在Gnuplot中绘制"带标签"时,如何证明标签的合理性?

Mar*_*ast 6 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" rotate left
Run Code Online (Sandbox Code Playgroud)

我希望值标签是右对齐的,所以我可以使用更好看的Helvetica字体而不是Courier来对齐小数点.

那么,我如何在上述命令中包含理由呢?

我没有在Gnuplot文档或Web上找到有关此特定问题的任何内容.其他标签可以很容易地证明,但是在用标签绘图时也可以吗?

sda*_*aau 5

我无法测试你的特定例子,但我的看起来像是:

...
plot "test.dat" using ..., \
"" using ($1-100000):2:3 with labels rotate left notitle
...
Run Code Online (Sandbox Code Playgroud)

......" rotate left"部分取自OP.

好吧,我没有太多运气找到关于网上标签的"对齐"或"理由"的信息; 所以我试着查看在线gnuplot的帮助.基本上,相关的东西都在help set label- 我不确定我是怎么做到的,但这是我的命令日志下面;

$ gnuplot
...
    G N U P L O T
    Version 4.4 patchlevel 2
...

Terminal type set to 'wxt'
gnuplot> help with labels
Sorry, no help for 'with labels'
gnuplot> help with 
 Functions and data may be displayed in one of a large number of styles.
 The `with` keyword provides the means of selection.

 Syntax:
       with  { {linestyle | ls }
...
where  is one of

      lines        dots       steps     errorbars     xerrorbar    xyerrorlines
      points       impulses   fsteps    errorlines    xerrorlines  yerrorbars
      linespoints  labels  ...
...
gnuplot> help labels
 The `labels` style reads coordinates and text from a data file and places
 the text string at the corresponding 2D or 3D position.  3 or 4 input columns
 of basic data are required.  ....

      3 columns:  x  y  string    # 2D version
...
 See also `datastrings`, `set style data`.

gnuplot> help set label
 Arbitrary labels can be placed on the plot using the `set label` command.

 Syntax:
       set label {} {""} {at }
                 {left | center | right}
                 {norotate | rotate {by }}
                 ...
 By default, the text is placed flush left against the point x,y,z.  To adjust
 the way the label is positioned with respect to the point x,y,z, add the
 justification parameter, which may be `left`, `right` or `center`,
 indicating that the point is to be at the left, right or center of the text.
 Labels outside the plotted boundaries are permitted but may interfere with
 axis labels or other text.

 If `rotate` is given, the label is written vertically (if the terminal can do
 so, of course).  If `rotate by ` is given, conforming terminals will
 try to write the text at the specified angle; non-conforming terminals will
 treat this as vertical text.

相关部分用粗体表示; 并且他们解释了我的一个误解 - rotate left在OP示例中看到,我认为left是属性rotate,但它不是 - left是一个单独的对齐参数,rotate而是一个单独的旋转关键字(即rotate left并不意味着" 逆时针旋转90度" "正如我最初想的那样).

如果是这样,那么可以将这两个关键字反转:

...
plot "test.dat" using ..., \
"" using ($1-100000):2:3 with labels left rotate notitle
...
Run Code Online (Sandbox Code Playgroud)

...并得到完全相同的输出图.如果最后我们替换leftright,如:

...
plot "test.dat" using ..., \
"" using ($1-100000):2:3 with labels right rotate notitle
...
Run Code Online (Sandbox Code Playgroud)

...我们可以看到标签仍然 "向左"旋转(逆时针旋转90度) - 但是,它现在与位置右对齐.

好吧,希望这会
有所帮助,干杯!