如何在打印时对齐标签;带标签;在Gnuplot?
以下plot命令生成条形图,每个条形图上方的值都以标签形式打印,格式为gprintf:如何在打印时对齐标签;带标签;在Gnuplot?,plot,label,gnuplot,Plot,Label,Gnuplot,以下plot命令生成条形图,每个条形图上方的值都以标签形式打印,格式为gprintf: plot "data.txt" using 6:1 index 0 notitle with boxes linestyle 1,\ "data.txt" using 6:(0.7):(gprintf("%5.2f", $1)) index 0 notitle \ with labels font "Courier,34"
plot "data.txt" using 6:1 index 0 notitle with boxes linestyle 1,\
"data.txt" using 6:(0.7):(gprintf("%5.2f", $1)) index 0 notitle \
with labels font "Courier,34" rotate left
我希望值标签右对齐,这样我就可以使用外观更好的Helvetica字体而不是Courier来对齐小数点
那么,如何在上述命令中包含对正呢
我在Gnuplot文档或Web上找不到关于这个特定问题的任何信息。其他标签可以很容易地对齐,但在使用标签打印时也可以对齐吗?您可以使用
%5.2f”
格式将打印字段的宽度指定为5个空格。小数部分用2个空格,小数点用1个空格,整数部分只剩下2个空格。因此,如果绘制的数字不是指定的0.7
,则生成的字符串将更宽。
此外,Helvetica是一种非单空格字体,因此数字的字符宽度不同。因此,正确对齐输出不会解决问题-“.11”和“.88”将不会对齐小数点。我无法测试您的特定示例,但我的示例如下所示:
...
plot "test.dat" using ..., \
"" using ($1-100000):2:3 with labels rotate left notitle
...
。。。其中“向左旋转
”部分取自OP
嗯,我没有太多的运气在网上找到关于标签“对齐”或“对齐”的信息;所以我试着查看在线gnuplot帮助。基本上,相关的东西都在帮助设置标签下
——我不确定我到底是如何开始的,但下面是我的命令日志
。。。得到完全相同的输出图。如果最后我们将左
替换为右
,如下所示:
...
plot "test.dat" using ..., \
"" using ($1-100000):2:3 with labels right rotate notitle
...
。。。我们可以看到标签仍然“向左”(逆时针90度)旋转,但是,现在它与位置右对齐
好吧,希望这有帮助,干杯 这可能是一个新问题,并且在最初提出这个问题时不存在。但至少在Gnuplot 5.2中,我发现我能够通过只使用
并保留标签来实现这一点。这是真的,小数点不会完全对齐,但如果字体看起来更好,我接受一个不太理想的解决方案。另外,我想知道在这种特殊情况下,在证明标签的合理性方面是否缺少一些东西。也许你应该使用格式字符串?出于好奇,尝试左对齐,使用减号“%-5.2f”。
...
plot "test.dat" using ..., \
"" using ($1-100000):2:3 with labels left rotate notitle
...
...
plot "test.dat" using ..., \
"" using ($1-100000):2:3 with labels right rotate notitle
...