在gnuplot中为直方图添加垂直标记线

在gnuplot中为直方图添加垂直标记线,gnuplot,histogram,Gnuplot,Histogram,在绘制函数时,有一些指令可以在gnuplot中获取垂直线。如使用设置箭头功能。我需要这个直方图的功能,结果是直方图在X轴上的位置不同,为0.0。在我的例子中,X轴标记只是数据文件中的字符串 绘制柱状图时,最好将平均值+-3sigma和X=0点从图的顶部到底部用垂直线标记,并用深色实线表示 我的直方图代码: set boxwidth 1.0 absolute set style line 1 lc rgb 'skyblue' set style fill solid border lt -1 se

在绘制函数时,有一些指令可以在gnuplot中获取垂直线。如使用
设置箭头
功能。我需要这个直方图的功能,结果是直方图在X轴上的位置不同,为0.0。在我的例子中,X轴标记只是数据文件中的字符串

绘制柱状图时,最好将平均值+-3sigma和X=0点从图的顶部到底部用垂直线标记,并用深色实线表示

我的直方图代码:

set boxwidth 1.0 absolute
set style line 1 lc rgb 'skyblue'
set style fill solid border lt -1
set style data histogram
set style histogram clustered gap 0.0
set xtics in rotate by 90 offset first +0.5,0 right
set xlabel
set ylabel 'Count'
set terminal unknown
plot 'histo.raw' using 3
set title 'data'
set yrange [0:GPVAL_DATA_Y_MAX*1.2]
set term X11
plot 'histo.raw' using 3:xtic(2) ls 1 title columnheader(1)
set arrow 1 from 0.0,0.0 to 0.0,GPVAL_DATA_Y_MAX*1.2 nohead
我的数据:

"data"
     0 "-INF ->  -5.0"      0   0.00
     1 " -5.0 ->  -4.5"      0   0.00
     2 " -4.5 ->  -4.0"      2   0.03
     3 " -4.0 ->  -3.5"      4   0.06
     4 " -3.5 ->  -3.0"      3   0.05
     5 " -3.0 ->  -2.5"      5   0.08
     6 " -2.5 ->  -2.0"     19   0.30
     7 " -2.0 ->  -1.5"     49   0.78
     8 " -1.5 ->  -1.0"    193   3.07
     9 " -1.0 ->  -0.5"    527   8.39
    10 " -0.5 ->  +0.0"   1289  20.53
    11 " +0.0 ->  +0.5"   1878  29.90
    12 " +0.5 ->  +1.0"   1411  22.47
    13 " +1.0 ->  +1.5"    636  10.13
    14 " +1.5 ->  +2.0"    178   2.83
    15 " +2.0 ->  +2.5"     56   0.89
    16 " +2.5 ->  +3.0"     17   0.27
    17 " +3.0 ->  +3.5"      9   0.14
    18 " +3.5 ->  +4.0"      4   0.06
    19 " +4.0 ->  +4.5"      0   0.00
    20 " +4.5 ->  +5.0"      0   0.00
    21 " +5.0 -> +INF"      0   0.00
set arrow
功能将线路置于错误位置

set arrow 1 from 0.0,0.0 to 0.0,GPVAL_DATA_Y_MAX*1.2 nohead
在此数据中

mean= 0.2743
sigma= 0.7491
谢谢你的想法


Gert

我发现直方图条定义了从左到右的X坐标。因为我有22个柱状图条的22个数据行,所以将11.0添加到行位置就完成了这项工作

set boxwidth 1.0 absolute
set style line 1 lc rgb 'skyblue'
set style fill solid border lt -1
set style data histogram
set style histogram clustered gap 0.0
set xtics in rotate by 90 offset first +0.5,0 right
set xlabel
set ylabel 'Count'
set terminal unknown
plot 'histo.raw' using 3
set title 'data'
set yrange [0:GPVAL_DATA_Y_MAX*1.2]
set terminal png size 1200,800
set output 'histo.png'
mean= +0.2743
sdev= +0.7491
lboffs= 0.2
set arrow  from 11.0 + mean,0.0 to 11.0 + mean ,GPVAL_DATA_Y_MAX*1.2 nohead lw 2 lc rgb "dark-green"
set arrow  from 11.0 + mean - 3 * sdev,0.0 to 11.0 + mean - 3 * sdev ,GPVAL_DATA_Y_MAX*1.2 nohead lw 2 lc rgb "red"
set arrow  from 11.0 + mean + 3 * sdev,0.0 to 11.0 + mean + 3 * sdev ,GPVAL_DATA_Y_MAX*1.2 nohead lw 2 lc rgb "red"
set arrow  from 11.0,0.0 to 11.0,GPVAL_DATA_Y_MAX*1.2 nohead lw 2 lc rgb "blue"
set label "Mean" at 11.0 + mean + lboffs,GPVAL_DATA_Y_MAX*1.1 tc rgb "dark-green"
set label "+3%"  at 11.0 + mean + 3 * sdev + lboffs,GPVAL_DATA_Y_MAX*1.1 tc rgb "red"
set label "-3%"  at 11.0 + mean - 3 * sdev + lboffs,GPVAL_DATA_Y_MAX*1.1 tc rgb "red"
plot 'histo.raw' using 3:xtic(2) ls 1 title columnheader(1)
set output
set term X11