# HG changeset patch # User jwe # Date 1163530359 0 # Node ID 8614649c454cda2cc971f3f15c90fe8558e9f6de # Parent b3c425131211134d7aea27b129e4b30ed0ce2925 [project @ 2006-11-14 18:52:34 by jwe] diff -r b3c425131211 -r 8614649c454c scripts/ChangeLog --- a/scripts/ChangeLog Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/ChangeLog Tue Nov 14 18:52:39 2006 +0000 @@ -1,3 +1,13 @@ +2006-11-14 John W. Eaton + + * plot/__do_legend__.m, plot/__errplot__.m, + plot/__init_plot_vars__.m, plot/__plot_globals__.m, + plot/__plt3__.m, plot/__plt__.m, plot/__setup_plot__.m, + plot/legend.m, plot/mplot.m, plot/multiplot.m, plot/oneplot.m, + plot/replot.m, plot/subplot.m, plot/subwindow.m: + Use __plot_globals__ for multiplot variables. Keep track of + multiplot info for each figure. Eliminate __multiplot_xscale__. + 2006-11-13 John W. Eaton * plot/mesh.m: Use proper dimensions for y in call to repmat. diff -r b3c425131211 -r 8614649c454c scripts/plot/__do_legend__.m --- a/scripts/plot/__do_legend__.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/__do_legend__.m Tue Nov 14 18:52:39 2006 +0000 @@ -3,8 +3,8 @@ __plot_globals__; cf = __current_figure__; - mxi = __multiplot_xi__; - myi = __multiplot_yi__; + mxi = __multiplot_xi__(cf); + myi = __multiplot_yi__(cf); props = __plot_key_properties__{cf}{mxi,myi}; diff -r b3c425131211 -r 8614649c454c scripts/plot/__errplot__.m --- a/scripts/plot/__errplot__.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/__errplot__.m Tue Nov 14 18:52:39 2006 +0000 @@ -38,8 +38,8 @@ __plot_globals__; cf = __current_figure__; - mxi = __multiplot_xi__; - myi = __multiplot_yi__; + mxi = __multiplot_xi__(cf); + myi = __multiplot_yi__(cf); __setup_plot__ ("__gnuplot_plot__"); @@ -89,7 +89,7 @@ __plot_data__{cf}{mxi,myi}{j} = tmp; __plot_command__{cf}{mxi,myi} \ - = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s %s __plot_key_labels__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}", + = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)}{%d} %s %s __plot_key_labels__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)}{%d}", __plot_command__{cf}{mxi,myi}, __plot_command_sep__, j, ifmt, gnuplot_command_title, loff); @@ -104,7 +104,7 @@ __plot_line_offset__{cf}(mxi,myi) = loff; if (! isempty (__plot_command__{cf}{mxi,myi})) - if (__multiplot_mode__) + if (__multiplot_mode__(cf)) __gnuplot_raw__ ("clear\n"); endif __do_legend__ (); diff -r b3c425131211 -r 8614649c454c scripts/plot/__init_plot_vars__.m --- a/scripts/plot/__init_plot_vars__.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/__init_plot_vars__.m Tue Nov 14 18:52:39 2006 +0000 @@ -22,8 +22,8 @@ __plot_globals__; cf = __current_figure__; - mxi = __multiplot_xi__; - myi = __multiplot_yi__; + mxi = __multiplot_xi__(cf); + myi = __multiplot_yi__(cf); if (nargin < 3) clear_data = true; diff -r b3c425131211 -r 8614649c454c scripts/plot/__plot_globals__.m --- a/scripts/plot/__plot_globals__.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/__plot_globals__.m Tue Nov 14 18:52:39 2006 +0000 @@ -21,27 +21,6 @@ ## global variables to keep track of multiplot options -global __multiplot_mode__ = 0; -global __multiplot_xsize__; -global __multiplot_ysize__; -global __multiplot_xn__; -global __multiplot_yn__; -global __multiplot_xi__; -global __multiplot_yi__; -global __multiplot_scale__; - -if (isempty (__multiplot_scale__)) - __multiplot_scale__ = [1, 1]; -endif - -if (isempty (__multiplot_xi__)) - __multiplot_xi__ = 1; -endif - -if (isempty (__multiplot_yi__)) - __multiplot_yi__ = 1; -endif - global __current_figure__; global __plot_data_offset__; global __plot_line_offset__; @@ -50,39 +29,74 @@ global __plot_data__; global __plot_key_labels__; global __plot_key_properties__; +global __multiplot_mode__; +global __multiplot_xsize__; +global __multiplot_ysize__; +global __multiplot_xn__; +global __multiplot_yn__; +global __multiplot_xi__; +global __multiplot_yi__; if (isempty (__current_figure__)) __current_figure__ = 1; endif +if (length (__multiplot_mode__) < __current_figure__) + __multiplot_mode__(__current_figure__) = false; +endif + +if (length (__multiplot_xsize__) < __current_figure__) + __multiplot_xsize__(__current_figure__) = 1; +endif + +if (length (__multiplot_ysize__) < __current_figure__) + __multiplot_ysize__(__current_figure__) = 1; +endif + +if (length (__multiplot_xn__) < __current_figure__) + __multiplot_xn__(__current_figure__) = 1; +endif + +if (length (__multiplot_yn__) < __current_figure__) + __multiplot_yn__(__current_figure__) = 1; +endif + +if (length (__multiplot_xi__) < __current_figure__) + __multiplot_xi__(__current_figure__) = 1; +endif + +if (length (__multiplot_yi__) < __current_figure__) + __multiplot_yi__(__current_figure__) = 1; +endif + if (length (__plot_data_offset__) < __current_figure__ - || any (size (__plot_data_offset__{__current_figure__}) != [__multiplot_xi__, __multiplot_yi__])) + || any (size (__plot_data_offset__{__current_figure__}) != [__multiplot_xi__(__current_figure__), __multiplot_yi__(__current_figure__)])) - __plot_data_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__) = 1; + __plot_data_offset__{__current_figure__}(__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)) = 1; endif if (length (__plot_line_offset__) < __current_figure__ - || any (size (__plot_line_offset__{__current_figure__}) != [__multiplot_xi__, __multiplot_yi__])) + || any (size (__plot_line_offset__{__current_figure__}) != [__multiplot_xi__(__current_figure__), __multiplot_yi__(__current_figure__)])) - __plot_line_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__) = 1; + __plot_line_offset__{__current_figure__}(__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)) = 1; endif if (length (__plot_command__) < __current_figure__ - || any (size (__plot_command__{__current_figure__}) != [__multiplot_xi__, __multiplot_yi__])) - __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} = ""; + || any (size (__plot_command__{__current_figure__}) != [__multiplot_xi__(__current_figure__), __multiplot_yi__(__current_figure__)])) + __plot_command__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)} = ""; endif if (length (__plot_data__) < __current_figure__ - || any (size (__plot_data__{__current_figure__}) != [__multiplot_xi__, __multiplot_yi__])) - __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} = []; + || any (size (__plot_data__{__current_figure__}) != [__multiplot_xi__(__current_figure__), __multiplot_yi__(__current_figure__)])) + __plot_data__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)} = []; endif if (length (__plot_key_labels__) < __current_figure__ - || any (size (__plot_key_labels__{__current_figure__}) != [__multiplot_xi__, __multiplot_yi__])) - __plot_key_labels__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} = []; + || any (size (__plot_key_labels__{__current_figure__}) != [__multiplot_xi__(__current_figure__), __multiplot_yi__(__current_figure__)])) + __plot_key_labels__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)} = []; endif if (length (__plot_key_properties__) < __current_figure__ - || any (size (__plot_key_properties__{__current_figure__}) != [__multiplot_xi__, __multiplot_yi__])) - __plot_key_properties__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} = struct ("visible", true, "box", false, "position", 0); + || any (size (__plot_key_properties__{__current_figure__}) != [__multiplot_xi__(__current_figure__), __multiplot_yi__(__current_figure__)])) + __plot_key_properties__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)} = struct ("visible", true, "box", false, "position", 0); endif diff -r b3c425131211 -r 8614649c454c scripts/plot/__plt3__.m --- a/scripts/plot/__plt3__.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/__plt3__.m Tue Nov 14 18:52:39 2006 +0000 @@ -54,8 +54,8 @@ __plot_globals__; cf = __current_figure__; - mxi = __multiplot_xi__; - myi = __multiplot_yi__; + mxi = __multiplot_xi__(cf); + myi = __multiplot_yi__(cf); __setup_plot__ ("__gnuplot_splot__"); @@ -71,7 +71,7 @@ endif __plot_command__{cf}{mxi,myi} ... - = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s %s %s __plot_key_labels__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s", + = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)}{%d} %s %s %s __plot_key_labels__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)}{%d} %s", __plot_command__{cf}{mxi,myi}, __plot_command_sep__, j++, usingstr, fmtstr, gnuplot_command_title, loff++, withstr); @@ -80,7 +80,7 @@ __plot_data_offset__{cf}(mxi,myi) = j; __plot_line_offset__{cf}(mxi,myi) = loff; - if (__multiplot_mode__) + if (__multiplot_mode__(cf)) __gnuplot_raw__ ("clear\n"); endif diff -r b3c425131211 -r 8614649c454c scripts/plot/__plt__.m --- a/scripts/plot/__plt__.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/__plt__.m Tue Nov 14 18:52:39 2006 +0000 @@ -28,8 +28,8 @@ __plot_globals__; cf = __current_figure__; - mxi = __multiplot_xi__; - myi = __multiplot_yi__; + mxi = __multiplot_xi__(cf); + myi = __multiplot_yi__(cf); __setup_plot__ ("__gnuplot_plot__"); @@ -106,7 +106,7 @@ for i = 1:length (__plot_data__{cf}{mxi,myi}{j}) usingstr = __make_using_clause__ (__plot_data__{cf}{mxi,myi}{j}{i}); __plot_command__{cf}{mxi,myi} ... - = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}{%d} %s %s %s __plot_key_labels__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}", + = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)}{%d}{%d} %s %s %s __plot_key_labels__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)}{%d}", __plot_command__{cf}{mxi,myi}, __plot_command_sep__, j, i, usingstr, fmtstr{i}, gnuplot_command_title, loff++); @@ -120,7 +120,7 @@ __plot_data_offset__{cf}(mxi,myi) = j; __plot_line_offset__{cf}(mxi,myi) = loff; - if (__multiplot_mode__) + if (__multiplot_mode__(cf)) __gnuplot_raw__ ("clear\n"); endif diff -r b3c425131211 -r 8614649c454c scripts/plot/__setup_plot__.m --- a/scripts/plot/__setup_plot__.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/__setup_plot__.m Tue Nov 14 18:52:39 2006 +0000 @@ -21,8 +21,12 @@ __plot_globals__ + cf = __current_figure__; + mxi = __multiplot_xi__(cf); + myi = __multiplot_yi__(cf); + if (ishold ()) - cmd = __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}; + cmd = __plot_command__{cf}{mxi,myi}; if (isempty (cmd)) cmd = plotcmd; sep = ""; diff -r b3c425131211 -r 8614649c454c scripts/plot/legend.m --- a/scripts/plot/legend.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/legend.m Tue Nov 14 18:52:39 2006 +0000 @@ -75,8 +75,8 @@ __plot_globals__; cf = __current_figure__; - mxi = __multiplot_xi__; - myi = __multiplot_yi__; + mxi = __multiplot_xi__(cf); + myi = __multiplot_yi__(cf); nargs = nargin; diff -r b3c425131211 -r 8614649c454c scripts/plot/mplot.m --- a/scripts/plot/mplot.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/mplot.m Tue Nov 14 18:52:39 2006 +0000 @@ -34,15 +34,9 @@ function mplot (varargin) - ## global variables to keep track of multiplot options + __plot_globals__; - global __multiplot_mode__ = 0; - global __multiplot_xsize__; - global __multiplot_ysize__; - global __multiplot_xn__; - global __multiplot_yn__; - global __multiplot_xi__; - global __multiplot_yi__; + cf = __current_figure__; __gnuplot_raw__ ("set nologscale;\n"); __gnuplot_raw__ ("set nopolar;\n"); @@ -51,21 +45,21 @@ ## update the plot position - if (__multiplot_mode__) + if (__multiplot_mode__(cf)) - if (__multiplot_xi__ < __multiplot_xn__) - __multiplot_xi__++; + if (__multiplot_xi__(cf) < __multiplot_xn__(cf)) + __multiplot_xi__(cf)++; else - __multiplot_xi__ = 1; - if (__multiplot_yi__ < __multiplot_yn__) - __multiplot_yi__++; + __multiplot_xi__(cf) = 1; + if (__multiplot_yi__(cf) < __multiplot_yn__(cf)) + __multiplot_yi__(cf)++; else - __multiplot_yi__ = 1; + __multiplot_yi__(cf) = 1; endif endif - xo = (__multiplot_xi__ - 1.0) * __multiplot_xsize__; - yo = (__multiplot_yn__ - __multiplot_yi__) * __multiplot_ysize__; + xo = (__multiplot_xi__(cf) - 1.0) * __multiplot_xsize__(cf); + yo = (__multiplot_yn__(cf) - __multiplot_yi__(cf)) * __multiplot_ysize__(cf); __gnuplot_raw__ (sprintf ("set origin %g, %g;\n", xo, yo)); diff -r b3c425131211 -r 8614649c454c scripts/plot/multiplot.m --- a/scripts/plot/multiplot.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/multiplot.m Tue Nov 14 18:52:39 2006 +0000 @@ -33,15 +33,9 @@ function multiplot (xn, yn) - ## global variables to keep track of multiplot options + plot_globals; - global __multiplot_mode__ = 0; - global __multiplot_xsize__; - global __multiplot_ysize__; - global __multiplot_xn__; - global __multiplot_yn__; - global __multiplot_xi__; - global __multiplot_yi__; + cf = __current_figure__; if (nargin != 2) print_usage (); @@ -58,14 +52,12 @@ oneplot (); - ## FIXME -- do we really need to reset these here? - - __multiplot_xsize__ = 1; - __multiplot_ysize__ = 1; - __multiplot_xn__ = 1; - __multiplot_yn__ = 1; - __multiplot_xi__ = 1; - __multiplot_yi__ = 1; + __multiplot_xsize__(cf) = 1; + __multiplot_ysize__(cf) = 1; + __multiplot_xn__(cf) = 1; + __multiplot_yn__(cf) = 1; + __multiplot_xi__(cf) = 1; + __multiplot_yi__(cf) = 1; else @@ -85,13 +77,13 @@ __gnuplot_raw__ (sprintf ("set origin %g, %g;\n", xo, yo)); - __multiplot_mode__ = 1; - __multiplot_xsize__ = xsize; - __multiplot_ysize__ = ysize; - __multiplot_xn__ = xn; - __multiplot_yn__ = yn; - __multiplot_xi__ = 1; - __multiplot_yi__ = 1; + __multiplot_mode__(cf) = true; + __multiplot_xsize__(cf) = xsize; + __multiplot_ysize__(cf) = ysize; + __multiplot_xn__(cf) = xn; + __multiplot_yn__(cf) = yn; + __multiplot_xi__(cf) = 1; + __multiplot_yi__(cf) = 1; gnuplot_command_replot = "cle;rep"; diff -r b3c425131211 -r 8614649c454c scripts/plot/oneplot.m --- a/scripts/plot/oneplot.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/oneplot.m Tue Nov 14 18:52:39 2006 +0000 @@ -28,13 +28,13 @@ function oneplot () - global __multiplot_mode__ = 0; + plot_globals; - if (__multiplot_mode__) + if (__multiplot_mode__(__current_figure__)) __gnuplot_raw__ ("set nomultiplot;\n"); __gnuplot_raw__ ("set size 1, 1;\n"); __gnuplot_raw__ ("set origin 0, 0;\n"); - __multiplot_mode__ = 0; + __multiplot_mode__(__current_figure__) = false; gnuplot_command_replot = "rep"; endif diff -r b3c425131211 -r 8614649c454c scripts/plot/replot.m --- a/scripts/plot/replot.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/replot.m Tue Nov 14 18:52:39 2006 +0000 @@ -28,13 +28,19 @@ __plot_globals__; + cf = __current_figure__; + mpmode = __multiplot_mode__(cf); + mxi = __multiplot_xi__(cf); + myi = __multiplot_yi__(cf); + cmd = __plot_command__{cf}{mxi,myi}; + if (nargin == 0) - if (! isempty (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__})) - if (__multiplot_mode__) + if (! isempty (cmd)) + if (mpmode) __gnuplot_raw__ ("clear\n"); endif __do_legend__ (); - eval (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}); + eval (cmd); endif else print_usage (); diff -r b3c425131211 -r 8614649c454c scripts/plot/subplot.m --- a/scripts/plot/subplot.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/subplot.m Tue Nov 14 18:52:39 2006 +0000 @@ -23,14 +23,6 @@ ## Sets @code{gnuplot} in multiplot mode and plots in location ## given by index (there are @var{cols} by @var{rows} subwindows). ## -## The global variable @var{__multiplot_scale__} should be used when the -## command @code{__gnuplot_set__ size xsize, ysize} has been used prior to calling -## @code{subplot}. -## -## The value of @var{__multiplot_scale__} should be a vector with two -## elements, the first set equal to @var{xsize} and the second to -## @var{ysize}. -## ## Input: ## ## @table @var @@ -85,6 +77,8 @@ __plot_globals__; + cf = __current_figure__; + if (nargin != 3 && nargin != 1) print_usage (); endif @@ -124,42 +118,41 @@ oneplot (); - ## FIXME -- do we really need to reset these here? - - __multiplot_xn__ = 1; - __multiplot_yn__ = 1; + __multiplot_xn__(cf) = 1; + __multiplot_yn__(cf) = 1; else ## doing multiplot plots - if (! __multiplot_mode__ - || __multiplot_xn__ != columns - || __multiplot_yn__ != rows) + if (! __multiplot_mode__(cf) + || __multiplot_xn__(cf) != columns + || __multiplot_yn__(cf) != rows) - __multiplot_mode__ = 1; - __multiplot_xn__ = columns; - __multiplot_yn__ = rows; - __multiplot_xsize__ = __multiplot_scale__(1) ./ columns; - __multiplot_ysize__ = __multiplot_scale__(2) ./ rows; + __multiplot_mode__(cf) = true; + __multiplot_xn__(cf) = columns; + __multiplot_yn__(cf) = rows; + __multiplot_xsize__(cf) = 1 / columns; + __multiplot_ysize__(cf) = 1 / rows; __gnuplot_raw__ ("set multiplot;\n"); __gnuplot_raw__ (sprintf ("set size %g, %g;\n", - __multiplot_xsize__, __multiplot_ysize__)); + __multiplot_xsize__(cf), + __multiplot_ysize__(cf))); endif ## get the sub plot location yp = fix ((index-1)/columns); xp = index - yp*columns - 1; - __multiplot_xi__ = ++xp; - __multiplot_yi__ = ++yp; + __multiplot_xi__(cf) = ++xp; + __multiplot_yi__(cf) = ++yp; ## set the origin - xo = (xp - 1.0) * __multiplot_xsize__; - yo = (rows - yp) * __multiplot_ysize__; + xo = (xp - 1.0) * __multiplot_xsize__(cf); + yo = (rows - yp) * __multiplot_ysize__(cf); __gnuplot_raw__ (sprintf ("set origin %g, %g;\n", xo, yo)); diff -r b3c425131211 -r 8614649c454c scripts/plot/subwindow.m --- a/scripts/plot/subwindow.m Tue Nov 14 15:33:22 2006 +0000 +++ b/scripts/plot/subwindow.m Tue Nov 14 18:52:39 2006 +0000 @@ -31,13 +31,9 @@ function subwindow (xn, yn) - ## global variables to keep track of multiplot options + __plot_globals__; - global __multiplot_mode__ = 0; - global __multiplot_xsize__; - global __multiplot_ysize__; - global __multiplot_xn__; - global __multiplot_yn__; + cf = __current_figure__; ## check calling argument count @@ -57,19 +53,20 @@ ## switch to multiplot mode if not already in, and use the args as the ## args to multiplot() - if (! __multiplot_mode__) + if (! __multiplot_mode__(cf)) multiplot (xn, yn); return; endif ## get the sub plot location - if (xn < 1 || xn > __multiplot_xn__ || yn < 1 || yn > __multiplot_yn__) + if (xn < 1 || xn > __multiplot_xn__(cf) + || yn < 1 || yn > __multiplot_yn__(__currrent_figure__)) error ("subwindow: incorrect xn and yn"); endif - xo = (xn - 1.0) * __multiplot_xsize__; - yo = (__multiplot_yn__ - yn) * __multiplot_ysize__; + xo = (xn - 1.0) * __multiplot_xsize__(cf); + yo = (__multiplot_yn__(cf) - yn) * __multiplot_ysize__(cf); __gnuplot_raw__ (sprintf ("set origin %g, %g;\n", xo, yo));