Avoid the flickering x11 window seen with rapid gnuplot updates.
authorBen Abbott <bpabbott@mac.com>
Thu Aug 06 07:30:34 2009 +0200 (7 months ago)
changeset 939554a3fa5d4376
parent 9394f1dd244757cd
child 93969107c882f193
Avoid the flickering x11 window seen with rapid gnuplot updates.
scripts/ChangeLog
scripts/plot/__go_draw_figure__.m
scripts/plot/gnuplot_drawnow.m
       1 --- a/scripts/ChangeLog	Thu Aug 06 07:18:53 2009 +0200
       2 +++ b/scripts/ChangeLog	Thu Aug 06 07:30:34 2009 +0200
       3 @@ -1,3 +1,10 @@
       4 +2009-08-02  Ben Abbott <bpabbott@mac.com>
       5 +
       6 +	* plot/gnuplot_drawnow.m: Avoid the flickering x11 window seen with
       7 +	rapid replots by avoidng setting multiplot mode. This fix only
       8 +	functions for a single axes with no image objects.
       9 +	* plot/__go_draw_figure__.m: Move 'set multiplot' to gnuplot_drawnow.
      10 +
      11  2009-07-29  Ben Abbott <bpabbott@mac.com>
      12  
      13  	* plot/__go_draw_axes__.m: Fix ticklabels specified as 2D character
     1.1 --- a/scripts/plot/__go_draw_figure__.m	Thu Aug 06 07:18:53 2009 +0200
     1.2 +++ b/scripts/plot/__go_draw_figure__.m	Thu Aug 06 07:30:34 2009 +0200
     1.3 @@ -67,7 +67,6 @@
     1.4        if (nkids > 0)
     1.5  	fputs (plot_stream, "\nreset;\n");
     1.6  	fputs (plot_stream, "set autoscale keepfix;\n");
     1.7 -	fputs (plot_stream, "set multiplot;\n");
     1.8  	fputs (plot_stream, "set origin 0, 0\n");
     1.9  	fputs (plot_stream, "set size 1, 1\n");
    1.10  	for i = 1:nkids
    1.11 @@ -96,7 +95,6 @@
    1.12  	      error ("__go_draw_figure__: unknown object class, %s", type);
    1.13  	  endswitch
    1.14  	endfor
    1.15 -	fputs (plot_stream, "unset multiplot;\n");
    1.16        else
    1.17  	fputs (plot_stream, "\nreset; clear;\n");
    1.18  	fflush (plot_stream);
     2.1 --- a/scripts/plot/gnuplot_drawnow.m	Thu Aug 06 07:18:53 2009 +0200
     2.2 +++ b/scripts/plot/gnuplot_drawnow.m	Thu Aug 06 07:30:34 2009 +0200
     2.3 @@ -266,43 +266,50 @@
     2.4        size_str = "";
     2.5      endif
     2.6  
     2.7 -    ## Set the gnuplot terminal (type, enhanced?, title, & size).
     2.8 -    if (! isempty (term))
     2.9 -      term_str = sprintf ("set terminal %s", term);
    2.10 -      if (any (strncmpi (term, {"x11", "wxt"}, 3)) && new_stream
    2.11 -	  && __gnuplot_has_feature__ ("x11_figure_position"))
    2.12 -        ## The "close" is added to allow the figure position property
    2.13 -        ## to remain active.
    2.14 -        term_str = sprintf ("%s close", term_str);
    2.15 +    ## Set the gnuplot terminal (type, enhanced, title, options & size).
    2.16 +    term_str = sprintf ("set terminal %s", term);
    2.17 +    if (! isempty (enh_str))
    2.18 +      term_str = sprintf ("%s %s", term_str, enh_str);
    2.19 +    endif
    2.20 +    if (! isempty (title_str))
    2.21 +      term_str = sprintf ("%s %s", term_str, title_str);
    2.22 +    endif
    2.23 +    if (nargin > 3 && ischar (opts_str))
    2.24 +      ## Options must go last.
    2.25 +      term_str = sprintf ("%s %s", term_str, opts_str);
    2.26 +    endif
    2.27 +    if (! isempty (size_str) && new_stream)
    2.28 +      ## size_str comes after other options to permit specification of
    2.29 +      ## the canvas size for terminals cdr/corel.
    2.30 +      term_str = sprintf ("%s %s", term_str, size_str);
    2.31 +    endif
    2.32 +    ## Work around the gnuplot feature of growing the x11 window when
    2.33 +    ## the mouse and multiplot are set.
    2.34 +    fputs (plot_stream, "unset multiplot;\n");
    2.35 +    if (! strcmp (term, "x11")
    2.36 +        || numel (findall (h, "type", "axes")) > 1
    2.37 +        || numel (findall (h, "type", "image")) > 0)
    2.38 +      fprintf (plot_stream, "%s\n", term_str);
    2.39 +      if (nargin == 5)
    2.40 +        if (! isempty (file))
    2.41 +          fprintf (plot_stream, "set output '%s';\n", file);
    2.42 +        endif
    2.43        endif
    2.44 -      if (! isempty (enh_str))
    2.45 -        term_str = sprintf ("%s %s", term_str, enh_str);
    2.46 +      fputs (plot_stream, "set multiplot;\n");
    2.47 +    elseif (strcmp (term, "x11"))
    2.48 +      fprintf (plot_stream, "%s\n", term_str);
    2.49 +      if (nargin == 5)
    2.50 +        if (! isempty (file))
    2.51 +          fprintf (plot_stream, "set output '%s';\n", file);
    2.52 +        endif
    2.53        endif
    2.54 -      if (! isempty (title_str))
    2.55 -        term_str = sprintf ("%s %s", term_str, title_str);
    2.56 -      endif
    2.57 -      if (nargin > 3 && ischar (opts_str))
    2.58 -        ## Options must go last.
    2.59 -        term_str = sprintf ("%s %s", term_str, opts_str);
    2.60 -      endif
    2.61 -      if (! isempty (size_str) && new_stream)
    2.62 -        ## size_str goes last to permit specification of canvas size
    2.63 -        ## for terminals cdr/corel.
    2.64 -        term_str = sprintf ("%s %s", term_str, size_str);
    2.65 -      endif
    2.66 -      fprintf (plot_stream, "%s\n", term_str);
    2.67 -    else
    2.68 -      ## gnuplot will pick up the GNUTERM environment variable itself
    2.69 -      ## so no need to set the terminal type if not also setting the
    2.70 -      ## figure title, enhanced mode, or position.
    2.71      endif
    2.72 +  else
    2.73 +    ## gnuplot will pick up the GNUTERM environment variable itself
    2.74 +    ## so no need to set the terminal type if not also setting the
    2.75 +    ## figure title, enhanced mode, or position.
    2.76    endif
    2.77  
    2.78 -  if (nargin == 5)
    2.79 -    if (! isempty (file))
    2.80 -      fprintf (plot_stream, "set output '%s';\n", file);
    2.81 -    endif
    2.82 -  endif
    2.83  
    2.84  endfunction
    2.85