开发者

Y-value on bar graph in gnuplot?

Can I get gnuplot to display the exact y-value or height of a data point (plotted using "with boxes") over its bar? I would like the plot to be easy to read 开发者_如何学Goso nobody has to line up the top of a bar with the y-axis and guess what the value is.


You can use the labels style and combine it into the plot command with the boxes style. The labels style expects 3 columns of data - the x coordinate, the y coordinate, and the actual label text.

For example, with the following data

1 4
2 6
3 2
4 8

the command (we set the yrange to 0 - 10 and boxwidth to 0.9 and set a solid fill style)

plot datafile u 1:2 with boxes, "" u 1:2:2 with labels offset char 0,1

produces

Y-value on bar graph in gnuplot?

Normally, the labels would be centered on the specified point (the top edge of the box). By specifying an offset, we can move them up to just above the box. Here we used no offset in the x direction, but a unit of 1 in the y direction. We used the character coordinate system, so this corresponds to moving up by one character unit.


I can only think of putting the values where you want them "manually" like this:

set label "value" at 12,34

The numbers are coordinates according to your x and y ranges.


An automatic way would use "with labels", see e.g. http://gnuplot.sourceforge.net/demo_4.4/stringvar.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜