Conversion between gnuplot's coordinates systems

后端 未结 2 762
忘掉有多难
忘掉有多难 2021-01-25 03:49

TL;DR

Is there a way to align corners of different plots in a multiplot setup?

Is there a way to convert axis coordinates to screen c

相关标签:
2条回答
  • 2021-01-25 04:26

    In order to achieve an exact overlap, I think that an option would be to adjust the margin manually:

    set terminal pngcairo
    set output 'fig.png'
    
    eps_h = 0.1
    eps_w = 0.1
    
    set multiplot
    unset key
    
    set lmargin at screen 2*eps_w
    set tmargin at screen 1 - eps_h
    set rmargin at screen 1 - eps_w
    set bmargin at screen eps_h
    
    plot cos(x) w lp lc rgb 'dark-red'
    
    set border ls 4;
    unset xlabel
    unset ylabel
    unset tics
    
    plot 2*cos(x+pi) w lp lc rgb 'royalblue'
    

    which gives:

    0 讨论(0)
  • 2021-01-25 04:33

    You can fix the margins to keep the automatic size after the first plot as follows (see also https://stackoverflow.com/a/19132068/2604213):

    fix_margins = 'set margins '.\
        'screen GPVAL_TERM_SCALE * GPVAL_TERM_XMIN/(1.0*GPVAL_TERM_XSIZE), '.\
        'screen GPVAL_TERM_SCALE * GPVAL_TERM_XMAX/(1.0*GPVAL_TERM_XSIZE), '.\
        'screen GPVAL_TERM_SCALE * GPVAL_TERM_YMIN/(1.0*GPVAL_TERM_YSIZE), '.\
        'screen GPVAL_TERM_SCALE * GPVAL_TERM_YMAX/(1.0*GPVAL_TERM_YSIZE)'
    
    set samples 20
    set xrange [-pi:pi]; set yrange [-2:1]
    set xlabel "x"; set ylabel "y"
    unset key
    
    set multiplot
    plot cos(x) w lp
    eval(fix_margins)
    unset tics; unset xlabel; unset ylabel
    plot 2*cos(x+pi) w lp
    unset multiplot
    
    0 讨论(0)
提交回复
热议问题