Re: Strange autoscaling with rgbimage and inverted yranges

Ethan A Merritt <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Organization University of Washington
Message-ID <2052773.FDliEkiBXs@stonelion>
On Friday, 11 September 2020 20:13:33 PDT Dima Kogan wrote:

> In any case, this worked in 5.2. I just did a bisection, and I can now
> see why this seemed familiar. The commit that broke it:
> 
>   https://sourceforge.net/p/gnuplot/gnuplot-main/ci/36a2407e50/
> 
> The person who broke it was me! But despite what git says, I have very
> little recollection of any of this. Ethan: do you have a good sense of
> what's happening here, and can you easily fix it now? If not, I can poke
> at it, and figure it out.
> 
> dima

I am puzzled because I do not understand the difference between
returning to the top level zoom state by pressing 'p' to step backwards
through the stack of zoom operations and pressing 'u' to jump back to the
top of the stack.  Either way it should be applying the same state
(confirmed in the debugger) but for some reason that I don't understand
the former works correcly and the latter doesn't.

I _think_ that the problem involves this macro in axis.h

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/* Simplest form of autoscaling (no check on autoscale constraints).
 * Used by refresh_bounds() and refresh_3dbounds().
 * Used also by autoscale_boxplot.
 */
#define autoscale_one_point(axis, x) do {\
    if (axis->set_autoscale & AUTOSCALE_MIN && x < axis->min) \
        axis->min = x; \
    if (axis->set_autoscale & AUTOSCALE_MAX && x > axis->max) \
        axis->max = x; \
    } while (0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

as called from plot2d.c:refresh_bounds() when zooming volatile data.

Note that the macro does not consider the case of reversed axes.
Adding a test for (axis->min < axis->max) seems to make your
test case work.   See attached patch.

The unpatched code does the wrong thing for reversed axes.
The patched code does nothing at all for reversed axes,
is it probably wrong also but for some case other than yours.
A more complete fix for the macro is wanted.

And even after tracking it that far I still don't understand why
'p' works and 'u' doesn't.     If you can figure that out I'd be 
happier with declaring it fixed.

                 Ethan
-- 
Ethan A Merritt
Biomolecular Structure Center,  K-428 Health Sciences Bldg
MS 357742,   University of Washington, Seattle 98195-7742

_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
refresh_volatile_reversed_axis.patch (text/x-patch, 676 B)
diff --git a/src/axis.h b/src/axis.h
index a89800800..3422bd3d3 100644
--- a/src/axis.h
+++ b/src/axis.h
@@ -404,10 +404,12 @@ extern struct axis THETA_AXIS;
  * Used also by autoscale_boxplot.
  */
 #define autoscale_one_point(axis, x) do {\
-    if (axis->set_autoscale & AUTOSCALE_MIN && x < axis->min) \
-	axis->min = x; \
-    if (axis->set_autoscale & AUTOSCALE_MAX && x > axis->max) \
-	axis->max = x; \
+    if (axis->min < axis->max) { \
+	if (axis->set_autoscale & AUTOSCALE_MIN && x < axis->min) \
+	    axis->min = x; \
+	if (axis->set_autoscale & AUTOSCALE_MAX && x > axis->max) \
+	    axis->max = x; \
+	} \
     } while (0);
 
 /* parse a position of the form
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.