Mercurial > hg > octave-lyh
changeset 17130:26589abbc78d
Don't pass axis handle unnecessarily from high level to low level plot functions.
* scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/compass.m,
scripts/plot/contour.m, scripts/plot/contourf.m, scripts/plot/cylinder.m,
scripts/plot/ellipsoid.m, scripts/plot/errorbar.m, scripts/plot/feather.m,
scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m,
scripts/plot/pcolor.m, scripts/plot/plot3.m, scripts/plot/rectangle.m,
scripts/plot/rose.m, scripts/plot/scatter3.m, scripts/plot/semilogxerr.m,
scripts/plot/semilogy.m, scripts/plot/semilogyerr.m, scripts/plot/slice.m,
scripts/plot/sphere.m, scripts/plot/stairs.m, scripts/plot/surf.m,
scripts/plot/surfc.m, scripts/plot/surfnorm.m, scripts/plot/trimesh.m,
scripts/plot/trisurf.m: Don't pass hax to lower level functions after
newplot() has been called.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 31 Jul 2013 18:42:17 -0700 |
parents | b5d6314314fc |
children | fd9a8b1a8768 |
files | scripts/plot/comet.m scripts/plot/comet3.m scripts/plot/compass.m scripts/plot/contour.m scripts/plot/contourf.m scripts/plot/cylinder.m scripts/plot/ellipsoid.m scripts/plot/errorbar.m scripts/plot/feather.m scripts/plot/mesh.m scripts/plot/meshc.m scripts/plot/meshz.m scripts/plot/pcolor.m scripts/plot/plot3.m scripts/plot/rectangle.m scripts/plot/rose.m scripts/plot/scatter3.m scripts/plot/semilogxerr.m scripts/plot/semilogy.m scripts/plot/semilogyerr.m scripts/plot/slice.m scripts/plot/sphere.m scripts/plot/stairs.m scripts/plot/surf.m scripts/plot/surfc.m scripts/plot/surfnorm.m scripts/plot/trimesh.m scripts/plot/trisurf.m |
diffstat | 28 files changed, 52 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/comet.m +++ b/scripts/plot/comet.m @@ -67,8 +67,8 @@ m = n - dn; m = max ([m, 1]); k = min ([n, num]); - plot (hax, x(1:m), y(1:m), "r", x(m:k), y(m:k), "g", x(k), y(k), "ob"); - axis (hax, limits); + plot (x(1:m), y(1:m), "r", x(m:k), y(m:k), "g", x(k), y(k), "ob"); + axis (limits); drawnow (); pause (p); endfor
--- a/scripts/plot/comet3.m +++ b/scripts/plot/comet3.m @@ -69,9 +69,9 @@ m = n - dn; m = max ([m, 1]); k = min ([n, num]); - htmp = plot3 (hax, x(1:m), y(1:m), z(1:m), "r", - x(m:k), y(m:k), z(m:k), "g", - x(k), y(k), z(k), "ob"); + htmp = plot3 (x(1:m), y(1:m), z(1:m), "r", + x(m:k), y(m:k), z(m:k), "g", + x(k), y(k), z(k), "ob"); axis (limits); drawnow (); pause (p);
--- a/scripts/plot/compass.m +++ b/scripts/plot/compass.m @@ -102,7 +102,7 @@ oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect hax = newplot (hax); - hlist = polar (hax, r, p, line_spec); + hlist = polar (r, p, line_spec); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/contour.m +++ b/scripts/plot/contour.m @@ -68,7 +68,6 @@ hax = newplot (hax); [ctmp, htmp] = __contour__ (hax, "none", varargin{:}); - unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/contourf.m +++ b/scripts/plot/contourf.m @@ -70,7 +70,6 @@ [ctmp, htmp] = __contour__ (hax, "none", "fill", "on", "linecolor", "black", varargin{:}); - unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/cylinder.m +++ b/scripts/plot/cylinder.m @@ -87,8 +87,7 @@ unwind_protect hax = newplot (hax); - surf (hax, x, y, z); - + surf (x, y, z); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/ellipsoid.m +++ b/scripts/plot/ellipsoid.m @@ -78,8 +78,7 @@ unwind_protect hax = newplot (hax); - surf (hax, x, y, z); - + surf (x, y, z); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/errorbar.m +++ b/scripts/plot/errorbar.m @@ -135,7 +135,6 @@ hax = newplot (hax); htmp = __errcomm__ ("errorbar", hax, varargin{:}); - unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/feather.m +++ b/scripts/plot/feather.m @@ -98,7 +98,7 @@ oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect hax = newplot (hax); - hlist = plot (hax, x, y, line_spec, [1, n], [0, 0], line_spec); + hlist = plot (x, y, line_spec, [1, n], [0, 0], line_spec); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -66,14 +66,14 @@ oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect hax = newplot (hax); - htmp = surface (hax, varargin{:}); + + htmp = surface (varargin{:}); set (htmp, "facecolor", "w"); set (htmp, "edgecolor", "flat"); - if (! ishold ()) set (hax, "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); + "xgrid", "on", "ygrid", "on", "zgrid", "on"); endif unwind_protect_cleanup if (! isempty (oldfig))
--- a/scripts/plot/meshc.m +++ b/scripts/plot/meshc.m @@ -65,14 +65,13 @@ unwind_protect hax = newplot (hax); - htmp = surface (hax, varargin{:}); + htmp = surface (varargin{:}); ## FIXME - gnuplot does not support a filled surface and a ## non-filled contour. 3D filled patches are also not supported. ## Thus, the facecolor will be transparent for the gnuplot backend. set (htmp, "facecolor", "w"); set (htmp, "edgecolor", "flat"); - if (! ishold ()) set (hax, "view", [-37.5, 30], "xgrid", "on", "ygrid", "on", "zgrid", "on"); @@ -81,7 +80,6 @@ drawnow (); zmin = get (hax, "zlim")(1); - [~, htmp2] = __contour__ (hax, zmin, varargin{:}); htmp = [htmp; htmp2];
--- a/scripts/plot/meshz.m +++ b/scripts/plot/meshz.m @@ -103,7 +103,7 @@ oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect hax = newplot (hax); - htmp = mesh (hax, x, y, z, varargin{charidx:end}); + htmp = mesh (x, y, z, varargin{charidx:end}); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/pcolor.m +++ b/scripts/plot/pcolor.m @@ -81,7 +81,6 @@ set (htmp, "facecolor", "flat"); set (hax, "box", "on"); - if (! ishold ()) set (hax, "view", [0, 90]); endif
--- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -209,7 +209,7 @@ color = __next_line_color__ (); endif - htmp(++idx) = line (hax, x(:, i), y(:, i), z(:, i), + htmp(++idx) = line (x(:, i), y(:, i), z(:, i), "color", color, "linestyle", linestyle, "marker", marker, properties{:}); key = options.key; @@ -264,7 +264,7 @@ color = __next_line_color__ (); endif - htmp(++idx) = line (hax, x(:, i), y(:, i), z(:, i), + htmp(++idx) = line (x(:, i), y(:, i), z(:, i), "color", color, "linestyle", linestyle, "marker", marker, properties{:}); key = options.key; @@ -339,7 +339,7 @@ color = __next_line_color__ (); endif - htmp(++idx) = line (hax, x(:, i), y(:, i), z(:, i), + htmp(++idx) = line (x(:, i), y(:, i), z(:, i), "color", color, "linestyle", linestyle, "marker", marker, properties{:}); key = options.key;
--- a/scripts/plot/rectangle.m +++ b/scripts/plot/rectangle.m @@ -64,8 +64,7 @@ unwind_protect hax = newplot (hax); - htmp = __rectangle__ (hax, varargin{:}); - + htmp = __rectangle__ (hax, varargin{:}); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig); @@ -213,9 +212,9 @@ function update_props (h, d) kids = get (h, "children"); set (kids, "edgecolor", get (h, "edgecolor"), - "linewidth", get (h, "linewidth"), - "linestyle", get (h, "linestyle"), - "facecolor", get (h, "facecolor")); + "linewidth", get (h, "linewidth"), + "linestyle", get (h, "linestyle"), + "facecolor", get (h, "facecolor")); endfunction
--- a/scripts/plot/rose.m +++ b/scripts/plot/rose.m @@ -93,7 +93,7 @@ oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect hax = newplot (hax); - htmp = polar (hax, th, r); + htmp = polar (th, r); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/scatter3.m +++ b/scripts/plot/scatter3.m @@ -77,6 +77,11 @@ hax = newplot (hax); tmp = __scatter__ (hax, 3, "scatter3", varargin{:}); + + if (! ishold (hax)) + set (hax, "view", [-37.5, 30], + "xgrid", "on", "ygrid", "on", "zgrid", "on"); + endif unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig); @@ -84,11 +89,6 @@ end_unwind_protect endif - if (! ishold (hax)) - set (hax, "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); - endif - if (nargout > 0) retval = tmp; endif
--- a/scripts/plot/semilogxerr.m +++ b/scripts/plot/semilogxerr.m @@ -54,6 +54,7 @@ if (! ishold (hax)) set (hax, "xminortick", "on"); endif + htmp = __errcomm__ ("semilogxerr", hax, varargin{:}); unwind_protect_cleanup
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -56,16 +56,16 @@ htmp = __plt__ ("semilogy", hax, varargin{:}); - if (nargout > 0) - h = htmp; - endif - unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig); endif end_unwind_protect + if (nargout > 0) + h = htmp; + endif + endfunction
--- a/scripts/plot/semilogyerr.m +++ b/scripts/plot/semilogyerr.m @@ -54,6 +54,7 @@ if (! ishold (hax)) set (hax, "yminortick", "on"); endif + htmp = __errcomm__ ("semilogyerr", hax, varargin{:}); unwind_protect_cleanup
--- a/scripts/plot/slice.m +++ b/scripts/plot/slice.m @@ -160,8 +160,8 @@ [xi, yi, zi] = meshgrid (squeeze (x(1,:,1)), sy(i), squeeze (z(1,1,:))); vy = squeeze (interp3 (x, y, z, v, xi, yi, zi, method)); htmp(sidx++) = surface (squeeze (xi), - squeeze (sy(i) * ones (size (zi))), - squeeze (zi), vy); + squeeze (sy(i) * ones (size (zi))), + squeeze (zi), vy); endfor endif @@ -170,7 +170,7 @@ [xi, yi, zi] = meshgrid (sx(i), squeeze (y(:,1,1)), squeeze (z(1,1,:))); vx = squeeze (interp3 (x, y, z, v, xi, yi, zi, method)); htmp(sidx++) = surface (squeeze (sx(i) * ones (size (zi))), - squeeze (yi), squeeze(zi), vx); + squeeze (yi), squeeze(zi), vx); endfor endif else
--- a/scripts/plot/sphere.m +++ b/scripts/plot/sphere.m @@ -75,8 +75,7 @@ unwind_protect hax = newplot (hax); - surf (hax, x, y, z); - + surf (x, y, z); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/stairs.m +++ b/scripts/plot/stairs.m @@ -164,8 +164,8 @@ if (doplot) h = []; + hold_state = get (gca (), "nextplot"); unwind_protect - hold_state = get (gca (), "nextplot"); for i = 1 : columns (y) hg = hggroup (); h = [h; hg];
--- a/scripts/plot/surf.m +++ b/scripts/plot/surf.m @@ -70,8 +70,9 @@ if (! ishold (hax)) set (hax, "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); + "xgrid", "on", "ygrid", "on", "zgrid", "on"); endif + unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig);
--- a/scripts/plot/surfc.m +++ b/scripts/plot/surfc.m @@ -68,10 +68,9 @@ unwind_protect hax = newplot (hax); - htmp = surface (hax, varargin{:}); + htmp = surface (varargin{:}); set (htmp, "facecolor", "flat"); - if (! ishold ()) set (hax, "view", [-37.5, 30], "xgrid", "on", "ygrid", "on", "zgrid", "on");
--- a/scripts/plot/surfnorm.m +++ b/scripts/plot/surfnorm.m @@ -118,7 +118,7 @@ unwind_protect hax = newplot (hax); - surf (hax, x, y, z, varargin{ioff:end}); + surf (x, y, z, varargin{ioff:end}); old_hold_state = get (hax, "nextplot"); unwind_protect set (hax, "nextplot", "add");
--- a/scripts/plot/trimesh.m +++ b/scripts/plot/trimesh.m @@ -59,13 +59,13 @@ elseif (ischar (z)) triplot (tri, x, y, z, varargin{:}); else - newplot (); + hax = newplot (); handle = patch ("Vertices", [x(:), y(:), z(:)], "Faces", tri, "FaceColor", "none", "EdgeColor", __next_line_color__ (), varargin{:}); if (! ishold ()) - set (gca (), "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); + set (hax, "view", [-37.5, 30], + "xgrid", "on", "ygrid", "on", "zgrid", "on"); endif if (nargout > 0) h = handle;
--- a/scripts/plot/trisurf.m +++ b/scripts/plot/trisurf.m @@ -73,17 +73,17 @@ && strcmpi (varargin{nfc+1}, "interp")) varargin(end+(1:2)) = {"EdgeColor", "none"}; endif - newplot (); - handle = patch ("Faces", tri, "Vertices", [x(:), y(:), z(:)], - "FaceVertexCData", reshape (c, numel (c), 1), - varargin{:}); + hax = newplot (); + htmp = patch ("Faces", tri, "Vertices", [x(:), y(:), z(:)], + "FaceVertexCData", reshape (c, numel (c), 1), + varargin{:}); if (nargout > 0) - h = handle; + h = htmp; endif if (! ishold ()) - set (gca (), "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); + set (hax, "view", [-37.5, 30], + "xgrid", "on", "ygrid", "on", "zgrid", "on"); endif endif