Mercurial > hg > octave-terminal
changeset 7110:0e63f1126f01
[project @ 2007-11-06 22:36:22 by jwe]
author | jwe |
---|---|
date | Tue, 06 Nov 2007 22:36:22 +0000 |
parents | 5436efbf35e3 |
children | 9c73ef1819c7 |
files | scripts/plot/__go_draw_axes__.m scripts/plot/mesh.m scripts/plot/pcolor.m scripts/plot/shading.m scripts/plot/surf.m scripts/plot/surface.m |
diffstat | 6 files changed, 90 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -574,7 +574,8 @@ case "surface" nd = 4; - if !((strncmp(obj.edgecolor,"none",4)) && (strncmp(obj.facecolor,"none",4))) + if (! (strncmp (obj.edgecolor, "none", 4) + && strncmp (obj.facecolor, "none", 4))) data_idx++; is_image_data(data_idx) = false; parametric(data_idx) = false; @@ -598,7 +599,7 @@ ydat = obj.ydata; zdat = obj.zdata; cdat = obj.cdata; - + if (xautoscale) tx = xdat(:); [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); @@ -621,7 +622,8 @@ err = true; endif if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) - if (rows (zdat) == length (ydat) && columns (zdat) == length (xdat)) + if (rows (zdat) == length (ydat) + && columns (zdat) == length (xdat)) [xdat, ydat] = meshgrid (xdat, ydat); else err = true; @@ -664,40 +666,43 @@ if (have_newer_gnuplot) ## Interpolation does not work for flat surfaces (e.g. pcolor) - ## and color mapping --> currently set empty + ## and color mapping --> currently set empty. interp_str = ""; surf_colormap = parent_figure_obj.colormap; - flat_interp_face = strncmp(obj.facecolor,"flat",4) || strncmp(obj.facecolor,"interp",6); - flat_interp_edge = strncmp(obj.edgecolor,"flat",4) || strncmp(obj.edgecolor,"interp",6); + flat_interp_face = (strncmp (obj.facecolor, "flat", 4) + || strncmp (obj.facecolor, "interp", 6)); + flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) + || strncmp (obj.edgecolor, "interp", 6)); palette_data = []; - if ((flat_interp_face) || - (flat_interp_edge && strncmp(obj.facecolor,"none",4))) + if (flat_interp_face + || (flat_interp_edge && strncmp (obj.facecolor, "none", 4))) palette_data = [1:rows(surf_colormap); surf_colormap']; - endif + endif - if (isnumeric(obj.facecolor)) + if (isnumeric (obj.facecolor)) palette_data = [1:2; [obj.facecolor; obj.facecolor]']; endif - if ((strncmp(obj.facecolor,"none",4) && isnumeric(obj.edgecolor))) + if (strncmp (obj.facecolor, "none", 4) + && isnumeric (obj.edgecolor)) palette_data = [1:2; [obj.edgecolor; obj.edgecolor]']; endif - if (strncmp(obj.facecolor,"none",4)) - elseif (flat_interp_face && strncmp(obj.edgecolor,"flat",4)) - fprintf (plot_stream, "set pm3d at s %s\n", interp_str); + if (strncmp (obj.facecolor, "none", 4)) + elseif (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) + fprintf (plot_stream, "set pm3d at s %s;\n", interp_str); else - if (strncmp(obj.edgecolor,"none",4)) - fprintf (plot_stream, "set pm3d at s %s\n", interp_str); + if (strncmp(obj.edgecolor, "none", 4)) + fprintf (plot_stream, "set pm3d at s %s;\n", interp_str); else edgecol = obj.edgecolor; if (ischar(obj.edgecolor)) edgecol = [0 0 0]; endif - fprintf (plot_stream, "set pm3d at s hidden3d %d %s \n", data_idx, interp_str); - fprintf (plot_stream, - "set style line %d linecolor rgb \"#%02x%02x%02x\" lw %f\n", + fprintf (plot_stream, "set pm3d at s hidden3d %d %s;\n", data_idx, interp_str); + fprintf (plot_stream, + "set style line %d linecolor rgb \"#%02x%02x%02x\" lw %f;\n", data_idx, round (255*edgecol), obj.linewidth); endif endif @@ -809,7 +814,8 @@ else ydir = "noreverse"; endif - fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", yaxisloc, ylim, ydir); + fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", + yaxisloc, ylim, ydir); if (nd == 3 || nd == 4) if (zautoscale && have_data) @@ -828,7 +834,7 @@ endif fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); endif - + if (strcmpi (axis_obj.box, "on")) if (nd == 3 || nd == 4) fputs (plot_stream, "set border 4095;\n");
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -35,10 +35,14 @@ newplot (); tmp = surface (varargin{:}); - ax = get(tmp, "parent"); - set (tmp, "FaceColor", "none"); - set (tmp, "EdgeColor", "flat"); + + ax = get (tmp, "parent"); + + set (tmp, "facecolor", "none"); + set (tmp, "edgecolor", "flat"); + set (ax, "view", [-37.5, 30]); + if (nargout > 0) h = tmp; endif
--- a/scripts/plot/pcolor.m +++ b/scripts/plot/pcolor.m @@ -1,6 +1,4 @@ - -## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2004, -## 2005, 2006, 2007 John W. Eaton +## Copyright (C) 2007 Kai Habel ## ## This file is part of Octave. ## @@ -30,28 +28,31 @@ ## @seealso{meshgrid, contour} ## @end deftypefn -## Author: jwe +## Author: Kai Habel <kai.habel@gmx.de> -function h = pcolor (x,y,c) +function h = pcolor (x, y, c) newplot (); if (nargin == 1) - C = x; - Z = zeros(size(C)); - [nr, nc] = size(C); - [X, Y] = meshgrid(1:nr, 1:nc); + c = x; + z = zeros (size (c)); + [nr, nc] = size (c); + [x, y] = meshgrid (1:nr, 1:nc); elseif (nargin == 3) - Z = zeros(size(C)); + z = zeros (size (c)); else - print_usage(); - end; + print_usage (); + endif + tmp = surface (X, Y, Z, c); - tmp = surface (X,Y,Z,C); - ax = get(tmp, "parent"); - set (tmp, "FaceColor", "flat"); + ax = get (tmp, "parent"); + + set (tmp, "facecolor", "flat"); + set (ax, "view", [0, 90]); + if (nargout > 0) h = tmp; endif
--- a/scripts/plot/shading.m +++ b/scripts/plot/shading.m @@ -1,5 +1,4 @@ - -## Copyright (C) 2006,2007 Kai Habel +## Copyright (C) 2006, 2007 Kai Habel ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by @@ -31,33 +30,38 @@ ## ## @end deftypefn -function shading(ax, mode) +## Author: Kai Habel <kai.habel@gmx.de> + +function shading (ax, mode) if (nargin == 1) mode = ax; - ax = gca(); - end - - if ((nargin !=1 ) && (nargin != 2)) - print_usage(); + ax = gca (); end - obj = findobj(ax,"Type","patch"); - obj = [obj; findobj(ax,"Type","surface")]; + if (nargin != 1 && nargin != 2) + print_usage (); + endif - for n = 1 : length(obj) + h1 = findobj (ax, "type", "patch"); + h2 = findobj (ax, "type", "surface"); + + obj = [h1, h2]; + + for n = 1:numel(obj) h = obj(n); - if strcmp(mode, "flat") - set(h,"FaceColor","flat"); - set(h,"EdgeColor","none"); - elseif strcmp(mode,"interp") - set(h,"FaceColor","interp"); - set(h,"EdgeColor","none"); - elseif strcmp(mode,"faceted") - set(h,"FaceColor","flat"); - set(h,"EdgeColor",[0 0 0]); + if (strcmp (mode, "flat")) + set (h, "facecolor", "flat"); + set (h, "edgecolor", "none"); + elseif (strcmp (mode, "interp")) + set (h, "facecolor", "interp"); + set (h, "edgecolor", "none"); + elseif (strcmp (mode, "faceted")) + set (h, "facecolor", "flat"); + set (h, "edgecolor", [0 0 0]); else - error("unknown argument") + error ("unknown argument"); endif endfor + endfunction
--- a/scripts/plot/surf.m +++ b/scripts/plot/surf.m @@ -1,6 +1,4 @@ - -## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2004, -## 2005, 2006, 2007 John W. Eaton +## Copyright (C) 2007 Kai Habel ## ## This file is part of Octave. ## @@ -29,16 +27,20 @@ ## @seealso{mesh, surface} ## @end deftypefn -## Author: jwe +## Author: Kai Habel <kai.habel@gmx.de> function h = surf (varargin) newplot (); tmp = surface (varargin{:}); - ax = get(tmp, "parent"); - set (tmp, "FaceColor", "flat"); + + ax = get (tmp, "parent"); + + set (tmp, "facecolor", "flat"); + set (ax, "view", [-37.5, 30]); + if (nargout > 0) h = tmp; endif
--- a/scripts/plot/surface.m +++ b/scripts/plot/surface.m @@ -1,4 +1,3 @@ - ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2004, ## 2005, 2006, 2007 John W. Eaton ## @@ -34,7 +33,7 @@ function h = surface (x, y, z, c) - ax = gca(); + ax = gca (); if (nargin == 1) c = z = x; @@ -46,25 +45,23 @@ error ("surface: argument must be a matrix"); endif elseif (nargin == 3) + c = z; if (isvector (x) && isvector (y) && ismatrix (z)) if (rows (z) == length (y) && columns (z) == length (x)) x = x(:)'; y = y(:); else - msg = "surface: rows (z) must be the same as length (y) and"; - msg = sprintf ("%s\ncolumns (z) must be the same as length (x)", msg); - error (msg); + error ("surface: rows (z) must be the same as length (y) and columns (z) must be the same as length (x)"); endif elseif (ismatrix (x) && ismatrix (y) && ismatrix (z)) if (! (size_equal (x, y) && size_equal (x, z))) error ("surface: x, y, and z must have same dimensions"); endif - c = z; else error ("surface: x and y must be vectors and z must be a matrix"); endif elseif (nargin == 4) - if !(size_equal (z, c)) + if (! size_equal (z, c)) error ("surface: z and c must have same size"); endif if (isvector (x) && isvector (y) && ismatrix (z)) @@ -72,9 +69,7 @@ x = x(:)'; y = y(:); else - msg = "surface: rows (z) must be the same as length (y) and"; - msg = sprintf ("%s\ncolumns (z) must be the same as length (x)", msg); - error (msg); + error ("surface: rows (z) must be the same as length (y) and columns (z) must be the same as length (x)" endif elseif (ismatrix (x) && ismatrix (y) && ismatrix (z)) if (! (size_equal (x, y) && size_equal (x, z))) @@ -87,11 +82,11 @@ print_usage (); endif - ## make a default surface object + ## Make a default surface object. tmp = __go_surface__ (ax, "xdata", x, "ydata", y, "zdata", z, "cdata", c); set (ax, "view", [0, 90], "box", "off"); - set (tmp, "FaceColor","flat"); + set (tmp, "facecolor","flat"); if (nargout > 0) h = tmp;