我一直试图在画布上的多图布局中将3个图堆叠在一起,但比例为2:3(宽高比)。
set terminal postscript eps enhanced "Helvetica" 24 color
set output "data.eps"
set timefmt "%s"
#set size 1.0,1.5
#set bmargin 2
#set tmargin 2
set size 1.0,1.5
set multiplot layout 3,1
set size 1.0,0.5
set tmargin 2
set bmargin 0
set ylabel 'Distance'
set format x ""
set ytics nomirror font "Helvetica,10"
set key top
plot "trace1.dat" using 1:3 axes x1y1 title "distances" with lines lw 2 lc rgb 'blue'
set size 1.0,0.5
set bmargin 0
set tmargin 0
set ylabel 'Power (W)'
set format x ""
set ytics nomirror font "Helvetica,10"
set key top
plot "trace2.dat" using 1:2 axes x1y1 title "device" with lines lw 2 lc rgb 'red'
set size 1.0,0.5
set bmargin
set tmargin 0
set xdata time
set ylabel 'Power (W)'
set xlabel 'Time (EST)' offset 0,-2.8 font "Helvetica,32
set format x "%b %d, %H:%M"
set ytics nomirror font "Helvetica,10"
set xtics nomirror rotate by 90 offset 0,-2.0 out font "Helvetica,10"
set key top
plot "trace3.dat" using 1:2 axes x1y1 title "aggr" with lines lw 2 lc rgb 'blue'
unset multiplot
当我做上面这样的事情时,我得到如下所示的情节,画布顶部有很多空白区域,3个多重图表似乎相互重叠。
非常感谢任何形式的帮助或指针。
答案 0 :(得分:16)
为了使用更大的画布,您必须在设置终端时使用size
选项,例如:
set terminal postscript eps enhanced size 10cm,15cm
set size
只是改变了相对于画布的绘图大小。要看到这一点,请考虑
set terminal wxt
set size 1.0,1.5
plot sin(x)
剧情的一部分消失了,因为相对于画布而言它太高了。
要堆叠三个具有相同高度的图,我认为最好使用固定边距:
set terminal pngcairo size 600, 900
set output 'stacking.png'
set lmargin at screen 0.15
set rmargin at screen 0.95
TOP=0.98
DY = 0.29
set multiplot
set offset 0,0,graph 0.05, graph 0.05
set xlabel 'time'
set ylabel 'ylabel 1' offset 1
set tmargin at screen TOP-2*DY
set bmargin at screen TOP-3*DY
set ytics -1000,500,1000
plot 1150*cos(x) title 'First'
set xtics format ''
unset xlabel
set ylabel 'ylabel 2' offset 0
set tmargin at screen TOP-DY
set bmargin at screen TOP-2*DY
set ytics -100,50,100
plot 101*sin(x) title 'Second'
set ylabel 'ylabel 3' offset -1
set tmargin at screen TOP
set bmargin at screen TOP-DY
set ytics -8,4,8
plot 10*sin(2*x) title 'Third'
unset multiplot; set output
结果是(用4.6.3):
为了避免重叠ytics
的标签,您必须更改抽取抽搐的范围,例如使用set ytics -100,50,100
,以-100
的步长将ytics放在100
和50
之间。使用set ytics rangelimited
不起作用
要增加绘图曲线与边框之间的距离,请将set offset
与graph
坐标一起使用,就像在上面的脚本中所做的那样。
我从最低的情节开始,因为只有x标签和xlabel
。
答案 1 :(得分:5)
您也需要使用set origin
。
set terminal postscript eps enhanced
set output "data.eps"
set size 1.0,1.5
set multiplot layout 3,1
set size 1.0,0.5
set origin 0,1
...
plot ...
set size 1.0,0.5
set origin 0,0.5
...
plot ...
set size 1.0,0.5
set origin 0,0
...
plot ...
unset multiplot