多重绘图在gnuplot中不显示相同的y轴范围

时间:2018-04-28 09:58:57

标签: plot gnuplot

使用gnuplot(下面的所有文件内容)绘制两个数据文件,但如下面的输出图像所示,y range是变化的。对于所有情节我都需要它[0:1]。我错过了什么?

两个数据文件data1.datdata2.dat分别为:

#x  y1  y2  y3  y4
0   0   1.1 0   3.0
1   0   1.5 0   1.9
2   0   2.1 0   2.4
3   0   1.0 0   1.4
4   0   3.2 0   1.6
5   0   2.8 0   1.2

#x  y1  y2  y3  y4
0   0   1.4 0   3.3
1   0   1.1 0   1.1
2   0   2.3 0   2.1
3   0   1.7 0   1.8
4   0   3.1 0   1.1
5   0   2.3 0   1.3

gnuplot data.gp文件:

set border linewidth 1.5


mpl_top    = 0.4 #inch  outer top margin, title goes here
mpl_bot    = 0.7 #inch  outer bottom margin, x label goes here
mpl_left   = 0.9 #inch  outer left margin, y label goes here
mpl_right  = 0.1 #inch  outer right margin, y2 label goes here
mpl_height = 1.5 #inch  height of individual plots
mpl_width  = 1.8 #inch  width of individual plots
mpl_dx     = 0.3 #inch  inter-plot horizontal spacing
mpl_dy     = 0.1 #inch  inter-plot vertical spacing
mpl_ny     = 1   #number of rows
mpl_nx     = 4   #number of columns


# calculate full dimensions
xsize = mpl_left+mpl_right+(mpl_width*mpl_nx)+(mpl_nx-1)*mpl_dx
ysize = mpl_top+mpl_bot+(mpl_ny*mpl_height)+(mpl_ny-1)*mpl_dy

# placement functions
#   rows are numbered from bottom to top
bot(n) = (mpl_bot+(n-1)*mpl_height+(n-1)*mpl_dy)/ysize
top(n)  = 1-((mpl_top+(mpl_ny-n)*(mpl_height+mpl_dy))/ysize)
#   columns are numbered from left to right
left(n) = (mpl_left+(n-1)*mpl_width+(n-1)*mpl_dx)/xsize
right(n)  = 1-((mpl_right+(mpl_nx-n)*(mpl_width+mpl_dx))/xsize)

set terminal epslatex size 3.5,2.62 color colortext
set output 'data.tex'
set xlabel '$x$'
set ylabel '$y$'

set key off

set multiplot


#-----------------------------------------------

#  set horizontal margins for first column
set lmargin at screen left(1)
set rmargin at screen right(1)
#  set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)

stats "data1.dat" u 2 name "A"
stats "data2.dat" u 2 name "B"
if (A_max <= 0.0) {A_max = 0.00001; set yr[0:1]}
if (B_max <= 0.0) {B_max = 0.00002; set yr[0:1]}

plot 'data1.dat' u 1:(A_max>B_max ? $2/A_max : $2/A_max) w l dt 1 lt rgb "red", 'data2.dat' u 1:(A_max>B_max ? $2/A_max : $2/A_max) w l dt 1 lt rgb "blue"

#-----------------------------------------------

unset yr
unset ylabel

#-----------------------------------------------
#  set horizontal margins for second column
set lmargin at screen left(2)
set rmargin at screen right(2)
#  set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)

stats "data1.dat" u 3 name "A"
stats "data2.dat" u 3 name "B"
if (A_max <= 0.0) {A_max = 0.00001; set yr[0:1]}
if (B_max <= 0.0) {B_max = 0.00002; set yr[0:1]}
plot 'data1.dat' u 1:(A_max>B_max ? $3/A_max : $3/A_max) w l dt 1 lt rgb "red", 'data2.dat' u 1:(A_max>B_max ? $3/A_max : $3/A_max) w l dt 1 lt rgb "blue"


#-----------------------------------------------

unset yr

#-----------------------------------------------

#  set horizontal margins for third column
set lmargin at screen left(3)
set rmargin at screen right(3)
#  set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)

stats "data1.dat" u 4 name "A"
stats "data2.dat" u 4 name "B"
if (A_max <= 0.0) {A_max = 0.00001; set yr[0:1]}
if (B_max <= 0.0) {B_max = 0.00002; set yr[0:1]}
plot 'data1.dat' u 1:(A_max>B_max ? $4/A_max : $4/A_max) w l dt 1 lt rgb "red", 'data2.dat' u 1:(A_max>B_max ? $4/A_max : $4/A_max) w l dt 1 lt rgb "blue"

#-----------------------------------------------

unset yr

#-----------------------------------------------

#  set horizontal margins for fourth column
set lmargin at screen left(4)
set rmargin at screen right(4)
#  set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)

stats "data1.dat" u 5 name "A"
stats "data2.dat" u 5 name "B"
if (A_max <= 0.0) {A_max = 0.00001; set yr[0:1]}
if (B_max <= 0.0) {B_max = 0.00002; set yr[0:1]}
plot 'data1.dat' u 1:(A_max>B_max ? $5/A_max : $5/A_max) w l dt 1 lt rgb "red", 'data2.dat' u 1:(A_max>B_max ? $5/A_max : $5/A_max) w l dt 1 lt rgb "blue"

unset multiplot
unset output

输出是: Output plot

P.S。为长文件道歉,但想把所有信息放在这里。如果/它让人困惑,请告诉我。

0 个答案:

没有答案