Mercurial > hg > octave-nkf
changeset 17066:328b579e08e9
mesh.m,meshc.m,meshz.m: Overhaul to use newplot and __plt_get_axis_arg__.
* scripts/plot/mesh.m: Call __plt_get_axis_arg__ and then newplot.
Fix typo in %!demo string.
* scripts/plot/meshc.m: Call __plt_get_axis_arg__ and then newplot.
* scripts/plot/meshz.m: Update to use new __plt_get_axis_arg__.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Jul 2013 23:12:46 -0700 |
parents | 991e8a386aa3 |
children | b2cbf369837e |
files | scripts/plot/mesh.m scripts/plot/meshc.m scripts/plot/meshz.m |
diffstat | 3 files changed, 53 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -46,19 +46,25 @@ error ("mesh: X, Y, Z, C arguments must be real"); endif - newplot (); + [hax, varargin, nargin] = __plt_get_axis_arg__ ("mesh", varargin{:}); - htmp = surface (varargin{:}); + oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + unwind_protect + hax = newplot (hax); + htmp = surface (hax, varargin{:}); - ax = get (htmp, "parent"); + set (htmp, "facecolor", "w"); + set (htmp, "edgecolor", "flat"); - set (htmp, "facecolor", "w"); - set (htmp, "edgecolor", "flat"); - - if (! ishold ()) - set (ax, "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); - endif + if (! ishold ()) + set (hax, "view", [-37.5, 30], + "xgrid", "on", "ygrid", "on", "zgrid", "on"); + endif + unwind_protect_cleanup + if (! isempty (oldfig)) + set (0, "currentfigure", oldfig); + endif + end_unwind_protect if (nargout > 0) h = htmp; @@ -86,6 +92,6 @@ %! ylabel 'Y-axis'; %! zlabel 'log scale'; %! if (strcmp (get (gcf, '__graphics_toolkit__'), 'gnuplot')) -%! title ({'Gnuplot: mesh color is wrong', 'This a Gnuplot bug'}); +%! title ({'Gnuplot: mesh color is wrong', 'This is a Gnuplot bug'}); %! endif
--- a/scripts/plot/meshc.m +++ b/scripts/plot/meshc.m @@ -33,32 +33,42 @@ error ("meshc: X, Y, Z, C arguments must be real"); endif - newplot (); + [hax, varargin, nargin] = __plt_get_axis_arg__ ("meshc", varargin{:}); - htmp = surface (varargin{:}); - - ax = get (htmp, "parent"); + oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + unwind_protect + hax = newplot (hax); - set (htmp, "facecolor", "w"); - set (htmp, "edgecolor", "flat"); - ## 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. + htmp = surface (hax, 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 (ax, "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); - endif + if (! ishold ()) + set (hax, "view", [-37.5, 30], + "xgrid", "on", "ygrid", "on", "zgrid", "on"); + endif + + drawnow (); + + zmin = get (hax, "zlim")(1); - drawnow (); - zmin = get (ax, "zlim")(1); + [~, htmp2] = __contour__ (hax, zmin, varargin{:}); + + htmp = [htmp; htmp2]; - [~, htmp2] = __contour__ (ax, zmin, varargin{:}); - - htmp = [htmp; htmp2]; + unwind_protect_cleanup + if (! isempty (oldfig)) + set (0, "currentfigure", oldfig); + endif + end_unwind_protect if (nargout > 0) h = htmp; endif endfunction +
--- a/scripts/plot/meshz.m +++ b/scripts/plot/meshz.m @@ -33,7 +33,7 @@ error ("meshz: X, Y, Z, C arguments must be real"); endif - [ax, varargin, nargin] = __plt_get_axis_arg__ ("meshz", varargin{:}); + [hax, varargin, nargin] = __plt_get_axis_arg__ ("meshz", varargin{:}); ## Find where property/value pairs start charidx = find (cellfun ("isclass", varargin, "char"), 1); @@ -72,14 +72,16 @@ zref = min (z(isfinite (z))); z = [zref .* ones(1, columns(z) + 2); zref .* ones(rows(z), 1), z, zref .* ones(rows(z), 1); - zref.* ones(1, columns(z) + 2)]; + zref .* ones(1, columns(z) + 2)]; - oldax = gca (); + oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect - axes (ax); - htmp = mesh (x, y, z, varargin{charidx:end}); + hax = newplot (hax); + htmp = mesh (hax, x, y, z, varargin{charidx:end}); unwind_protect_cleanup - axes (oldax); + if (! isempty (oldfig)) + set (0, "currentfigure", oldfig); + endif end_unwind_protect if (nargout > 0)