changeset 33461:2f5a875246ae

view.m: Move input validation to avoid creating figure on error (bug #65641) * view.m: Move check for simultaneous viewpoint get and set ahead of axes object creation. * NEWS.10.md: note change to view under Graphics backend section.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Thu, 25 Apr 2024 11:54:24 -0400
parents 4401310ad737
children 583637c89c11 7594fda4aab4
files etc/NEWS.10.md scripts/plot/appearance/view.m
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS.10.md	Thu Apr 25 11:41:04 2024 -0400
+++ b/etc/NEWS.10.md	Thu Apr 25 11:54:24 2024 -0400
@@ -38,6 +38,8 @@
 to 'rtick' by the function `rticks` will only include the center tick mark
 value if it is specified.
 
+- `view` correctly interprets cartesion viewpoints on main axes. (bug #65641)
+
 ### Matlab compatibility
 
 - `height` and `width` are now aliases for the `rows` and `columns` functions.
--- a/scripts/plot/appearance/view.m	Thu Apr 25 11:41:04 2024 -0400
+++ b/scripts/plot/appearance/view.m	Thu Apr 25 11:54:24 2024 -0400
@@ -58,6 +58,10 @@
     print_usage ();
   endif
 
+  if (nargout > 0 && nargin > 0)
+    error ("view: cannot simultaneously get and set viewpoint");
+  endif
+
   if (isempty (hax))
     hax = gca ();
   endif
@@ -66,8 +70,6 @@
     vw = get (hax, "view");
     az = vw(1);
     el = vw(2);
-  elseif (nargout > 0)
-    error ("view: cannot simultaneously get and set viewpoint");
   elseif (numel (varargin) == 1)
     x = varargin{1};
     if (numel (x) == 2)