changeset 17564:234731d524c2

axis.m: Fix 'axis tight' with pcolor plots. * libinterp/corefcn/graphics.cc(calc_dimensions): Use if/else if tree to avoid unnecessary comparisons once object has been determined to be 3-D. * libinterp/corefcn/graphics.cc(F__calc_dimensions__): Put input validation first. * scripts/plot/axis.m: Check for 2D view (elevation = 90) before setting Z limits.
author Rik <rik@octave.org>
date Fri, 04 Oct 2013 06:59:31 -0700
parents d7ca186396d4
children ddecb2e231d4
files libinterp/corefcn/graphics.cc scripts/plot/axis.m
diffstat 2 files changed, 32 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Fri Oct 04 00:15:36 2013 -0400
+++ b/libinterp/corefcn/graphics.cc	Fri Oct 04 06:59:31 2013 -0700
@@ -4614,7 +4614,7 @@
   double yo = ylimits(yd > 0 ? 0 : 1);
   double zo = zlimits(zd > 0 ? 0 : 1);
 
-  Matrix pb  = get_plotboxaspectratio ().matrix_value ();
+  Matrix pb = get_plotboxaspectratio ().matrix_value ();
 
   bool autocam = (camerapositionmode_is ("auto")
                   && cameratargetmode_is ("auto")
@@ -9088,25 +9088,27 @@
 
   if (go.isa ("surface"))
     nd = 3;
-
-  if ((go.isa ("line") || go.isa ("patch")) && ! go.get("zdata").is_empty ())
+  else if ((go.isa ("line") || go.isa ("patch"))
+            && ! go.get ("zdata").is_empty ())
     nd = 3;
-
-  Matrix kids = go.get_properties ().get_children ();
-
-  for (octave_idx_type i = 0; i < kids.length (); i++)
-    {
-      graphics_handle hnd = gh_manager::lookup (kids(i));
-
-      if (hnd.ok ())
-        {
-          const graphics_object& kid = gh_manager::get_object (hnd);
-
-          if (kid.valid_object ())
-            nd = calc_dimensions (kid);
-
-          if (nd == 3)
-            break;
+  else
+    {
+      Matrix kids = go.get_properties ().get_children ();
+
+      for (octave_idx_type i = 0; i < kids.length (); i++)
+        {
+          graphics_handle hnd = gh_manager::lookup (kids(i));
+
+          if (hnd.ok ())
+            {
+              const graphics_object& kid = gh_manager::get_object (hnd);
+
+              if (kid.valid_object ())
+                nd = calc_dimensions (kid);
+
+              if (nd == 3)
+                break;
+            }
         }
     }
 
@@ -9126,17 +9128,15 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1)
-    {
-      double h = args(0).double_value ();
-
-      if (! error_state)
-        retval = calc_dimensions (gh_manager::get_object (h));
-      else
-        error ("__calc_dimensions__: expecting graphics handle as only argument");
-    }
+  if (nargin != 1)
+    print_usage ();
+
+  double h = args(0).double_value ();
+
+  if (! error_state)
+    retval = calc_dimensions (gh_manager::get_object (h));
   else
-    print_usage ();
+    error ("__calc_dimensions__: expecting graphics handle as only argument");
 
   return retval;
 }
--- a/scripts/plot/axis.m	Fri Oct 04 00:15:36 2013 -0400
+++ b/scripts/plot/axis.m	Fri Oct 04 06:59:31 2013 -0700
@@ -364,7 +364,9 @@
     ylim = ylim .* (1 + eps () * [-1, 1]);
   endif
   set (ca, "xlim", xlim, "ylim", ylim)
-  if (__calc_dimensions__ (ca) > 2)
+  nd = __calc_dimensions__ (ca);
+  is3dview = (get (ca, "view")(2) != 90);
+  if (nd > 2 && is3dview)
     zlim = __get_tight_lims__ (ca, "z");
     if (all (zlim == 0))
       zlim = eps () * [-1 1];