Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#340 Align origin of axes y1 and y2 (or x1 and x2)

closed-fixed
nobody
None
5
2012-09-14
2012-07-25
Anonymous
No

When plotting data on 2 different axes, the pointis often to compare relative variations of data in different units. Thus it is often more correct to plot them with the same position of the zero, so that relative variations are to scale.

In gnuplot, this is easily done for positive data, setting ymin=y2min=0, but I can find no way to do it with autoscale for data that can change sign.

Discussion


  • Anonymous
    2012-07-25

    I can do it manually of course :
    [code]
    plot "data2.dat" axes x1y2
    SAVE_Y2_MIN=GPVAL_Y2_MIN
    SAVE_Y2_MAX=GPVAL_Y2_MAX
    plot "data1.dat" axes x1y2
    max(a,b)=(a>b)?a:b
    a=max(SAVE_Y2_MIN/GPVAL_Y_MIN,SAVE_Y2_MAX/GPVAL_Y_MAX)
    set y2range [GPVAL_Y_MIN*a:GPVAL_Y_MAX*a]
    replot "data2.dat" axes x1y2
    [/code]

     
    Last edit: Anonymous 2013-11-20
  • Ethan Merritt
    Ethan Merritt
    2012-08-08

    • status: open --> pending-fixed
     
  • Ethan Merritt
    Ethan Merritt
    2012-08-08

    Version 4.7 now supports a command "set link {x2|y2}" that I think will do what you want. For example, if you wanted y axis data in Farenheit and y2 axis data in Centigrade, but aligned so that 32F is parallel to 0C

    c2f(y) = 32. + 9.*y/5.
    f2c(y) = (y-32.) * 5./9.
    set link y2 via f2c(y) inverse c2f(y)

     
  • Ethan Merritt
    Ethan Merritt
    2012-09-14

    • status: pending-fixed --> closed-fixed