Gnuplot 在同一Y范围内绘制数据
我有以下数据:Gnuplot 在同一Y范围内绘制数据,gnuplot,Gnuplot,我有以下数据: Channel1 3 5 Channel1 1 2 Channel2 1 3 我的目标是在同一行上绘制Channel1的值,我试图从这个问题中获得灵感:但是Channel1在Y轴上出现了2次 set terminal png size 1920,240 transparent set output "plot.png" $DATA << EOD Channel1 3 5 Channel1 1 2 Channel2 1 3 EOD set style fill sol
Channel1 3 5
Channel1 1 2
Channel2 1 3
我的目标是在同一行上绘制Channel1
的值,我试图从这个问题中获得灵感:但是Channel1
在Y轴上出现了2次
set terminal png size 1920,240 transparent
set output "plot.png"
$DATA << EOD
Channel1 3 5
Channel1 1 2
Channel2 1 3
EOD
set style fill solid
boxwidth = 0.5
plot $DATA using (($2+$3)/2.):0:(($3-$2)/2.):(boxwidth/2.):yticlabels(1) w boxxyerrorbars notitle
设置终端png大小1920240透明
设置输出“plot.png”
$DATA如果您的关键字只是Channel+
,您可以定义一个函数来提取这个数字。
在下面的示例中,例如通道3缺失,因此将存在间隙。
如果您的关键字是任意的,那么您必须构建一个唯一的关键字列表(类似于哈希表或字典)并分配数字。这在gnuplot中也是可能的,但有点“复杂”
代码:
### a simple chart with keywords
reset session
$Data <<EOD
Channel1 3.0 5.0
Channel2 1.0 2.0
Channel1 1.1 2.2
Channel4 2.7 3.5
Channel5 0.2 1.3
Channel5 2.6 4.3
EOD
myY(col) = int(strcol(col)[strlen("Channel")+1:])
set style fill solid 1.0
boxwidth = 0.5
set offsets 0.1,0.2,0.5,0.5
plot $Data u (($2+$3)/2.):(myY(1)):(($3-$2)/2.):(boxwidth/2.):yticlabels(1) \
w boxxyerrorbars lc rgb "web-green" notitle
### end of code
###一个包含关键字的简单图表
重置会话
$Data