# HG changeset patch # User Ben Abbott # Date 1249536634 -7200 # Node ID b50d1eb627475554904f13271e1863f8debf9518 # Parent f3bf489b73228254129c76b299cf92bf506dfd60 Avoid the flickering x11 window seen with rapid gnuplot updates. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2009-08-02 Ben Abbott + + * 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 * plot/__go_draw_axes__.m: Fix ticklabels specified as 2D character diff --git a/scripts/plot/__go_draw_figure__.m b/scripts/plot/__go_draw_figure__.m --- 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); diff --git a/scripts/plot/gnuplot_drawnow.m b/scripts/plot/gnuplot_drawnow.m --- 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