问题描述
我想制作一个gnuplot多重绘图,其中三个绘图彼此重叠。到目前为止,它一直有效,当我不添加x轴标签并将每个tmargin和bmargin设置为相等时。但是,当我在最低绘图下添加x轴标签和xtics时,该绘图的高度会缩小-如图所示。您有一个想法如何在最低图下用x轴标签制作大小相等的图?
这是我的代码:
reset
set lmargin 9
set rmargin 3
unset key
set xrange [-1:41]
set Boxwidth 0.4
set style fill solid noborder
set multiplot layout 3,1
set xtics format ""
set xtics 5
unset xlabel
set ytics 100
set logscale y
set format y "10^{%L}"
set key ins vert right top
set tmargin 0.8
set bmargin 0.5
set yrange [1:100000000]
#set ylabel "Photonen / s [Mio.]" offset 0,0 font ""
plot "300sLinienMit0.txt" u (($1)):($2/300) w Boxes lc rgb "#6699ff" title "185,72 keV"
set xtics format ""
unset xlabel
set ytics 10
set tmargin 0.5
set bmargin 0.5
set yrange [1:1000]
set ylabel "Photonen [s^{-1}]" offset -2,0 font ""
plot "300sLinienMit0.txt" u ($1):($3/300) w Boxes lc rgb "#ff6600" title "351,03 keV"
unset ylabel
set xtics format ""
unset xlabel
set tmargin 0.5
set yrange [1:1000]
set format x "%g"
set xtics 5 offset 0,0
set bmargin 3.5
set xlabel "Blei-Abschirmung [mm]" offset 0,0 font ""
#set ylabel "Photonen / s [Tsd.]" offset 0,0 font ""
plot "300sLinienMit0.txt" u ($1):($4/300) w Boxes lc -1 title "831,98 keV"
unset multiplot
解决方法
您必须在多图环境中设置自己(子)图的位置和大小。
重要的是set bmargin 0
。您通过set origin 0,myBottomMargin
设置的底部图的边距。然后相应地设置其他图的原点和大小。我希望下面的代码能自我解释。
代码:
### multiplot with equal plot heights
reset session
myBottomMargin = 0.15
myPlotHeight = (1. - myBottomMargin)/3
set multiplot
set xlabel "This is the xlabel for all plots"
set ytics 0.5
set grid xtics,ytics
set origin 0,myBottomMargin
set size 1,myPlotHeight
set bmargin 0
set label 1 at graph 1.0,graph 1.0 "185.72 keV" right offset -1,-1
plot sin(x) w l lc 1 notitle
unset xlabel
set format x ""
set origin 0,myBottomMargin+myPlotHeight
set label 1 at graph 1.0,graph 1.0 "351.03 keV" right offset -1,-1
plot sin(2*x) w l lc 2 notitle
set origin 0,myBottomMargin+2*myPlotHeight
set label 1 at graph 1.0,graph 1.0 "831.98 keV" right offset -1,-1
plot sin(3*x) w l lc 3 notitle
unset multiplot
### end of code
结果: