带绘图线的Gnuplot直方图
我正在使用Gnuplot创建一个带有打印线的直方图,但是,打印线与条形图头部不太匹配,而且我想将该线放在离条形图头部稍远的位置 更新: 这是数据文件:带绘图线的Gnuplot直方图,gnuplot,Gnuplot,我正在使用Gnuplot创建一个带有打印线的直方图,但是,打印线与条形图头部不太匹配,而且我想将该线放在离条形图头部稍远的位置 更新: 这是数据文件: 500000 25.938 25.938 2 1000000 52.385 52.385 4 1500000 79.749 78.405 6.125 2000000 152.589 100.261 12.
500000 25.938 25.938 2
1000000 52.385 52.385 4
1500000 79.749 78.405 6.125
2000000 152.589 100.261 12.479
2500000 224.869 118.364 19.159
这适用于任意数量的列,您必须在变量
N
中指定它们,并在调用自定义函数xbox
时对它们进行编号。对于非密集型使用,应该这样做。可以使用offset
变量(以y轴为单位)垂直偏移曲线
最好发布数据文件(或其中的重要部分)。我相信,通过使用子句对样条曲线的
进行一些调整,您将达到您想要的效果,但是第2列的内容可能会对简单的选择产生一些影响。“把线离杆头稍微远一点”是指整个样条曲线的垂直移动吗?@Joce我添加了数据文件,是的,我需要垂直移动以避免将绘图线与杆头粘在一起。
500000 25.938 25.938 2
1000000 52.385 52.385 4
1500000 79.749 78.405 6.125
2000000 152.589 100.261 12.479
2500000 224.869 118.364 19.159
set border 3
#number of columns to be plotted
N=3
#vertical offset
OFFSET=0
#gapwidth (set to gnuplot's default)
GW=2
xbox(x,i)=x+(i-N*0.5)/(N+GW)
set boxwidth 0.9
set tics nomirror out scale 0.75
set style fill solid 0.8
plot "03.txt" using 2:xtic(1) lt rgb "0060ad" notitle, \
"" using 2 with histogram notitle, \
"" using (xbox($0,1)):($2+OFFSET) smooth csplines notitle with lines ls 1, \
"" using 3 lt rgb "#ff6600" notitle with histogram, \
"" using (xbox($0,2)):($3+OFFSET) smooth csplines notitle with lines ls 2, \
"" using 4 lt rgb "#dd181f" notitle with histogram, \
"" using (xbox($0,3)):($4+OFFSET) smooth csplines notitle with lines ls 3