#1251 Unset object when saving



'save set' should store 'unset object' before saving the current objects. To illustrate this:

set object 1 rectangle from screen 0.4,0.4 to 0.6,0.6
save set 'blubb.gp'
set object 2 rectangle from screen 0.5,0.5 to 0.7,0.7
load set 'blubb.gp'
plot x # shows both objects


1 Attachments


  • Ethan Merritt

    Ethan Merritt - 2013-06-22

    I take your point about issuing an "unset obj N" while saving each object so that when it is later reloaded any conflicting settings are cleared first. But I think that in practice this is not needed, because the "save" operation explicitly saves all properties of the object in question. So reloading will restore the object properly regardless of whether some non-default property is set at that later time. That's the intent anyhow. If you have an example where it doesn't work, I agree it's a bug and your proposed "unset" would be one way to fix it.

    But I don't follow the rest of your example. Restoring object 1 should have no effect on other objects, nor should it. Consider the case where you build up a library of objects for possible inclusion in a new plot. You could easily want to say
    load 'saved_obj_1'
    load 'saved_obj_3'
    load 'save_obj_15'
    plot FOO

    That wouldn't work if loading object 15 had the side effect of deleting objects 1 and 3.

  • Christoph Bersch

    My understanding of 'save set' was, that it takes a snapshot of the current set options with the possibility to restore exactly these settings at a later point. This is also how it works for labels and arrows.

    But this does not work in my example, since after loading the file the second object is also present but that is not include in the 'saved snapshot'. In the following example, the second plot contains only label 1 and arrow 1, but object 1 and 2, which I regard as wrong:

    set object 1 rectangle from screen 0.2,0.2 to screen 0.4,0.4
    set arrow 1 head from screen 0.25,0.25 to screen 0.35,0.35
    set label 1 right at screen 0.38,0.25 'label 1'
    save set 'foobar.gp'
    set object 2 rectangle from screen 0.5,0.5 to screen 0.7,0.7
    set arrow 2 head from screen 0.55,0.55 to screen 0.65,0.65
    set label 2 right at screen 0.68,0.55 'label 2'
    plot -x
    pause -1
    load 'foobar.gp'
    plot -x
  • Ethan Merritt

    Ethan Merritt - 2013-06-23

    That's not the way I understand save/load. "Save" saves a set of commands that are sufficient to restore the current state starting from a blank slate. I.e., the commands are incremental. If you start a new copy of gnuplot, which gives you a blank slate, then loading the commands will get you back where you were.

    If you want to restore a previous state while continuing an existing gnuplot session, at minimum you need to issue a "reset" command first, and as you note you may also need to clear existing objects, arrows, and so on. This is a feature, not a bug, as it allows you to build up a more complicated page layout from modulare "load" commands.

  • Ethan Merritt

    Ethan Merritt - 2013-08-28
    • status: open --> closed-accepted

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks