[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: improved surface: __go_draw_axes__
From: |
David Bateman |
Subject: |
Re: improved surface: __go_draw_axes__ |
Date: |
Wed, 07 Nov 2007 03:01:25 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
Please use the attached version of the patch as hidden3d should be set
by lines so as to avoid issues with the surfc function..
D.
Index: scripts/plot/__go_draw_axes__.m
===================================================================
RCS file: /usr/local/cvsroot/octave/scripts/plot/__go_draw_axes__.m,v
retrieving revision 1.56
diff -u -r1.56 __go_draw_axes__.m
--- scripts/plot/__go_draw_axes__.m 6 Nov 2007 22:36:22 -0000 1.56
+++ scripts/plot/__go_draw_axes__.m 7 Nov 2007 01:59:41 -0000
@@ -237,6 +237,7 @@
data_idx++;
is_image_data(data_idx) = true;
parametric(data_idx) = false;
+ have_cdata(data_idx) = false;
[y_dim, x_dim] = size (img_data(:,:,1));
if (x_dim > 1)
@@ -300,6 +301,7 @@
data_idx++;
is_image_data(data_idx) = false;
parametric(data_idx) = true;
+ have_cdata(data_idx) = false;
if (isempty (obj.keylabel))
titlespec{data_idx} = "title \"\"";
else
@@ -320,6 +322,7 @@
xdat = obj.xdata(:);
ydat = obj.ydata(:);
zdat = obj.zdata(:);
+
if (xautoscale)
[xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat);
endif
@@ -332,7 +335,7 @@
data{data_idx} = [xdat, ydat, zdat]';
usingclause{data_idx} = "using ($1):($2):($3)";
fputs (plot_stream, "set parametric;\n");
- fputs (plot_stream, "unset hidden3d;\n");
+ fputs (plot_stream, "set hidden3d;\n");
fputs (plot_stream, "set style data lines;\n");
fputs (plot_stream, "set surface;\n");
fputs (plot_stream, "unset contour;\n");
@@ -446,6 +449,7 @@
data_idx++;
is_image_data(data_idx) = false;
parametric(data_idx) = false;
+ have_cdata(data_idx) = false;
titlespec{data_idx} = "title \"\"";
usingclause{data_idx} = "";
if (isfield (obj, "facecolor") && isfield (obj, "cdata"))
@@ -520,6 +524,7 @@
data_idx++;
is_image_data(data_idx) = false;
parametric(data_idx) = false;
+ have_cdata(data_idx) = false;
titlespec{data_idx} = "title \"\"";
usingclause{data_idx} = "";
if (isfield (obj, "edgecolor"))
@@ -573,12 +578,13 @@
endfor
case "surface"
- nd = 4;
+ nd = 3;
if (! (strncmp (obj.edgecolor, "none", 4)
&& strncmp (obj.facecolor, "none", 4)))
data_idx++;
is_image_data(data_idx) = false;
parametric(data_idx) = false;
+ have_cdata(data_idx) = true;
[style, typ, with] = do_linestyle_command (obj, data_idx,
plot_stream);
if (isempty (obj.keylabel))
titlespec{data_idx} = "title \"\"";
@@ -664,49 +670,75 @@
fputs (plot_stream, "unset contour;\n");
fprintf (plot_stream, "set cbrange [%g:%g];\n", cmin, cmax);
- if (have_newer_gnuplot)
- ## Interpolation does not work for flat surfaces (e.g. pcolor)
- ## 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));
- palette_data = [];
-
- if (flat_interp_face
- || (flat_interp_edge && strncmp (obj.facecolor, "none", 4)))
- palette_data = [1:rows(surf_colormap); surf_colormap'];
- endif
+ ## Interpolation does not work for flat surfaces (e.g. pcolor)
+ ## 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));
+ palette_data = [];
+
+ if (flat_interp_face
+ || (flat_interp_edge && strncmp (obj.facecolor, "none", 4)))
+ palette_data = [1:rows(surf_colormap); surf_colormap'];
+ endif
- if (isnumeric (obj.facecolor))
- palette_data = [1:2; [obj.facecolor; obj.facecolor]'];
- endif
+ if (isnumeric (obj.facecolor))
+ palette_data = [1:2; [obj.facecolor; obj.facecolor]'];
+ endif
- if (strncmp (obj.facecolor, "none", 4)
- && isnumeric (obj.edgecolor))
- palette_data = [1:2; [obj.edgecolor; obj.edgecolor]'];
- endif
+ 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))
+ 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);
else
- 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);
+ 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);
+
+ if (have_newer_gnuplot)
fprintf (plot_stream,
"set style line %d linecolor rgb \"#%02x%02x%02x\"
lw %f;\n",
data_idx, round (255*edgecol), obj.linewidth);
- endif
+ else
+ if (isequal (edgecol, [0,0,0]))
+ typ = -1;
+ elseif (isequal (edgecol, [1,0,0]))
+ typ = 1;
+ elseif (isequal (edgecol, [0,1,0]))
+ typ = 2;
+ elseif (isequal (edgecol, [0,0,1]))
+ typ = 3;
+ elseif (isequal (edgecol, [1,0,1]))
+ typ = 4;
+ elseif (isequal (edgecol, [0,1,1]))
+ typ = 5;
+ elseif (isequal (edgecol, [1,1,1]))
+ typ = -1;
+ elseif (isequal (edgecol, [1,1,0]))
+ typ = 7;
+ else
+ typ = -1;
+ endif
+ fprintf (plot_stream,
+ "set style line %d lt %d lw %f;\n",
+ data_idx, typ, obj.linewidth);
+ endif
endif
+ endif
+ if (have_newer_gnuplot)
if (length(palette_data) > 0)
fprintf (plot_stream,
"set palette positive color model RGB maxcolors %i;\n",
@@ -817,7 +849,7 @@
fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n",
yaxisloc, ylim, ydir);
- if (nd == 3 || nd == 4)
+ if (nd == 3)
if (zautoscale && have_data)
zlim = get_axis_limits (zmin, zmax, zminp, zlogscale);
if (isempty (zlim))
@@ -836,13 +868,13 @@
endif
if (strcmpi (axis_obj.box, "on"))
- if (nd == 3 || nd == 4)
+ if (nd == 3)
fputs (plot_stream, "set border 4095;\n");
else
fputs (plot_stream, "set border 431;\n");
endif
else
- if (nd == 3 || nd == 4)
+ if (nd == 3)
fputs (plot_stream, "set border 895;\n");
else
fputs (plot_stream, "set border 3;\n");
@@ -947,7 +979,8 @@
if (is_image_data(i))
fwrite (plot_stream, data{i}, "float32");
else
- __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i));
+ __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i),
+ have_cdata(i));
endif
endfor
else
@@ -1182,7 +1215,7 @@
endfunction
-function __gnuplot_write_data__ (plot_stream, data, nd, parametric)
+function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata)
## DATA is already transposed.
@@ -1220,21 +1253,17 @@
fprintf (plot_stream, "%.15g %.15g %.15g\n", data);
else
nc = columns (data);
- for j = 1:3:nc
- fprintf (plot_stream, "%.15g %.15g %.15g\n", data(:,j:j+2)');
- fputs (plot_stream, "\n");
- endfor
- endif
- elseif (nd == 4)
- ## FIXME -- handle NaNs here too?
- if (parametric)
- fprintf (plot_stream, "%.15g %.15g %.15g\n", data);
- else
- nc = columns (data);
- for j = 1:4:nc
- fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data(:,j:j+3)');
- fputs (plot_stream, "\n");
- endfor
+ if (cdata)
+ for j = 1:4:nc
+ fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data(:,j:j+3)');
+ fputs (plot_stream, "\n");
+ endfor
+ else
+ for j = 1:3:nc
+ fprintf (plot_stream, "%.15g %.15g %.15g\n", data(:,j:j+2)');
+ fputs (plot_stream, "\n");
+ endfor
+ endif
endif
endif
fputs (plot_stream, "e\n");
Index: scripts/plot/meshc.m
===================================================================
RCS file: /usr/local/cvsroot/octave/scripts/plot/meshc.m,v
retrieving revision 1.3
diff -u -r1.3 meshc.m
--- scripts/plot/meshc.m 12 Oct 2007 21:27:24 -0000 1.3
+++ scripts/plot/meshc.m 7 Nov 2007 01:59:41 -0000
@@ -31,47 +31,14 @@
newplot ();
- if (nargin == 1)
- z = varargin{1};
- if (ismatrix (z))
- [nr, nc] = size (z);
- x = 1:nc;
- y = (1:nr)';
- else
- error ("meshc: argument must be a matrix");
- endif
- elseif (nargin == 3)
- x = varargin{1};
- y = varargin{2};
- z = varargin{3};
-
- if (isvector (x) && isvector (y) && ismatrix (z))
- if (rows (z) == length (y) && columns (z) == length (x))
- x = x(:)';
- y = y(:);
- else
- msg = "meshc: 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);
- endif
- elseif (ismatrix (x) && ismatrix (y) && ismatrix (z))
- if (! (size_equal (x, y) && size_equal (x, z)))
- error ("meshc: x, y, and z must have same dimensions");
- endif
- else
- error ("meshc: x and y must be vectors and z must be a matrix");
- endif
- else
- print_usage ();
- endif
+ tmp = surface (varargin{:});
- ## make a default line object, and make it the current axes for the
- ## current figure.
- ca = gca ();
+ ax = get (tmp, "parent");
- tmp = __go_surface__ (ca, "xdata", x, "ydata", y, "zdata", z);
+ set (tmp, "facecolor", "none");
+ set (tmp, "edgecolor", "flat");
- set (ca, "view", [-37.5, 30]);
+ set (ax, "view", [-37.5, 30]);
hold on;
2007-11-07 David Bateman <address@hidden>
* plot/__go_draw_axes__.m: Fix surfaces for gnuplot 4.0 and for
the meshc.m function.
* plot/meshc.m: Also use the surface function.
- Re: improved surface: __go_draw_axes__, (continued)
- Re: improved surface: __go_draw_axes__, Kai Habel, 2007/11/05
- Re: improved surface: __go_draw_axes__, Kai Habel, 2007/11/05
- Re: improved surface: __go_draw_axes__, John W. Eaton, 2007/11/06
- Re: improved surface: __go_draw_axes__, David Bateman, 2007/11/06
- Re: improved surface: __go_draw_axes__, John W. Eaton, 2007/11/06
- Re: improved surface: __go_draw_axes__, David Bateman, 2007/11/06
- Re: improved surface: __go_draw_axes__, John W. Eaton, 2007/11/07
- Re: improved surface: __go_draw_axes__, David Bateman, 2007/11/07
- Re: improved surface: __go_draw_axes__, David Bateman, 2007/11/06
- Re: improved surface: __go_draw_axes__, David Bateman, 2007/11/06
- Re: improved surface: __go_draw_axes__,
David Bateman <=
- Re: improved surface: __go_draw_axes__, John W. Eaton, 2007/11/07
- Re: improved surface: __go_draw_axes__, David Bateman, 2007/11/07
- Re: improved surface: __go_draw_axes__, John W. Eaton, 2007/11/07
- Re: improved surface: __go_draw_axes__, John W. Eaton, 2007/11/07