#1378 Strange results when plotting with '+' twice.

Christoph Bersch


using the pseudo filename '+' twice gives strange results when the xrange is not set:

plot '+' using 0:1 w lp, '+' using 0:1 w lp

This error appears both in CVS and at least in 4.6.4.


1 Attachments


  • Ethan Merritt
    Ethan Merritt

    I do not understand the intent of the plot command. Column 0 will run from 0 to \<current value of 'set sample'>, which defaults to 100 and gives the x axis range shown in your plot. But what is column 1? You haven't set an x range, so what exactly is supposed to be sampled, and what are you expecting to see as a y value in the plot?

    Last edit: Ethan Merritt 2014-04-13
    • I was expecting the + to sample the default xrange [-10:10], as it also does in the first plot command.

      I had in mind, that a previous gnuplot version gave an error in this situation: using + without explicit xrange. But that is what happens with splot '++': -> "x range is invalid".

      I think, if using plot '+' without explicitely setting an xrange is not supported, it should also give an error like for splot '++'.


  • Ethan Merritt
    Ethan Merritt

    I have not had occasion to use this mode myself, but I imagine the idea is something like this:

    Consider the existing demo mgr . There is a file of observed values and a theoretical function that may or may not fit very well. The demo plots theory as a smooth line and data as points with experimental error bars. Suppose, however, that you had a denser data set and a theoretical but expersive to calculate error model. These commands would plot it:

      set samples 11
      set offset .1,.1
      plot 'battery.dat' using 1:2 smooth csplines with lines,\
           '+' using 1:(pred($1)):(error($1)) with yerrorbars

    This is a very contrived plot, but the point is that '+' takes its sampling range from the autoscaled range of the previous plot element. That is exactly what your "strange result" does.

    Last edit: Ethan Merritt 2014-04-15
    • Thanks for the nice example.

      At the moment I'm quite active at stackoverflow and there using '+' is very comfortable to demonstrate solutions related to data files.

      I need to think a bit more about this:

      Currently it seems to be as follows (also for the first plot):

      • x-axis is autoscaled
      • this autoscaled range determines the sampling of $1
      • no further autoscaling is done, if a different value than $1 is used as first column.

      I think the last point was also not clear to me. Don't know if there is something meaningful which one could do here, I'll see.