我正在尝试绘制一个带有断轴的直方图(使用 gnuplot (5.4 版本)),但我无法使两个图中的 y 范围一致。对于 y 范围从 [0:-8] 开始的绘图,间隔为 -1。但对于 y 范围从 [-16:-20] 开始的图,间隔为 -0.5 而不是 -1。那么有什么办法可以使两个图中的间隔一致呢?任何这方面的建议都会非常有帮助。
谢谢
set encoding iso_8859_1
set terminal postscript eps enhanced size 5.7, 4.3 color solid linewidth 2 font 'Times-Roman, 22'
set output 'test4.eps'
red = "#FF0000"; green = "#00FF00"; blue = "#0000FF"; skyblue = "#87CEEB";
reset
unset key
bm = 0.05
lm = 0.12
rm = 0.95
tm = 0.5
gap = 0.03
size =0.68
kk = 0.5 # relative height of bottom plot
y1 = 0.0; y2 = -8.0; y3 = -16; y4 = -20
ntics = 5
set style histogram cluster gap 1
set style data histogram
#set key autotitle columnheader
set style fill solid 1.0 border -1
set multiplot
set border 2+4+8
unset xtics
set x2tics nomirror
set x2tics rotate
#set grid ytics
set ytics nomirror
set xlabel 'Metals' font 'Times-Roman, 22' offset 0, 16.5;
set ylabel 'd-band' font 'Times-Roman, 22' offset -1.5, -6;
#set lmargin at screen lm
#set rmargin at screen rm
#set bmargin at screen bm
#set tmargin at screen bm + size * kk
set lmargin at screen lm
set rmargin at screen rm
set bmargin at screen bm + size * kk + gap
#set tmargin at screen bm + size * (abs(y2-y1) / (abs(y2-y1) + abs(y4-y3))) + gap
set tmargin at screen bm + size + gap
set yrange [y2:y1]
plot "d-band.dat" using 2:x2tic(1) title "Neutral" linecolor rgb '#616161', \
"d-band.dat" using 3 title "Positive" linecolor rgb '#EF6C00', \
"d-band.dat" using 4 title "Negative" linecolor rgb '#039BE5',
unset x2tics
unset xtics
#unset ytics
unset xlabel
unset ylabel
set key at 11, -18.3
set border 2+1+8
#set ytics nomirror
#set bmargin at screen bm + size * kk + gap
#set tmargin at screen bm + size + gap
#set lmargin at screen lm
#set rmargin at screen rm
set bmargin at screen bm
set tmargin at screen bm + size * kk
#set tmargin at screen bm + size * (abs(y2-y1) / (abs(y2-y2) + abs(y4-y3)))
set yrange [y4:y3]
plot "d-band.dat" using 2:x2tic(1) title "Neutral" linecolor rgb '#616161', \
"d-band.dat" using 3 title "Positive" linecolor rgb '#EF6C00', \
"d-band.dat" using 4 title "Negative" linecolor rgb '#039BE5',
unset multiplot
一种没有多图的可能解决方案...您可以使用非线性轴做一些事情,请检查
help nonlinear
。
由于我没有您的数据,因此我创建了一些更简单的数据并仅用方框绘制了它。
这可能可以进行微调,例如自定义间隙,让
-16
出现在 y 轴等
脚本:(适用于 gnuplot>=5.2.0)
### broken axis with equal ytic spacing using nonlinear axis
reset session
$Data <<EOD
A -19.5
B -4.0
C -1.0
D -18.3
E -7.0
F -5.0
EOD
y1 = 0.0
y2 = -8.0
y3 = -16
y4 = -20
set yrange[-y4:y1]
f(y) = y<y3 ? y-y3+y2 : y
g(y) = y<y2 ? y+y3-y2 : y
set nonlinear y via f(y) inverse g(y)
set x2tics out mirror
unset xtics
set grid y
set key noautotitle
set boxwidth 0.7
set style fill solid 0.3
set obj 1 rect from graph -0.01, first y2-0.1 to screen 1.0, first y2-0.5 fc "white" front fs noborder
plot $Data u 0:2:0:x2tic(1) w boxes lc var
### end of script
结果: