gnuplot:如何添加从0开始的错误条?
我想将错误条添加到从0开始的直方图中 示例类似于和,但它们都从条形图的峰值开始 这就是我目前制作条形图的方式:gnuplot:如何添加从0开始的错误条?,gnuplot,Gnuplot,我想将错误条添加到从0开始的直方图中 示例类似于和,但它们都从条形图的峰值开始 这就是我目前制作条形图的方式: set style histogram clustered unset title set xlabel "X" set ylabel "Y" set boxwidth 1 set style fill solid set term png set output "figure.png" plot [-0.5:4.5][0:10] "data.dat"using 2:xtic(1)
set style histogram clustered
unset title
set xlabel "X"
set ylabel "Y"
set boxwidth 1
set style fill solid
set term png
set output "figure.png"
plot [-0.5:4.5][0:10] "data.dat"using 2:xtic(1) title "Title 1" with histograms fillstyle pattern 1, \
"" using 3 title "Title 2" with histograms fillstyle pattern 2, \
"" using 4 title "Title 3" with histograms fillstyle pattern 3
我可以在data.dat文件中添加第四列,其中包含错误条的高度,但我不知道正确的打印方式
编辑:
为什么不用方框和脉冲以及点来“手动”?您没有提供示例数据,所以我创建了一些数据。
比如像这样。也许有更简单的方法
编辑:使用xtic字符串而不是数字
代码:
### manual histogram and percentile line
reset session
# n MedianX MedianY Perc90x Perc90y
$Data <<EOD
A 7.1 6.2 20.3 16.4
B 8.1 7.2 22.3 17.4
C 9.1 8.2 24.3 18.4
D 10.1 9.2 26.3 19.4
E 11.1 10.2 28.3 20.4
EOD
set style fill solid 1.0
w = 0.15
set boxwidth 0.3
set key top left
set xrange[-0.5:4.5]
set xtics 1
plot $Data u ($0-w):2 w boxes lc rgb "red" ti "Median x", \
'' u ($0+w):3 w boxes lc rgb "blue" ti "Median y", \
'' u ($0-w):4 w impulses dt 3 lc rgb "black" ti "90th Percentile", \
'' u ($0-w):4 w p pt 7 ps 1 lc rgb "black" not, \
'' u ($0+w):5 w impulses dt 3 lc rgb "black" not, \
'' u ($0+w):5 w p pt 7 ps 1 lc rgb "black" not, \
'' u 0:(NaN):xtic(1) not
### end of code
### manual histogram and percentile line
reset session
# n MedianX MedianY MedianZ Perc90x Perc90y Perc90z
$Data <<EOD
A 7.1 6.2 5.3 20.4 16.5 12.6
B 8.1 7.2 6.3 22.4 17.5 13.6
C 9.1 8.2 7.3 24.4 18.5 14.6
D 10.1 9.2 8.3 26.4 19.5 15.6
E 11.1 10.2 9.3 28.4 20.5 16.6
EOD
set style fill solid 1.0
w = 0.20
set boxwidth 0.20
set key top left
set xrange[-0.5:4.5]
set xtics 1
plot $Data u ($0-w):2 w boxes lc rgb "red" ti "Median x", \
'' u ($0):3 w boxes lc rgb "blue" ti "Median y", \
'' u ($0+w):4 w boxes lc rgb "web-green" ti "Median z", \
'' u ($0-w):(0):(0):5 w errorlines ls 0 ti "90th Percentile", \
'' u ($0):(0):(0):6 w errorlines ls 0 not, \
'' u ($0+w):(0):(0):7 w errorlines ls 0 not, \
'' u 0:(NaN):xtic(1) not, \
### end of code
结果:
### manual histogram and percentile line
reset session
# n MedianX MedianY Perc90x Perc90y
$Data <<EOD
A 7.1 6.2 20.3 16.4
B 8.1 7.2 22.3 17.4
C 9.1 8.2 24.3 18.4
D 10.1 9.2 26.3 19.4
E 11.1 10.2 28.3 20.4
EOD
set style fill solid 1.0
w = 0.15
set boxwidth 0.3
set key top left
set xrange[-0.5:4.5]
set xtics 1
plot $Data u ($0-w):2 w boxes lc rgb "red" ti "Median x", \
'' u ($0+w):3 w boxes lc rgb "blue" ti "Median y", \
'' u ($0-w):4 w impulses dt 3 lc rgb "black" ti "90th Percentile", \
'' u ($0-w):4 w p pt 7 ps 1 lc rgb "black" not, \
'' u ($0+w):5 w impulses dt 3 lc rgb "black" not, \
'' u ($0+w):5 w p pt 7 ps 1 lc rgb "black" not, \
'' u 0:(NaN):xtic(1) not
### end of code
### manual histogram and percentile line
reset session
# n MedianX MedianY MedianZ Perc90x Perc90y Perc90z
$Data <<EOD
A 7.1 6.2 5.3 20.4 16.5 12.6
B 8.1 7.2 6.3 22.4 17.5 13.6
C 9.1 8.2 7.3 24.4 18.5 14.6
D 10.1 9.2 8.3 26.4 19.5 15.6
E 11.1 10.2 9.3 28.4 20.5 16.6
EOD
set style fill solid 1.0
w = 0.20
set boxwidth 0.20
set key top left
set xrange[-0.5:4.5]
set xtics 1
plot $Data u ($0-w):2 w boxes lc rgb "red" ti "Median x", \
'' u ($0):3 w boxes lc rgb "blue" ti "Median y", \
'' u ($0+w):4 w boxes lc rgb "web-green" ti "Median z", \
'' u ($0-w):(0):(0):5 w errorlines ls 0 ti "90th Percentile", \
'' u ($0):(0):(0):6 w errorlines ls 0 not, \
'' u ($0+w):(0):(0):7 w errorlines ls 0 not, \
'' u 0:(NaN):xtic(1) not, \
### end of code
您能告诉我如何在XTIC中使用字母而不是数字吗?我尝试在数据文件中更改它们,但没有打印。然后您必须使用$0
作为x坐标(请参见帮助伪列
),并使用另一个打印命令来获取(未移动的)xtic标签。我修改了密码。我希望这完全回答了您的问题。我试图修改您的代码以使用3列。我有了工作的冲动和障碍,但我不能让XTIC正确地绘图。当我将data.dat文件中的数字改为字母时,它只绘制B、C、D、E,而没有任何条或脉冲。如果我没有看到您的实际代码,很难分辨。