#611 Multiplot auto layout with explicit margins and spacing

Version 5
closed-accepted
nobody
None
5
2014-04-25
2013-02-15
No

Hi,

I propose to extend the multiplot auto layout by the possibility to set explicit margins and spacing between all plots (equivalent to using set {lrtb}margin) for each plot.

This can be very useful if you want to stack several plots, but want to have ylabels only for the leftmost plots, and xlabel only for the lower plots, but with equal graph sizes. Example with the patch:

set multiplot layout 2,2 columnsfirst margins 0.1,0.95,0.15,0.95 spacing 0.1
set ylabel 'ylabel'
plot sin(x)
set xlabel 'xlabel'
plot cos(x)
unset ylabel
unset xlabel
plot sin(2x)
set xlabel 'xlabel'
plot cos(2
x)
unset multiplot

I attached a patch which introduces a new option 'margins' which allows to set all four margins (left, right, bottom, top) around the whole multiplot grid, and an option 'spacing', which gives the horizontal and vertical spacing between two plots.

All values must be given as fractions of the whole drawing area.

1 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2013-02-18

    Comments:

    1) If the intent is that these settings are persistent, as they are in the current patch, then there should be corresponding show/save/unset/reset commands for the current state. The other option is to make them not persistent, and reset everything to the default at the start of parsing the "set multiplot" command.

    2) It's not clear to me how the top margin is intended to interact with the "title" setting. In the 4.6/4.7 code "set multiplot title 'foo'" will reserve extra space at the top for the title. Does the new tmargin setting allow for that as well?

     
  • Christoph Bersch

    Dear Ethan,

    thanks for your comments:

    1) The settings should not be persistent, just like the scale and offset options. But I thought, that my patch does not make persistent changes, because all changes of {lrbt}margin variable are reset to their previous values at 'unset multiplot'. The previous margins are stored in the mp_layout.prev_{lrbt}margin variables and are restored when 'unset multiplot' is called:

    set tmargin at screen 0.7
    set multiplot layout 1,2 margins 0.1,0.9,0.1,0.9 spacing 0.1
    plot sin(x)
    plot sin(x)
    unset multiplot
    plot sin(x)

    For the last plot, the tmargin of 0.7 is used.

    2) The top margin should not interact with the "title" setting, just like the behavior of the 'set {lrbt}margin' settings is not affected by any other settings.

     
  • Ethan Merritt

    Ethan Merritt - 2013-02-18

    1) Although you save and restore the non-multiplot margins, you never initialize the entries mp_layout.lmargin, etc. So they remain at whatever they were last set to. If you just say
    set multiplot layout 2,2
    you get whatever margins and spacing were set by some previous multiplot command.

    2) So are you suggesting the the current behavior of set multiplot should be changed to not reserve space for the title?

     
  • Christoph Bersch

    1) I updated the patch to reset the multiplot margins and the spacing at the end.

    2) No, the current behavior is fine. I only suggest that the new options don't have to reserve space for the title, because they must set fixed margins.

     
  • Ethan Merritt

    Ethan Merritt - 2014-03-29

    Now in CVS for version 5

     
  • Ethan Merritt

    Ethan Merritt - 2014-03-29
    • status: open --> pending-accepted
    • Group: -->
     
  • Ethan Merritt

    Ethan Merritt - 2014-04-25
    • status: pending-accepted --> closed-accepted
    • Group: --> Version 5
     

Log in to post a comment.