GnuPlot:在盒子中间写一些文字
我试图通过gnu绘图在绘图框的中间书写,但找不到一些优雅的方式。手动查找所有框的中间点非常繁琐。请引导我找出答案。GnuPlot:在盒子中间写一些文字,plot,gnuplot,Plot,Gnuplot,我试图通过gnu绘图在绘图框的中间书写,但找不到一些优雅的方式。手动查找所有框的中间点非常繁琐。请引导我找出答案。 正如评论中提到的@Christoph,plot。。。w标签是选项之一。唯一的额外因素在于计算标签的位置。例如,可以进行以下操作: set terminal pngcairo set output 'fig.png' fName='test.dat' bw = 0.9 yMin = 50 yMax = 130 xMin = 2 xMax = 15 set boxwidth
正如评论中提到的@Christoph,plot。。。w标签是选项之一。唯一的额外因素在于计算标签的位置。例如,可以进行以下操作:
set terminal pngcairo
set output 'fig.png'
fName='test.dat'
bw = 0.9
yMin = 50
yMax = 130
xMin = 2
xMax = 15
set boxwidth bw
set xr [xMin - bw/2:xMax + bw/2]
set yr [yMin:yMax]
#scale 0 makes sure that the tic marks don't "show up"
set format x "1 %.0f"
set xtics 2,1,15 rotate by -15 scale 0
set ytics 50,10,130 scale 0
set ylabel "TODO"
set xlabel "TODO"
set key top right
#place the labels in the "middle" with respect to the
#minimum on the y-axis
p \
100 t "Todo" lc rgb "black" dt 3, \
fName u 1:2 w boxes t "TODO" lc rgb "black", \
fName u 1:(($2-yMin)/2+yMin):(sprintf("%.0f", $2)) w labels t '' tc rgb 'dark-red'
这将产生:
假设数据文件test.dat为:
使用例如带有标签的绘图。
2 100
3 75
4 74
5 76
6 74
7 78
8 92
9 98
10 75
11 105
12 118
13 120
14 122
15 122