|
From: Dima K. <gn...@di...> - 2020-09-13 20:18:11
|
Hi. I do observe your sequence work at you state:
> 1) start gnuplot
> 2) load script
> 3) zoom
> 4) 'u'
> plot is now incorrectly scaled
> 5) 'n'
> shows zoom state from (3)
> 6) 'p'
> correctly unzooms to original plot
Step 6 may be 'u' or 'p'. The reason things don't look the same after
steps 4 and 6 is the value of
{ axis_array[FIRST_Y_AXIS].min, axis_array[FIRST_Y_AXIS].max }
at the start of the refresh_bounds() call. This function assumes
min<max. And if we're reversing some axis, this is done at the very end
of refresh_bounds() with the axis_check_range() calls.
In step 3, refresh_bounds() sees {min,max} = {4000,-500}
In step 6, refresh_bounds() sees {min,max} = {1850,1400}
This is dependent on the actual zoom bounds. Both of these have the
unexpected min>max, obviously, but in step 6 we get lucky, and it ends
up doing the right thing anyway, in this case.
Specifically the diverging behavior comes from
refresh_bounds() calls
process_image() calls
STORE_AND_UPDATE_RANGE() calls
store_and_update_range()
The logic in store_and_update_range() is effectively:
if ( curval > axis->max && curval >= axis->min )
axis->max = curval;
Which is correct only if axis->min < axis->max
I'm not entirely sure what the values of axis->min, axis->max should be
at the start of refresh_bounds(), but reordering them makes this thing
work correctly. Patch (usable for this specific test case only):
diff --git a/src/plot2d.c b/src/plot2d.c
index b2877eb89..7e4e57259 100644
--- a/src/plot2d.c
+++ b/src/plot2d.c
@@ -299,6 +299,17 @@ refresh_bounds(struct curve_points *first_plot, int nplots)
struct curve_points *this_plot = first_plot;
int iplot; /* plot index */
+
+ if(axis_array[FIRST_Y_AXIS].min > axis_array[FIRST_Y_AXIS].max)
+ {
+ double t = axis_array[FIRST_Y_AXIS].min;
+ axis_array[FIRST_Y_AXIS].min = axis_array[FIRST_Y_AXIS].max;
+ axis_array[FIRST_Y_AXIS].max = t;
+ }
+
+
+
+
for (iplot = 0; iplot < nplots; iplot++, this_plot = this_plot->next) {
int i; /* point index */
struct axis *x_axis = &axis_array[this_plot->x_axis];
Applying this patch makes the test case work, even before any of your
patches from yesterday. Clearly, this should be more general, but I'm
hazy on the details, so it'd be better if you finish this, probably.
Thanks!
|