多图-在较大的画布上堆叠3个图 [英] multiplot - stacking 3 graphs on a larger canvas
问题描述
我一直在尝试以3:3(宽高比)的比率在画布上以多图布局将3个图形堆叠在一起的尝试非常失败.
I have been trying very unsuccessfully to stack 3 graphs together in a multi-plot layout on a canvas that is a ratio of 2:3(width by height).
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个多图图形似乎相互重叠.
When I do something like above, I get the plot shown below, there's a lot of blank space at the top of the canvas and the 3 multiplot graphs seem to overlap each other.
任何帮助或指针,将不胜感激.
Any kind of help or pointer will be greatly appreciated.
推荐答案
要使用更大的画布,设置终端时必须使用size
选项,例如:
In order to use a bigger canvas, you must use the size
option when setting the terminal, e.g.:
set terminal postscript eps enhanced size 10cm,15cm
set size
只是更改相对于画布的打印大小.要看到这一点,请考虑
set size
just changes the plot size relative to your canvas. To see this, consider
set terminal wxt
set size 1.0,1.5
plot sin(x)
部分情节消失了,因为相对于画布而言,情节太高了.
Parts of the plot disappear, because it is much too high with respect to the canvas.
要堆叠三个具有相同高度的地块,我认为最好使用固定边距:
To stack three plots with same heights, in my opinion its best to use fixed margins:
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):
The result is (with 4.6.3):
为避免ytics
的标签重叠,必须更改绘制抽签的范围,例如使用set ytics -100,50,100
,将ytics置于-100
和100
之间,步长为50
.使用set ytics rangelimited
不起作用
In order to avoid overlapping labels of the ytics
, you must change the range where the tics are drawn, e.g. with set ytics -100,50,100
, which puts ytics between -100
and 100
in steps of 50
. Using set ytics rangelimited
doesn't work
要增加绘图曲线和边框之间的距离,请像在上面的脚本中一样,将set offset
与graph
坐标一起使用.
To increase the distance between the plot curve and the border, use set offset
with graph
coordinates, like done in the above script.
我从最低的情节开始,因为只有那个情节有x个标签和一个xlabel
.
I started with the lowest plot, because only that has x labels and an xlabel
.
这篇关于多图-在较大的画布上堆叠3个图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!