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 <3467227.u06PiINMj0@stonelion>
On Friday, 11 September 2020 22:51:03 PDT Ethan A Merritt wrote:

> 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.

Better patch (but still not fully correct)

	Ethan

_______________________________________________
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, 695 B)
diff --git a/src/axis.h b/src/axis.h
index a89800800..ed2e43973 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->range_flags & RANGE_IS_REVERSED)) { \
+	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.