Menu

#1922 gnuplot 5.0.6 axis x2y2 bug

None
closed-not-a-bug
nobody
None
2017-03-27
2017-03-26
Anonymous
No

Gnuplot seems to scale a plot to nice even numbers. So a plot that goes from x=0 to x=1030 as the right edge at x=1200 or so.

Which is great, so when I plot a simple graph from x=0 to x=1030 there's a bit of space on the right edge.

The same plot using "axis x2y2" assumes the right edge = 1030. Thus the plot is scaled by a factor of 1.15x or so.

My terminal type is qt.

Discussion

  • Bill Broadley

    Bill Broadley - 2017-03-26

    To be clear the commands I used (after launching gnupot):
    gnuplot> plot 'fs1.log' using 1:3 with lines
    gnuplot> plot 'fs1.log' using 1:3 axis x2y2 with lines

    The first is exactly correct, the second assumes that the right edge of the screen is x=1030 instead of x=1200.

     
    • Hans-Bernhard Broeker

      the second assumes that the right edge of the screen is x=1030 instead of x=1200.

      Not really. What actually happens is that you failed to display what gnuplot assumes the right edge of the graph to be. That made you confuse the mirror of the unused left-side axis, y1, with the actually used axis, y2. To see what's actually happened, do

      set y2tics ; set ytics nomirror
      

      before your second 'plot' command.

       

      Last edit: Hans-Bernhard Broeker 2017-03-26
  • Bill Broadley

    Bill Broadley - 2017-03-26

    I dug further and got some help on the #gnuplot irc channel.

    I have a completely default gnuplot configuration. No customization by me. Just download gnuplot source, ./configure; make; make install.

    So I launch gnuplot and:
    gnuplot> show xrange
    set xrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
    gnuplot> show x2range
    set x2range [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )

    Exactly what I expect. Now:
    gnuplot> plot 'fs1.log' using 1:3
    gnuplot> show xrange
    set xrange [ * : * ] noreverse nowriteback # (currently [0.00000:2500.00] )

    Now the EXACT same data plotted with axis x2y2:
    gnuplot> plot 'fs1.log' using 1:3 axis x2y2
    gnuplot> show x2range
    set x2range [ * : * ] noreverse nowriteback # (currently [1.00000:2386.00] )

    So presented with exactly the same data (columns 1 and 3 from fs1.log) I get fairly different graphs and ranges. Seems like a bug. I can force the xaxis, but it's somewhat annoying I can't autorange.

     
  • Karl Ratzsch

    Karl Ratzsch - 2017-03-27

    I don't have your data, but everything looks fine here (also 5.0pl6):

    $dat << EOD
    1 10 56
    500 20 80 
    2386 15 95
    EOD
    
    plot $dat us 1:3 w lp
    set xtics nomirr; set x2tics
    set ytics nomirr; set y2tics
    set grid
    rep $dat us 1:3 axes x2y2 w lp
    sho xr
    sho x2r
    

    Grid lines match up on all axes, ranges are [0:2500] on both x and x2.

    There something odd in "fs1.log"? Perhaps you can strip the file down to a few lines that reproduce the problem.

     
  • Bill Broadley

    Bill Broadley - 2017-03-27

    bill@left:~/tmp/migrate$ cat fs3.log
    1 25348763
    2 25348771
    3 25358380
    4 25375125
    5 25382468
    6 25385411
    7 25390387
    8 25399115
    9 25400565
    10 25402865
    11 25407756
    gnuplot> plot 'fs3.log' using 1:2 with lines
    gnuplot> show xrange
    set xrange [ * : * ] noreverse nowriteback # (currently [0.00000:12.0000] )
    gnuplot> plot 'fs3.log' using 1:2 with lines axis x2y2
    gnuplot> show x2range
    set x2range [ * : * ] noreverse nowriteback # (currently [1.00000:11.0000] )
    gnuplot>

    That's 5.0.4 that comes with ubuntu, but same thing happens with a 5.0.6 I compiled myself.

     
  • Karl Ratzsch

    Karl Ratzsch - 2017-03-27

    Hm. The range changes if you set the x2tics/y2tics after plotting. They are then the same as x1/y1.

    $dat << EOD
    1 25148763
    2 25348771
    3 25358380
    4 25375125
    5 25382468
    6 25385411
    7 25390387
    8 25399115
    9 25400565
    10 25402865
    11 25407756
    EOD
    plot $dat w lp
    replot $dat axes x2y2 w lp
    set x2tics; replot  # makes x2 snap to [0:12]
    set y2tics; replot  # makes y2 snap to the same as y1
    

    However the same happens to x1 / y1 if you unset them before plotting. The autoranging does not extend the range to the next "even" value for axes that have not tics. I guess this is indended behaviour. Makes some sense to me, at least.

     
  • Ethan Merritt

    Ethan Merritt - 2017-03-27

    The range is extended to the next major tic. If there are no tics then there is no extension.

     
  • Bill Broadley

    Bill Broadley - 2017-03-27

    Ah, so I get it, by default xtics and ytics is on, and x2tics and y2tics is off, thus the different in behavior. Makes sense I guess.

    Seems a bit less surprising to have them both set if plotted against, but I can see it either way.

    Thanks for the help, I guess the ticket should be closed.

     
  • Karl Ratzsch

    Karl Ratzsch - 2017-03-27
    • status: open --> closed-not-a-bug
    • Group: -->
    • Priority: -->
     

Log in to post a comment.