diff scripts/plot/gnuplot_drawnow.m @ 11246:c463aed850b0

allow legend and gcf to work when no figure is present
author John W. Eaton <jwe@octave.org>
date Sat, 13 Nov 2010 01:25:05 -0500
parents 9f080d23396f
children acebc0e675c1
line wrap: on
line diff
--- a/scripts/plot/gnuplot_drawnow.m	Fri Nov 12 20:53:32 2010 -0500
+++ b/scripts/plot/gnuplot_drawnow.m	Sat Nov 13 01:25:05 2010 -0500
@@ -302,9 +302,9 @@
     fputs (plot_stream, "unset multiplot;\n");
     flickering_terms = {"x11", "windows", "wxt", "dumb"};
     if (! any (strcmp (term, flickering_terms))
-        || (numel (findall (h, "type", "axes")) -
-            sum (strcmp (get (findall (h, "type", "axes"), "tag"), "legend"))) > 1
+        || have_non_legend_axes (h)
         || numel (findall (h, "type", "image")) > 0)
+1
       fprintf (plot_stream, "%s\n", term_str);
       if (nargin == 5)
         if (! isempty (file))
@@ -377,4 +377,16 @@
   ret = any (strcmpi ({"aqua", "dumb", "wxt", "x11", "windows", "pm"}, term));
 endfunction
 
-
+function retval = have_non_legend_axes (h)
+  retval = false;
+  all_axes = findall (h, "type", "axes");
+  if (! isempty (all_axes))
+    n_all_axes = numel (all_axes);
+    all_axes_tags = get (all_axes, "tag");
+    legend_axes = strcmp (all_axes_tags, "legend");
+    if (! isempty (legend_axes))
+      n_legend_axes = sum (legend_axes);
+      retval = (n_all_axes - n_legend_axes) > 1;
+    endif
+  endif
+endfunction