1
votes

I am having some troubles getting the desired results when using Multiplot with a specified size and margins. I have attached a picture shows the issue when plotting my data. I am interested in merging plots with the same scale. For that I specified xsize= 0.40, ysize= 0.90, and xinit= 0.10 as in the code below. When the data files were plotted, the y-axis of the right plot was a bit lower than that of the left plot. If I was not looping, everything seems to work as expected. I even tried to move xsize= 0.40, ysize= 0.90, and xinit= 0.10 inside the for loop but no luck.

set term png
xsize= 0.40   
ysize= 0.90  
xinit= 0.10   
do for [i=1:files] { 
set output sprintf("Picture(x=-%d).png",i) 
set multiplot layout 1,2

# Reset keys
unset rmargin
unset lmargin
# Set individual keys

set size xsize, ysize                  # Plot size in relation with canvas
set lmargin at screen  xinit           # x inital possition 0.10
set rmargin at screen  xinit + xsize   # x final possition 0.50 
set  xlabel "x[m]" offset 2,0          # Displace xlabel to the center of canvas
set  ylabel "y[m]"

plot filename(i) using 4:3 with lines notitle

# Reset keys
unset rmargin   # Clears the past x position
unset lmargin
unset label     # Clears the past label
unset ytics     # Removes the y axis tics
unset ylabel    # Removes the y axis label

set size xsize, ysize                  # Plot size in relation with canvas
set lmargin at screen  xinit+xsize     # x inital possition 0.50
set rmargin at screen  1 - xinit       # x final possition 0.90 

plot filename(i) using 6:3 with lines notitle 
unset multiplot
}

enter image description here

I wonder what could be the issue in my code. Thanks for the help.

1
I cannot reproduce the different heights in the sub-plots. Have you tried reset session at the beginning? Is this really the plot you're getting with above code? Where are the axes labels and the data? For a minimal example you just can insert plot x or something else. Which gnuplot version and operating system are you using? - theozh
Hi Theozh, thanks for your help. I am using gnuplot 5.0 on a Unix environment. reset session doesn't seem to work thought I found help to rest parameters. - Programming

1 Answers

0
votes

For your use case you should use the spacing and margins options for multiplot:

set multiplot layout 1,2 margins 0.1,0.1,0.05,0.05 spacing 0,0