#393 "save" to record the actual last filename

None
closed-accepted
nobody
None
5
2014-10-12
2014-05-19
Karl Ratzsch
No

If the last plot was done using "" as shorthand for the previous file name, the saved plot only contains the "", there´s no hint as to what file was actually printed.

There could be a GPVAL_ variable that contains the actual name, and gets saved.

The handling of that variable upon loading and it´s use for further plots might raise a backwards compatibility issue, however.

Discussion

  • Ethan Merritt
    Ethan Merritt
    2014-05-19

    From "help plot special-filename"

    The empty filename '' tells gnuplot to re-use the previous input file in the
    same plot command. So to plot two columns from the same input file:

       plot 'filename' using 1:2, '' using 1:3
    

    Thus the scope of the empty quotes is only a single plot command, and the filename
    is right there at the front of that command.

    It may be that the string holding the name is not explictly cleared out everywhere
    it should be (bug?), so that it is sometimes still set for a later plot command.
    But that was not the intent and is contrary to the documentation. Certainly
    you should not depend on it.

     
  • Karl Ratzsch
    Karl Ratzsch
    2014-05-20

    Oh. Right. ;-)

    But reusing the filename with "" over subsequent plot commands has always worked, ever since i first used gnuplot > 10 years ago. Couldn´t we just promote this from "bug" to "feature"? It´s damn useful, saves quite some typing.

     
  • Ethan Merritt
    Ethan Merritt
    2014-10-08

    I've added a line so that the end of a saved file now looks like this:

      ## Last datafile plotted: "silver.dat"
      plot ''
      #    EOF
    

    Do you think that is sufficient?

    Adding a GPVAL_* variable would not help here, since these are not included in the "save" output. At the moment I can't think of anything one could write to the saved file that would automatically restore the internal state of the df_filename string when read back in via "load". There would need to be some new command, perhaps "set datafile 'filename'" that would fill in this string.

     
    • Karl Ratzsch
      Karl Ratzsch
      2014-10-09

      Sure. I was just concerned about the reproducibility of a saved plot. As long as the information is there, a little repair work on the script will hurt nobody.

       
  • Ethan Merritt
    Ethan Merritt
    2014-10-12

    • status: open --> closed-accepted
    • Group: -->