changeset 12052:b50d1eb62747 release-3-2-x

Avoid the flickering x11 window seen with rapid gnuplot updates.
author Ben Abbott <bpabbott@mac.com>
date Thu, 06 Aug 2009 07:30:34 +0200
parents f3bf489b7322
children 1740ac0eb9c2
files scripts/ChangeLog scripts/plot/__go_draw_figure__.m scripts/plot/gnuplot_drawnow.m
diffstat 3 files changed, 46 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-02  Ben Abbott <bpabbott@mac.com>
+
+	* plot/gnuplot_drawnow.m: Avoid the flickering x11 window seen with
+	rapid replots by avoidng setting multiplot mode. This fix only
+	functions for a single axes with no image objects.
+	* plot/__go_draw_figure__.m: Move 'set multiplot' to gnuplot_drawnow.
+
 2009-07-29  Ben Abbott <bpabbott@mac.com>
 
 	* plot/__go_draw_axes__.m: Fix ticklabels specified as 2D character
--- a/scripts/plot/__go_draw_figure__.m
+++ b/scripts/plot/__go_draw_figure__.m
@@ -67,7 +67,6 @@
       if (nkids > 0)
 	fputs (plot_stream, "\nreset;\n");
 	fputs (plot_stream, "set autoscale keepfix;\n");
-	fputs (plot_stream, "set multiplot;\n");
 	fputs (plot_stream, "set origin 0, 0\n");
 	fputs (plot_stream, "set size 1, 1\n");
 	for i = 1:nkids
@@ -96,7 +95,6 @@
 	      error ("__go_draw_figure__: unknown object class, %s", type);
 	  endswitch
 	endfor
-	fputs (plot_stream, "unset multiplot;\n");
       else
 	fputs (plot_stream, "\nreset; clear;\n");
 	fflush (plot_stream);
--- a/scripts/plot/gnuplot_drawnow.m
+++ b/scripts/plot/gnuplot_drawnow.m
@@ -266,43 +266,50 @@
       size_str = "";
     endif
 
-    ## Set the gnuplot terminal (type, enhanced?, title, & size).
-    if (! isempty (term))
-      term_str = sprintf ("set terminal %s", term);
-      if (any (strncmpi (term, {"x11", "wxt"}, 3)) && new_stream
-	  && __gnuplot_has_feature__ ("x11_figure_position"))
-        ## The "close" is added to allow the figure position property
-        ## to remain active.
-        term_str = sprintf ("%s close", term_str);
-      endif
-      if (! isempty (enh_str))
-        term_str = sprintf ("%s %s", term_str, enh_str);
-      endif
-      if (! isempty (title_str))
-        term_str = sprintf ("%s %s", term_str, title_str);
+    ## Set the gnuplot terminal (type, enhanced, title, options & size).
+    term_str = sprintf ("set terminal %s", term);
+    if (! isempty (enh_str))
+      term_str = sprintf ("%s %s", term_str, enh_str);
+    endif
+    if (! isempty (title_str))
+      term_str = sprintf ("%s %s", term_str, title_str);
+    endif
+    if (nargin > 3 && ischar (opts_str))
+      ## Options must go last.
+      term_str = sprintf ("%s %s", term_str, opts_str);
+    endif
+    if (! isempty (size_str) && new_stream)
+      ## size_str comes after other options to permit specification of
+      ## the canvas size for terminals cdr/corel.
+      term_str = sprintf ("%s %s", term_str, size_str);
+    endif
+    ## Work around the gnuplot feature of growing the x11 window when
+    ## the mouse and multiplot are set.
+    fputs (plot_stream, "unset multiplot;\n");
+    if (! strcmp (term, "x11")
+        || numel (findall (h, "type", "axes")) > 1
+        || numel (findall (h, "type", "image")) > 0)
+      fprintf (plot_stream, "%s\n", term_str);
+      if (nargin == 5)
+        if (! isempty (file))
+          fprintf (plot_stream, "set output '%s';\n", file);
+        endif
       endif
-      if (nargin > 3 && ischar (opts_str))
-        ## Options must go last.
-        term_str = sprintf ("%s %s", term_str, opts_str);
+      fputs (plot_stream, "set multiplot;\n");
+    elseif (strcmp (term, "x11"))
+      fprintf (plot_stream, "%s\n", term_str);
+      if (nargin == 5)
+        if (! isempty (file))
+          fprintf (plot_stream, "set output '%s';\n", file);
+        endif
       endif
-      if (! isempty (size_str) && new_stream)
-        ## size_str goes last to permit specification of canvas size
-        ## for terminals cdr/corel.
-        term_str = sprintf ("%s %s", term_str, size_str);
-      endif
-      fprintf (plot_stream, "%s\n", term_str);
-    else
-      ## gnuplot will pick up the GNUTERM environment variable itself
-      ## so no need to set the terminal type if not also setting the
-      ## figure title, enhanced mode, or position.
     endif
+  else
+    ## gnuplot will pick up the GNUTERM environment variable itself
+    ## so no need to set the terminal type if not also setting the
+    ## figure title, enhanced mode, or position.
   endif
 
-  if (nargin == 5)
-    if (! isempty (file))
-      fprintf (plot_stream, "set output '%s';\n", file);
-    endif
-  endif
 
 endfunction