如何在多图上方添加白色 space?

How to add white space above multiplot?

我正在使用 gnuplot 的多绘图环境。 我很难找到一种方法来增加白色 space 以上 所有情节以为传说腾出一些空间。 我设法通过声明 4,1 的布局但实际上仅使用前三个子图来在图 space 下方添加白色 space 。 (所以底部是空白的,我可以放 xlabel)。 如果我增加顶部的边距,那么第一个图就会被挤压,如图所示。 我怎样才能在上面添加这个额外的白色 space 以 简单 的方式保持所有子图的相同高度。 在这里我把我的简单代码

 


set term pdfcairo size 6,4
set output "currents.pdf"
set xrange [0:1]

set tmargin 0
set bmargin 0
set lmargin 10
set rmargin 2


set multiplot layout 4,1 


############################################# PLOT 1
set tmargin 2

set grid xtics ytics lt 1 lc "grey"

set ytics (-50,-40,-30,-20,-10,0,10,20,30)

set format x ''

set ylabel "[mV]" offset -3,0

set key at screen 0.8,0.97

plot "ionic_model_0d.csv" using 1:2 title "u" with lines lt 2 lc "red"

set tmargin 0 



################################################# PLOT 2
set key at screen 0.4,0.97

plot "ionic_currents.csv" using "Time":"INaK" with lines 



################################################# PLOT 3
set format x "%1.1f" 

set yrange [-0.002:0.022]

set xtics  (0,0.2,0.4,0.6,0.8,1)

set ytics (0.002,0.006,0.01,0.014,0.018,)

set ylabel "[nA]" offset 0,0

set xlabel "Time [s]"

set grid xtics ytics lt 1 lc "grey"  

set key at screen  0.68,0.97

plot "ionic_currents.csv" using "Time":"Ito" with lines lt 2 lc "blue" 


unset multiplot 

set lmargin screen 0.1
set multiplot layout 4,1 
set multiplot next         # skip the first plot
plot x
plot x**2
set label 1 center at screen 0.5, 0.95
set label 1 "Some title that goes above all the plots"
plot x**3
unset multiplot

编辑: 这是另一种方法。因为标题字体指定为较大(本例中为 50pt),所以为其预留了额外的空间。但是您可以巧妙地处理实际文本并切换回较小的字体。 或者您可以使用 whitespace " " 作为标题,以便保留 space,然后将 space 与单独的 set label 命令一起使用。

set margins 10,10,0,0
unset xtics

set multiplot layout 4,1 title "Overall title" font ",50" offset 0,-1 right
  plot x
  plot x**2
  set label 1 at screen 0.6, 0.95 left "Label line 1\nline 2\nline 3"
  plot x**3
unset multiplot

我对你的问题的理解如下:

  • 垂直和水平子图大小相等
  • 子图之间没有space
  • xtics 仅在底部图表中(不是 no xtics,如 Ethan 的解决方案)
  • 可定制的上边距
  • key/legend 不在子图中但在顶部图上方(不是像 Ethan 的解决方案中那样没有线条的标签)

我想这就是为什么在 gnuplot 5.0 中引入了 multiplot 选项 marginsspacing 的原因。 检查 help multiplot。 如果想让按键在上图上方,可以把所有的按键都设置在一个固定的屏幕y坐标myKeyY,但是你必须自己分配按键和设置x坐标或者定义一个函数来设置x 位置自动。此外,您想适当地设置 ytics 以避免零间隙图的 ytic 标签重叠。

代码:

### add space on top of multiplot
reset # session

set multiplot layout 3,1 margins 0.12,0.95,0.11,0.87 spacing 0,0 \
            title "Measurements" font ",14" offset 4,0
    myKeyY = 0.93
    
    unset xlabel
    set format x ""
    set ylabel "[mV]"
    set ytics 5
    set grid xtics, ytics
    set key at screen 0.6,myKeyY
    plot x w l lc "red" title "u"

    set ytics 0,20,80
    set key at screen 0.75,myKeyY
    plot x**2 w l lc "web-green" title "INaK"

    set xlabel "Time [s]"
    set xtics
    set key at screen 0.9,myKeyY
    set ylabel "[nA]"
    set ytics -1000,500,500
    set format "%g"
    plot x**3 w l lc "web-blue" title "Ito"

unset multiplot
### end of code

结果: