0
votes

According to the docs, a multiplot with a layout can have a plot with its own custom origin which overrides its layout location: http://gnuplot.sourceforge.net/docs_4.2/node203.html

I am trying to do this with the following example code; however, I cannot get the third plot to align in the middle of the second row.

set multiplot layout 2,2 rowsfirst margins 0.1,0.93,0.2,0.93 spacing 0.1,0.1
plot sin(x)
plot cos(x)
plot tan(x)

How do I make tan(x) appear in the middle of the second row, instead of in the first cell of the second row?

Here is what I get:

Here is what I want: enter image description here

I do understand that I can simply turn off the layout and manually set the size / origin of each plot to get what I want; however, I am looking for a solution that allows me to work the layout specification, as I am working with a margin as well that I'd rather not define with different code unless it is absolutely necessary to get the effect I am looking for.

1
I do not yet fully understand. what's wrong with ... set origin 0.25,0 plot tan(x)? How should the layout look like? Positions, margins, sizes, number of plots, ...?theozh
Ah I see that works with the MWE I provided. I have updated the MWE with my full code for the multiplot command, which returns the problem I am observing.Justapigeon
hmm, apparently margins 0.1,0.93,0.2,0.93 is overriding the set origin 0.25,0. Then I don't know... probably back to manually setting sizes and origins?theozh
if you haven't checked this already, maybe this could help gnuplotting.org/multiplot-placing-graphs-next-to-each-othertheozh
Thanks for the link; I appreciate it. Is there a way to report bugs to the gnuplot team? Either 1) the docs need to be changed so that it does not say that origin will override the layout or 2) origin needs to override layout.Justapigeon

1 Answers

1
votes

One must admit that it is probably a bit tedious, on the other hand, directly playing with margins gives you certain flexibility. The script below basically just first calculates the width(s) and height(s) in screen coordinates of individual plots and then positions them separately via the set margin command:

BORDER_L = 0.10
BORDER_R = 0.07
BORDER_B = 0.20
BORDER_T = 0.07

SPACING_X = 0.10
SPACING_Y = 0.10

NUM_ROWS = 2
NUM_COLS = 2

PLT_W = (1 - BORDER_L - BORDER_R - (NUM_COLS-1)*SPACING_X)/NUM_COLS
PLT_H = (1 - BORDER_B - BORDER_T - (NUM_ROWS-1)*SPACING_Y)/NUM_ROWS

#set multiplot layout 2,2 rowsfirst margins BORDER_L,1-BORDER_R,BORDER_B,1-BORDER_T spacing SPACING_X,SPACING_Y

set multiplot

set tmargin at screen 1 - BORDER_T
set bmargin at screen 1 - BORDER_T - PLT_H
set lmargin at screen BORDER_L
set rmargin at screen BORDER_L + PLT_W

plot sin(x)

set tmargin at screen 1 - BORDER_T
set bmargin at screen 1 - BORDER_T - PLT_H
set lmargin at screen 1 - BORDER_R - PLT_W
set rmargin at screen 1 - BORDER_R

plot cos(x)

set tmargin at screen 1 - BORDER_T - PLT_H - SPACING_Y
set bmargin at screen BORDER_B 
set lmargin at screen (1 - PLT_W)/2
set rmargin at screen 1 - (1 - PLT_W)/2

plot tan(x)

This then produces: enter image description here