Search code examples
gnuplot

How to place a text below plots using multiplot


I am using Gnuplot version 5.4. I have 4 plots generated by the code:

set size 1, 1
set origin 0.0, 0.0
set term postscript eps enhanced color 'Helvetica' 15
set output 'sig_tau2.eps'
set multiplot layout 2,2
set style fill solid 1.0 noborder
set size square
set xtics ("0" 0, "175" 175, "350" 350) font "Helvetica,15"
set ytics ("0" 0, "2" 2, "4" 4) font "Helvetica,15"
set cbtics ("-0.0075" -0.0075, "0" 0, "0.0075" 0.0075) font "Helvetica,15"
set xlabel "{/Symbol t}" font "Helvetica,15"
set label "{/Symbol s}" font "Helvetica,15" at graph -0.3, graph 0.6
set label "{Re{/Symbol z}_{max}}" font "Helvetica,15" at graph 1.3, graph 0.5
set pm3d map #Achte auf das Format der Datendatei (Leerzeilen!)
set cbrange [-0.0075:0.0075]
set xrange [0:350]
set yrange [0:4]
set palette defined (-0.0075 0 0 1, 0 0 1 0, 0 "yellow", 0.0075 1 0 0)
set colorbox
set title "(a)" font "Helvetica Bold,15"
unset key
splot "1.dat" u 1:2:4 title""

unset xtics
unset ytics
unset cbtics
unset xlabel
unset label
unset label
unset cbrange
unset xrange
unset yrange
unset pm3d

set xtics ("0" 0, "175" 175, "350" 350) font "Helvetica,15"
set ytics ("0" 0, "2" 2, "4" 4) font "Helvetica,15"
set cbtics ("-0.0075" -0.0075, "0" 0, "0.0075" 0.0075) font "Helvetica,15"
set xlabel "{/Symbol t}" font "Helvetica,15"
set label "{/Symbol s}" font "Helvetica,15" at graph -0.3, graph 0.6
set label "{Re{/Symbol z}_{max}}" font "Helvetica,15" at graph 1.3, graph 0.5
set pm3d map #Achte auf das Format der Datendatei (Leerzeilen!)
set cbrange [-0.0075:0.0075]
set xrange [0:350]
set yrange [0:4]
set palette defined (-0.0075 0 0 1, 0 0 1 0, 0 "yellow", 0.0075 1 0 0)
set colorbox
set title "(b)"
unset key
splot "2.dat" u 1:2:4 title""

unset xtics
unset ytics
unset cbtics
unset xlabel
unset label
unset label
unset cbrange
unset xrange
unset yrange
unset pm3d

set xtics ("0" 0, "175" 175, "350" 350) font "Helvetica,15"
set ytics ("0" 0, "4" 4, "8" 8) font "Helvetica,15"
set cbtics ("-0.0075" -0.0075, "0" 0, "0.0075" 0.0075) font "Helvetica,15"
set xlabel "{/Symbol t}" font “Helvetica,15"
set label "{/Symbol s}" font "Helvetica,15" at graph -0.3, graph 0.6
set label "{Re{/Symbol z}_{max}}" font "Helvetica,15" at graph 1.3, graph 0.5
set pm3d map #Achte auf das Format der Datendatei (Leerzeilen!)
set cbrange [-0.0075:0.0075]
set xrange [0:350]
set yrange [0:8]
set palette defined (-0.0075 0 0 1, 0 0 1 0, 0 "yellow", 0.0075 1 0 0)
set colorbox
set title "(c)"
unset key
splot "3.dat" u 1:2:4 title""

unset xtics
unset ytics
unset cbtics
unset xlabel
unset label
unset label
unset cbrange
unset xrange
unset yrange
unset pm3d

set xtics ("0" 0, "175" 175, "350" 350) font "Helvetica,15" 
set ytics ("0" 0, "6" 6, "12" 12) font "Helvetica,15"
set cbtics ("-0.0075" -0.0075, "0" 0, "0.0075" 0.0075) font "Helvetica,15"
set xlabel "{/Symbol t}" font "Helvetica,15"
set label "{Figure 2: Stability region of the endemic equilibrium in σ-τ plane. Color code denotes the maximum real part of ζ.}" font "Helvetica,15" at graph -0.3, graph -0.1
set label "{/Symbol s}" font "Helvetica,15" at graph -0.3, graph 0.6
set label "{Re{/Symbol z}_{max}}" font "Helvetica,15" at graph 1.3, graph 0.5
set pm3d map #Achte auf das Format der Datendatei (Leerzeilen!)
set cbrange [-0.0075:0.0075]
set xrange [0:350]
set yrange [0:12]
set palette defined (-0.0075 0 0 1, 0 0 1 0, 0 "yellow", 0.0075 1 0 0)
set colorbox
set title "(d)"
unset key
splot "4.dat" u 1:2:4 title""
unset multiplot

and I would like to place a text below these graphs like the one in this picture: enter image description here

Would it be possible to do this while maintaining the plots sizes?

I tried to use set label at positions but the text does appear in the file.


Solution

  • As I understand you want to add some bottom margin to a multiplot in order to have space for a label (in your case figure caption). To my opinion, the figure caption should be the task of the text editor (LaTeX, Word, Writer, etc.).

    Anyway, check help multiplot. You have the options margins and spacing.

    • If you need full flexibility then you have to place and size each subplot via set origin and set size (check help origin and help size)
    • set the figure label 1 only before the last plot and in screen coordinates, since label 1 would be placed again in each plot unless you unset label 1 or all via unset label.
    • By the way you don't have to unset all setting and set them again, just overwrite them. But maybe there is a reason why you do so.

    Check the following minimized example below which requires some tuning for your specific case.

    Script:

    ### create some bottom margin for text in multiplot environment
    reset session
    
    set multiplot layout 2,2 margins 0.1,0.90,0.2,0.95 spacing 0.2
    
        set view map
        set size square
    
        set title "(a)"
        set xlabel "h"
        set ylabel "γ" rotate by 0
        splot x*y w pm3d
        
        set title "(b)"
        set xlabel "ʎ"
        set ylabel "ω"
        splot x*y**2 w pm3d
        
        set title "(c)"
        set ylabel "h"
        splot x**2*y w pm3d
        
        set label 1 at screen 0.05, screen 0.04 "{/:Bold Fig.1} This is some figure text..."
        set title "(d)"
        set ylabel "γ"
        splot x**2*y**2 w pm3d
    
    unset multiplot
    ### end of script
    

    Result:

    enter image description here