changeset 18896:4d75bda5df80

mesh, meshc, surfc: Allow user provided properties to override defaults. * mesh.m, meshc.m, surfc.m: Call underlying graphic primitive with default properties first followed by any user properties second so that they will override the defaults.
author Rik <rik@octave.org>
date Fri, 04 Jul 2014 15:37:42 -0700
parents b8934a57e13e
children f9cf5ae6b8a2
files scripts/plot/draw/mesh.m scripts/plot/draw/meshc.m scripts/plot/draw/surfc.m
diffstat 3 files changed, 36 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/draw/mesh.m	Fri Jul 04 14:32:49 2014 -0700
+++ b/scripts/plot/draw/mesh.m	Fri Jul 04 15:37:42 2014 -0700
@@ -70,10 +70,15 @@
   unwind_protect
     hax = newplot (hax);
 
-    htmp = surface (varargin{:});
+    mesh_props = {"facecolor", "w", "edgecolor", "flat"};
+    chararg = find (cellfun ("isclass", varargin, "char"), 1);
+    if (isempty (chararg))
+      htmp = surface (varargin{:}, mesh_props{:});
+    else
+      htmp = surface (varargin{1:chararg-1}, mesh_props{:},
+                      varargin{chararg:end});
+    endif
 
-    set (htmp, "facecolor", "w");
-    set (htmp, "edgecolor", "flat");
     if (! ishold ())
       set (hax, "view", [-37.5, 30],
                 "xgrid", "on", "ygrid", "on", "zgrid", "on");
@@ -125,3 +130,14 @@
 %!   title ({'Gnuplot: mesh color is wrong', 'This is a Gnuplot bug'});
 %! endif
 
+%!demo
+%! clf;
+%! x = logspace (0,1,11);
+%! z = x'*x;
+%! mesh (x, x, z, 'facecolor', 'none', 'edgecolor', 'c');
+%! xlabel 'X-axis';
+%! ylabel 'Y-axis';
+%! zlabel 'Z-axis';
+%! title ({'mesh() default properties overriden', ...
+%!         'transparent mesh with cyan color'});
+
--- a/scripts/plot/draw/meshc.m	Fri Jul 04 14:32:49 2014 -0700
+++ b/scripts/plot/draw/meshc.m	Fri Jul 04 15:37:42 2014 -0700
@@ -68,13 +68,18 @@
   unwind_protect
     hax = newplot (hax);
 
-    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");
+    mesh_props = {"facecolor", "w", "edgecolor", "flat"};
+    chararg = find (cellfun ("isclass", varargin, "char"), 1);
+    if (isempty (chararg))
+      htmp = surface (varargin{:}, mesh_props{:});
+    else
+      htmp = surface (varargin{1:chararg-1}, mesh_props{:},
+                      varargin{chararg:end});
+    endif
+
     if (! ishold ())
       set (hax, "view", [-37.5, 30],
                 "xgrid", "on", "ygrid", "on", "zgrid", "on",
--- a/scripts/plot/draw/surfc.m	Fri Jul 04 14:32:49 2014 -0700
+++ b/scripts/plot/draw/surfc.m	Fri Jul 04 15:37:42 2014 -0700
@@ -71,9 +71,15 @@
   unwind_protect
     hax = newplot (hax);
     
-    htmp = surface (varargin{:});
+    surfc_props = {"facecolor", "flat"};
+    chararg = find (cellfun ("isclass", varargin, "char"), 1);
+    if (isempty (chararg))
+      htmp = surface (varargin{:}, surfc_props{:});
+    else
+      htmp = surface (varargin{1:chararg-1}, surfc_props{:},
+                      varargin{chararg:end});
+    endif
 
-    set (htmp, "facecolor", "flat");
     if (! ishold ())
       set (hax, "view", [-37.5, 30],
                 "xgrid", "on", "ygrid", "on", "zgrid", "on",