gnuplot 绘制标签时出错

发布于 2024-12-15 16:16:20 字数 574 浏览 2 评论 0原文

我想绘制这个数据文件

“/root/temp.txt”

LB|30|421
CN|50|247
BR|20|370
SA|12|310

,其中第一列是 X 轴,第二列是 Y 轴,第三列是放置在直方图每列上方的标签。

在此之前,我使用此语法来绘制图形(但没有任何标签)

set terminal png ;
set title "Hello" ;
set xlabel "Country" ;
set ylabel "values" ;
set style fill solid ;
set xtic rotate -45 ;
set datafile separator "|" ;
set style data histograms ; 
plot '/root/temp.txt' using 2:xtic(1) notitle

但是如果我尝试添加标签 gnuplot 会给我错误!

我用来添加标签的语法是 使用 2:xtic(1):3 和标签 notitle 绘制 '/root/temp.txt'

你能帮我吗? 谢谢

I would like to plot this datafile

"/root/temp.txt"

LB|30|421
CN|50|247
BR|20|370
SA|12|310

Where the first column is the X Axis, the second one is the Y Axis and the third one the label to put above each column of the histogram.

Before now, I use this syntax to plot the graph (but without any label)

set terminal png ;
set title "Hello" ;
set xlabel "Country" ;
set ylabel "values" ;
set style fill solid ;
set xtic rotate -45 ;
set datafile separator "|" ;
set style data histograms ; 
plot '/root/temp.txt' using 2:xtic(1) notitle

But if I try to add labels gnu plot give me error!!

The syntax I use to add labels is
plot '/root/temp.txt' using 2:xtic(1):3 with labels notitle

Could you please help me?
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲欢浪云 2024-12-22 16:16:20

我不确定您是否可以压缩为一种绘图格式,但您可以使用 replot (或类似 replot 的绘图):

plot '/root/temp.txt' using 2:xtic(1) notitle, '' u ($0):2:3 with labels notitle

空“”导致重用最后一个输入(文件)。现在,它等于 '/root/temp.txt'

半重绘图解决方案

更好一点:

plot 'temp.txt' using 2:xtic(1) notitle, '' u ($0+0.1):($2+1):3 with labels notitle

移动标签

哦!并且不要忘记设置 png 术语的输出

I am not sure that you can compress into one plotting format, but you can use replot (or replot-like plot):

plot '/root/temp.txt' using 2:xtic(1) notitle, '' u ($0):2:3 with labels notitle

Empty '' induce reuse the last input(file). Now, it equals with '/root/temp.txt'

Solution with semi-replot

To be nicer:

plot 'temp.txt' using 2:xtic(1) notitle, '' u ($0+0.1):($2+1):3 with labels notitle

Shifted label

Oh! And don't forget to set output of png term!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文