changeset 18706:ec55f6870efb

Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449). * graphics.cc (axes::properties::calc_ticks_and_lims): Always use a tick separation of 1 order of magnitude for logscale plots.
author Rik <rik@octave.org>
date Wed, 30 Apr 2014 08:24:08 -0700
parents 60df2fd04293
children a18e223224c5
files libinterp/corefcn/graphics.cc
diffstat 1 files changed, 12 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Tue Apr 29 15:50:32 2014 -0700
+++ b/libinterp/corefcn/graphics.cc	Wed Apr 30 08:24:08 2014 -0700
@@ -6424,11 +6424,7 @@
   double tmp;
   // FIXME: should this be checked for somewhere else? (i.e. set{x,y,z}lim)
   if (hi < lo)
-    {
-      tmp = hi;
-      hi = lo;
-      lo = tmp;
-    }
+    std::swap (hi, lo);
 
   if (is_logscale)
     {
@@ -6445,15 +6441,17 @@
         }
     }
 
-  double tick_sep = calc_tick_sep (lo , hi);
-
-  if (is_logscale && ! (xisinf (hi) || xisinf (lo)))
-    {
-      // FIXME: what if (hi-lo) < tick_sep?
-      //         ex: loglog ([1 1.1])
-      tick_sep = std::max (tick_sep, 1.);
-      tick_sep = std::ceil (tick_sep);
-    }
+  double tick_sep;
+  
+  if (is_logscale)
+    {
+      if (! (xisinf (hi) || xisinf (lo)))
+        tick_sep = 1;  // Tick is every order of magnitude (bug #39449)
+      else
+        tick_sep = 0;
+    }
+  else
+    tick_sep = calc_tick_sep (lo , hi);
 
   int i1 = static_cast<int> (gnulib::floor (lo / tick_sep));
   int i2 = static_cast<int> (std::ceil (hi / tick_sep));