Avoid the flickering x11 window seen with rapid gnuplot updates.
authorBen Abbott <bpabbott@mac.com>
Thu Aug 06 07:30:34 2009 +0200 (2009-08-06)
changeset 939554a3fa5d4376
parent 9394 f1dd244757cd
child 9396 9107c882f193
Avoid the flickering x11 window seen with rapid gnuplot updates.
scripts/ChangeLog
scripts/plot/__go_draw_figure__.m
scripts/plot/gnuplot_drawnow.m
     1.1 --- a/scripts/ChangeLog	Thu Aug 06 07:18:53 2009 +0200
     1.2 +++ b/scripts/ChangeLog	Thu Aug 06 07:30:34 2009 +0200
     1.3 @@ -1,3 +1,10 @@
     1.4 +2009-08-02  Ben Abbott <bpabbott@mac.com>
     1.5 +
     1.6 +	* plot/gnuplot_drawnow.m: Avoid the flickering x11 window seen with
     1.7 +	rapid replots by avoidng setting multiplot mode. This fix only
     1.8 +	functions for a single axes with no image objects.
     1.9 +	* plot/__go_draw_figure__.m: Move 'set multiplot' to gnuplot_drawnow.
    1.10 +
    1.11  2009-07-29  Ben Abbott <bpabbott@mac.com>
    1.12  
    1.13  	* plot/__go_draw_axes__.m: Fix ticklabels specified as 2D character
     2.1 --- a/scripts/plot/__go_draw_figure__.m	Thu Aug 06 07:18:53 2009 +0200
     2.2 +++ b/scripts/plot/__go_draw_figure__.m	Thu Aug 06 07:30:34 2009 +0200
     2.3 @@ -67,7 +67,6 @@
     2.4        if (nkids > 0)
     2.5  	fputs (plot_stream, "\nreset;\n");
     2.6  	fputs (plot_stream, "set autoscale keepfix;\n");
     2.7 -	fputs (plot_stream, "set multiplot;\n");
     2.8  	fputs (plot_stream, "set origin 0, 0\n");
     2.9  	fputs (plot_stream, "set size 1, 1\n");
    2.10  	for i = 1:nkids
    2.11 @@ -96,7 +95,6 @@
    2.12  	      error ("__go_draw_figure__: unknown object class, %s", type);
    2.13  	  endswitch
    2.14  	endfor
    2.15 -	fputs (plot_stream, "unset multiplot;\n");
    2.16        else
    2.17  	fputs (plot_stream, "\nreset; clear;\n");
    2.18  	fflush (plot_stream);
     3.1 --- a/scripts/plot/gnuplot_drawnow.m	Thu Aug 06 07:18:53 2009 +0200
     3.2 +++ b/scripts/plot/gnuplot_drawnow.m	Thu Aug 06 07:30:34 2009 +0200
     3.3 @@ -266,43 +266,50 @@
     3.4        size_str = "";
     3.5      endif
     3.6  
     3.7 -    ## Set the gnuplot terminal (type, enhanced?, title, & size).
     3.8 -    if (! isempty (term))
     3.9 -      term_str = sprintf ("set terminal %s", term);
    3.10 -      if (any (strncmpi (term, {"x11", "wxt"}, 3)) && new_stream
    3.11 -	  && __gnuplot_has_feature__ ("x11_figure_position"))
    3.12 -        ## The "close" is added to allow the figure position property
    3.13 -        ## to remain active.
    3.14 -        term_str = sprintf ("%s close", term_str);
    3.15 +    ## Set the gnuplot terminal (type, enhanced, title, options & size).
    3.16 +    term_str = sprintf ("set terminal %s", term);
    3.17 +    if (! isempty (enh_str))
    3.18 +      term_str = sprintf ("%s %s", term_str, enh_str);
    3.19 +    endif
    3.20 +    if (! isempty (title_str))
    3.21 +      term_str = sprintf ("%s %s", term_str, title_str);
    3.22 +    endif
    3.23 +    if (nargin > 3 && ischar (opts_str))
    3.24 +      ## Options must go last.
    3.25 +      term_str = sprintf ("%s %s", term_str, opts_str);
    3.26 +    endif
    3.27 +    if (! isempty (size_str) && new_stream)
    3.28 +      ## size_str comes after other options to permit specification of
    3.29 +      ## the canvas size for terminals cdr/corel.
    3.30 +      term_str = sprintf ("%s %s", term_str, size_str);
    3.31 +    endif
    3.32 +    ## Work around the gnuplot feature of growing the x11 window when
    3.33 +    ## the mouse and multiplot are set.
    3.34 +    fputs (plot_stream, "unset multiplot;\n");
    3.35 +    if (! strcmp (term, "x11")
    3.36 +        || numel (findall (h, "type", "axes")) > 1
    3.37 +        || numel (findall (h, "type", "image")) > 0)
    3.38 +      fprintf (plot_stream, "%s\n", term_str);
    3.39 +      if (nargin == 5)
    3.40 +        if (! isempty (file))
    3.41 +          fprintf (plot_stream, "set output '%s';\n", file);
    3.42 +        endif
    3.43        endif
    3.44 -      if (! isempty (enh_str))
    3.45 -        term_str = sprintf ("%s %s", term_str, enh_str);
    3.46 +      fputs (plot_stream, "set multiplot;\n");
    3.47 +    elseif (strcmp (term, "x11"))
    3.48 +      fprintf (plot_stream, "%s\n", term_str);
    3.49 +      if (nargin == 5)
    3.50 +        if (! isempty (file))
    3.51 +          fprintf (plot_stream, "set output '%s';\n", file);
    3.52 +        endif
    3.53        endif
    3.54 -      if (! isempty (title_str))
    3.55 -        term_str = sprintf ("%s %s", term_str, title_str);
    3.56 -      endif
    3.57 -      if (nargin > 3 && ischar (opts_str))
    3.58 -        ## Options must go last.
    3.59 -        term_str = sprintf ("%s %s", term_str, opts_str);
    3.60 -      endif
    3.61 -      if (! isempty (size_str) && new_stream)
    3.62 -        ## size_str goes last to permit specification of canvas size
    3.63 -        ## for terminals cdr/corel.
    3.64 -        term_str = sprintf ("%s %s", term_str, size_str);
    3.65 -      endif
    3.66 -      fprintf (plot_stream, "%s\n", term_str);
    3.67 -    else
    3.68 -      ## gnuplot will pick up the GNUTERM environment variable itself
    3.69 -      ## so no need to set the terminal type if not also setting the
    3.70 -      ## figure title, enhanced mode, or position.
    3.71      endif
    3.72 +  else
    3.73 +    ## gnuplot will pick up the GNUTERM environment variable itself
    3.74 +    ## so no need to set the terminal type if not also setting the
    3.75 +    ## figure title, enhanced mode, or position.
    3.76    endif
    3.77  
    3.78 -  if (nargin == 5)
    3.79 -    if (! isempty (file))
    3.80 -      fprintf (plot_stream, "set output '%s';\n", file);
    3.81 -    endif
    3.82 -  endif
    3.83  
    3.84  endfunction
    3.85