Search code examples
gnuplot

How to manage tick lable and axis-lable in gnu multiplot


enter image description hereI have two files each is having five columns where 1st will be the x-axis in both the data. I want to make a multiplot 2 2 in GNU with zero spacing. I could manage many things but I am could not fix below problems: 1. How to place the figure at the center of the page i.e. equal left right margin? I set the left, right, top and bottom margin but it is not working. 2. How to number the figure. For example, Figure 1 1 should be numbered as (a), figure 1 2 should be numbered as (b) and so on. 3. How to put tick lable and tick mark on the plot 1 2 and 2 2 on right side of the plot? 4. how to create a common title at the bottom of the figure representing the X-axis.

I have tried to make gnu multiplot layout but still it is not giving desired results. The script I used is mentioned below:

My code is

[![set terminal postscript eps enhanced size 20cm,15cm  color solid lw 3 "Times-Roman" 24
reset
set lmargin screen 0.10
set rmargin screen 0.95
set bmargin screen 0.15
set tmargin screen 0.9

set mxtics 2
set mytics 2
set tics font "Times-bold, 50"
set output "absorption.pdf"

set multiplot layout 2,2 margin 0.2, 0.9, 0.1, 0.9 spacing 0.00, 0.00
set tics scale 1.2
set tics font "Times-bold, 26" 


set key spacing 1.2
unset key
set xrange \[0:8.5\] 
set yrange \[0:1\]
set xlabel ' '
set format x ""
set ylabel  'A11' font 'Times-bold, 26' offset 1,1,3
unset label
plot "data1.dat" u 1:($2/10**4) w l lw 3 lt 2 lc rgb "red" title "x-D", 'data1.dat' u 1:($3/10**4)  w l lw 3 lc rgb "blue" title "z-D"

unset label
unset format x
unset key
set key inside center top                    # to adjust the legends position
set xrange \[0:8.5\]
set yrange \[0:1\]
set title ' '
set xlabel ' '
set xlabel ' '
set format x ""
set ylabel ' '
set format y " "
set key spacing 1.2
set ylabel 'A12' font 'Times-bold, 26' offset 1,0,3
plot "data1.dat" u 1:($4/10**2) w l lw 3 lt 2 lc rgb "red" title "x-D", 'data1.dat' u 1:($5/10**2) w l lw 3 lt 2 lc rgb "blue" title "Z-D"


unset label
unset format y
unset format x

unset key

set xrange \[0:8.5\]
set yrange \[0:1.08\]
set xlabel ' '
unset label
set ylabel 'A21'   font 'Times-bold, 28'
unset label
plot "data2.dat" u 1:($2/10) w l  lw 3 lt 2 lc rgb "red" title "x-dir", 'data2.dat' u 1:($4/10) w l  lw 3 lt 2 lc rgb "blue" title "z-dir" ,\

unset label
unset format x
unset key

set xrange \[0:8.5\]
set yrange \[0:1.08\]
set title ' '
set format y ""
set xlabel 'X-12-scale' font 'Times-bold, 28'
set ylabel 'A22' font 'Times-bold, 28'
plot "data2.dat" u 1:($3/10) w l lw 3 lt 2 lc rgb "red" title "x-dir", 'data2.dat' u 1:($5/10) w l lw 3 lt 2 lc rgb "blue" title "z-dir"

unset label
unset format y
unset key

unset multiplot
set output][1]][1]

My data should be like what I want according to attached figure queries and hand marks.


Solution

  • Try this

    reset
    set encoding utf8
    set terminal pngcairo size 750,500 font ",10"
    set output "Multiplot_2x2.png"
    set multiplot \
        layout 2,2 rowsfirst \
        title "{/:Bold=11 Multiplot 2×2}" \
        margins screen 0.10,0.92,0.12,0.90 \
        spacing screen 0.00,0.00
    
    set link y2
    # Gaussian fuction
    f(x,a,b,c) = a*exp(-((x-b)/c)**2)
    # Parameters to first one
    a1 = 0.95
    b1 = 4.00
    c1 = 1.00
    # Parameters to second one
    a2 = 0.95
    b2 = 5.00
    c2 = 1.00
    # Line style
    set style line 1 lc "#e41a1c"   # red
    set style line 2 lc "#377eb8"   # blue
    # -----------------------------------------------
    set xrange [0:10]
    set yrange [0:1.0]
    set xtics format ""
    set ytics
    set ylabel "y-label"
    set label 1 "{/:Bold (a)}" at graph 0.05, 0.9
    plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
    # -----------------------------------------------
    unset ylabel
    set ytics format ""
    set y2tics format ""
    set y2label "y2-label"
    set label 1 "{/:Bold (b)}"
    plot f(x,a1,b1,c1) w l ls 1 title "Your title 1", f(x,a2,b2,c2) w l ls 2 title "Your title 2"
    # -----------------------------------------------
    unset y2tics
    unset y2label
    set xtics 0,2,9 format "%g"
    set ytics 0,0.2,0.9 format "%g"
    set ylabel "y-label"
    set label 1 "{/:Bold (c)}"
    plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
    # -----------------------------------------------
    unset ylabel
    set xtics 0,2,10
    set xlabel "common x-label" offset screen -0.20,0.0
    set ytics format ""
    set y2tics
    set y2label "y2-label"
    set label 1 "{/:Bold (d)}"
    plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
    # -----------------------------------------------
    

    Result

    result