Menu

Align vertically two plots

Help
James
2017-07-18
2017-07-18
  • James

    James - 2017-07-18

    Hello,
    I would like to align vertically two plots, but the yaxis labels prevent me from doing that. Here is a minimal working example:

    set multiplot
    
    #first plot
    
    set size 1,.5
    set origin  0,0
    
    set format y ""     
    unset ytics
    set ytics add ("1" 1, "-1" -1) offset 0,0
    
    p cos(x)
    
    #second plot
    
    res
    
    set size 1,0.3
    set origin 0,.5
    
    set format y ""     
    unset ytics 
    set ytics add ("1000" 1000, "-1000" -1000) offset 0,0
    
    p 1000*sin(x)
    
    unset multiplot
    

    Which generates this plot

    Because the ylabel in the top panel has 4 digits and the one in the bottom panel has 2 digits, the two plots are not aligned vertically. Do you know how to force gnuplot to align them vertically, without manually tuning the plot position?

    Thank you for your help.
    Best,

     
  • Bastian Märkisch

    You can fix the distance from the left plot border to the canvas border by using

    set lmargin 8
    

    for both plots (or omitting the reset in between.
    See also the "aligned plots" demo at http://gnuplot.sourceforge.net/demo_5.0/margins.html

     

    Last edit: Bastian Märkisch 2017-07-19
  • James

    James - 2017-07-21

    This works perfectly, thank you!

    Best,
    James

     

    Last edit: James 2017-07-21

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.