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

#336 Refresh plot or zoom without re-reading data

closed-out-of-date
Ethan Merritt
None
2
2009-06-01
2007-05-22
Ethan Merritt
No

This patch adds a new command 'refresh' that acts similarly to 'replot' except that it does not re-read or recalculate the input data. This allows you to zoom, add labels, or otherwise modify the current plot even if the input data is transient. In particular it allows you to zoom or otherwise modify a plot whose data came from stdin, e.g. plot '-'.

Data processing is modified in these ways:

1) Plot data is not discarded immediately after a successful plot command. Instead it is kept around until it is replaced by a subsequent plot or replot command. This is a change for 2D plots. 3D plots already worked this way.

2) The new command 'refresh' is implicitly used by mouse zooming operations. Because the axis ranges may have changed since the data was read in, we must walk through the data and re-evaluate the INBOUNDS/OUTBOUNDS flag for each point before regenerating the plot.

3) I had to re-work the way zoom operations are saved/restored. It is actually a simplification of the existing code, but the behaviour of "unzoom" is now subtly changed if it is triggered from a different plot than the original zoom operation. The old behaviour was undocumented, so I am not too worried about this at the moment.

Known issues in the first version (22 May 2007):

- Quick refresh is not yet implemented for 3D plots (splot + set view map).

- Only the primary x and y coordinates of each point are rechecked against the current axis limits. Possibly this is not sufficient for some plot styles (errorbars? candlestick?) Easy to fix if needed.

- There should be some way to turn off the quick refresh if you really do want to re-read the data during a zoom operation. Maybe a new command
set zoom {replot|refresh}
or
set mouse zoom {replot|refresh}

Discussion

1 2 3 .. 5 > >> (Page 1 of 5)
  • Petr Mikulik
    Petr Mikulik
    2007-05-22

    Logged In: YES
    user_id=31505
    Originator: NO

    For me it does not work when zooming with '-'.
    It shows its typical
    input data ('e' ends) >

    Can you please fix it?

     
  • Ethan Merritt
    Ethan Merritt
    2007-05-22

    Logged In: YES
    user_id=235620
    Originator: YES

    >Can you please fix it?

    I don't know. For me it works fine with both x11 and wxt. The changes do not touch any driver-specific code that I know of, but I have not tested other interactive terminals to confirm this. You might try putting a debug statement in replotrequest() to see if the refresh information is making it through to that point. It should report refresh_ok = 2 when you try to zoom a 2D plot.

    diff -ur gnuplot/src/command.c gnuplot-cvs/src/command.c
    --- gnuplot/src/command.c 2007-05-14 01:05:12.000000000 -0700
    +++ gnuplot-cvs/src/command.c 2007-05-22 15:41:42.000000000 -0700
    @@ -1777,6 +1813,8 @@
    void
    replotrequest()
    {
    + fprintf(stderr,"refresh_ok = %d\n",refresh_ok);
    +
    if (equals(c_token, "["))
    int_error(c_token, "cannot set range with replot");

     
  • Petr Mikulik
    Petr Mikulik
    2007-05-23

    Logged In: YES
    user_id=31505
    Originator: NO

    Fine, it works with zooming (by mouse or via zoom history hotkeys).

    The problem I had with plot '-' was with 'g', 'l' etc. hotkeys. In the current gnuplot, the variable replot_disabled is set for inline data, and this is checked in do_string_replot. Your code #if 0 replot_disabled= ... #endif. in mouse.c. This should be changed by calling the refresh instead of replot for the inline data.

    I think the
    set mouse {replot|refresh}
    command should apply to both the zoom and the default bind commands.

    For scripting purposes, it seems that GPVAL_CAN_REPLOT automatic variable would be useful. It will be filled by !replot_disabled.

    BTW, the trick with memcpy(axes) is great!

     
  • Ethan Merritt
    Ethan Merritt
    2007-05-23

    Logged In: YES
    user_id=235620
    Originator: YES

    > The problem I had with plot '-' was with 'g', 'l' etc. hotkeys.

    'l' is a problem. I forgot to point out that the quick refresh path cannot work if you change something about the processing of the input data. This includes toggling the log scaling, because this is applied at the time the data is read in rather than when it is plotted. That is a bit unfortunate, but I see no way around it without totally re-working the way log scaling is done.

    Yes, the 'g' hotkey should be fixed. I am uncertain about the 'a' hotkey; should it continue to issue a 'replot' command, or should it try to use 'refresh' if possible?

    You may be right that the replot_disabled flag is still needed in some other cases. Do you have an example command sequence that shows this?

     
  • Petr Mikulik
    Petr Mikulik
    2007-05-25

    Logged In: YES
    user_id=31505
    Originator: NO

    > Yes, the 'g' hotkey should be fixed. I am uncertain about the 'a' hotkey;

    They should work according to
    set mouse {replot|refresh}

    In-line data should always be refreshed only.

    > 'l' is a problem.

    Then the data should be de-logged. Can they have a flag whether they are logged or not, and (de)logged if this flag for a column is not consistent with its "set log"?

    > You may be right that the replot_disabled flag is still needed in some
    > other cases. Do you have an example command sequence that shows this?

    It was the "g" hotkey or "e", for example.

     
  • Ethan Merritt
    Ethan Merritt
    2007-06-07

    Logged In: YES
    user_id=235620
    Originator: YES

    Second version.

    Log scale plots now work correctly. However it remains an intrinsic limitation that if you toggle log scale on or off, than invalidates the stored data so that a full reread+replot is necessary.

    Known issues in the second version (6 June 2007):

    - Not yet implemented for 3D plots (splot + set view map)

    - During zoom, the plot boundaries do not adhere strictly to the
    new plot limits. But the actual data points do. So there is a
    gap between the graph lines and the plot border.

    - To disable the quick refresh mode, type
    REFRESH_DEBUG = 0
    File Added: persistent_plot_data_06jun2007.patch

     
  • Petr Mikulik
    Petr Mikulik
    2007-06-08

    Logged In: YES
    user_id=31505
    Originator: NO

    > Log scale plots now work correctly.

    I would prefer to ignore "set log", instead of "freezing" the plot.
    A message could be printed on the status line, for example.

     
  • Ethan Merritt
    Ethan Merritt
    2007-06-08

    Logged In: YES
    user_id=235620
    Originator: YES

    How would you know to ignore the "set log" command?
    The refresh command might not come until much later. The freeze is only triggered by the combination of "set/unset log" + "input from stdin" + "mouse action triggers replot", and is exactly what happens in the current (no quick refresh) version of gnuplot for *all* mouse-triggered replots.

     
1 2 3 .. 5 > >> (Page 1 of 5)