如何在gnuplot中仅为1个数据源使用set offset?
我想在gnuplot中一起绘制两个数据源:一个来自数据文件,使用文本作为x数据(带有xticlabels和errorbar),另一个是常量 我不希望xticlabels到达图形的两侧,所以我使用“设置偏移”。但是,我确实希望常数到达图形的两侧 gnuplot脚本示例:如何在gnuplot中仅为1个数据源使用set offset?,gnuplot,Gnuplot,我想在gnuplot中一起绘制两个数据源:一个来自数据文件,使用文本作为x数据(带有xticlabels和errorbar),另一个是常量 我不希望xticlabels到达图形的两侧,所以我使用“设置偏移”。但是,我确实希望常数到达图形的两侧 gnuplot脚本示例: set terminal pngcairo size 500, 500 file = 'data.txt' set output 'plot.png' set xtics rotate by -45 set yrange [0:1
set terminal pngcairo size 500, 500
file = 'data.txt'
set output 'plot.png'
set xtics rotate by -45
set yrange [0:1]
set offset 0.5,0.5,0,0
plot file using 0:2:3:xticlabels(1) with yerrorbars notitle,\
0.5 notitle
使用关联的data.txt文件:
"Europe" 0.4 0.03
"North America" 0.8 0.05
"South America" 0.1 0.08
"Asia" 0.7 0.01
"Africa" 0.9 0.03
"Australia" 0.2 0.03
提供以下绘图:
但是,我想要下面的图:
如何实现这一点?您可以将常数绘制为无头箭头:
set arrow from graph 0, first 0.5 to graph 1, first 0.5 nohead lt 1
如果只需正确设置
xrange[]
,也可以获得相同的结果。
在您使用xticlabels(1)
时,欧洲=0,澳大利亚=5。
因此,只需设置xrange[-0.5:5.5]
。如果事先不知道项目数(此处为6),您可以通过$Data
或stats$Data
和stats\u记录来获取
代码:
### border when using xticlabels()
reset session
$Data <<EOD
"Europe" 0.4 0.03
"North America" 0.8 0.05
"South America" 0.1 0.08
"Asia" 0.7 0.01
"Africa" 0.9 0.03
"Australia" 0.2 0.03
EOD
set xtics rotate by -45
set xrange [-0.5:5.5]
set yrange [0:1]
plot $Data using 0:2:3:xticlabels(1) with yerrorbars notitle,\
0.5 notitle
### end of code
使用xticlabels()时的边框
重置会话
$Data