This question is to some part identical to what has already been asked here. But the referenced question never received the answer to the point whether the issue presented here is a bug or documentation confusion.
Documentation states with respect to the layout
option of multiplot
:
With the layout option you can generate simple multiplots without having to give the set size and set origin commands before each plot: Those are generated automatically, but can be overridden at any time.
My understanding of that text is that layout sets origin and size and at any time, i can change those specifications. Then this should work:
set xrange [0:10]
set multiplot layout 3,1 margins 0.1,0.95,0.12,0.95 spacing 0,0
unset key
plot cos(x) axes x1y1 w l ls 3 notitle
plot sin(x) axes x1y1 w l ls 3 notitle
set key bottom center out horizontal
plot sin(x) axes x1y1 w l ls 3 notitle
set origin 0.3,0.5
set size 0.2,0.1
set xrange [1:2]
plot cos(x) axes x1y1 w l ls 3 notitle
unset multiplot
But it does not. gnuplot
completely ignores set size
and set origin
commands. What it should do is to plot 3 plots under each other and then create an inset at screen position (0.3,0.5)
of size relative to canvas (0.2,0.1)
.
My questions are:
set position
and set size
)?multiplot
offers two ways to position the sub-plots, set origin
+ set size
and set *margin
where *
stands for one of b,t,l,r
. Can someone provide a deeper explanation when one should use which? (For me it feels the proper way that was meant to do it is set origin
and margins just became a dirty trick that works but was not meant for that)origin
, size
, margins and any other relevant settings that are automatically calculated (and used) when the layout
option is specified?My guess would be that it is a bit unclear documentation.
It's a matter of taste and convenience and depends on your situation. Setting origin and size is setting the place for the (sub-)"canvas". This (sub-)"canvas" still can have some individual b,t,l,r margins. Note, margins are the space between graph border and canvas-border.
Apparently, the margins which you are setting in the multiplot layout are kept for your extra plot.
So, apparently you have to reset them, e.g. set margins 0,0,0,0
. And then you are probably getting your intended plot.
I am not aware that you can extract the automatically calculated values for margins. There are no such values
listed in show var GPVAL
.
Code:
### multiplot layout with manual origin and size
reset session
set xrange [0:10]
unset key
set ytics 0.5
set multiplot layout 3,1 margins 0.1,0.95,0.12,0.95 spacing 0,0
plot cos(x) axes x1y1 w l ls 3 notitle
plot sin(x) axes x1y1 w l ls 3 notitle
set key bottom center out horizontal
plot sin(x) axes x1y1 w l ls 3 notitle
set margins 0,0,0,0
set origin 0.3,0.5
set size 0.2,0.1
set xrange [1:2]
plot cos(x) axes x1y1 w l ls 3 notitle
unset multiplot
### end of code
Result: