comparison scripts/plot/subplot.m @ 6163:8614649c454c

[project @ 2006-11-14 18:52:34 by jwe]
author jwe
date Tue, 14 Nov 2006 18:52:39 +0000
parents 34f96dd5441b
children 830235f4984f
comparison
equal deleted inserted replaced
6162:b3c425131211 6163:8614649c454c
20 ## -*- texinfo -*- 20 ## -*- texinfo -*-
21 ## @deftypefn {Function File} {} subplot (@var{rows}, @var{cols}, @var{index}) 21 ## @deftypefn {Function File} {} subplot (@var{rows}, @var{cols}, @var{index})
22 ## @deftypefnx {Function File} {} subplot (@var{rcn}) 22 ## @deftypefnx {Function File} {} subplot (@var{rcn})
23 ## Sets @code{gnuplot} in multiplot mode and plots in location 23 ## Sets @code{gnuplot} in multiplot mode and plots in location
24 ## given by index (there are @var{cols} by @var{rows} subwindows). 24 ## given by index (there are @var{cols} by @var{rows} subwindows).
25 ##
26 ## The global variable @var{__multiplot_scale__} should be used when the
27 ## command @code{__gnuplot_set__ size xsize, ysize} has been used prior to calling
28 ## @code{subplot}.
29 ##
30 ## The value of @var{__multiplot_scale__} should be a vector with two
31 ## elements, the first set equal to @var{xsize} and the second to
32 ## @var{ysize}.
33 ## 25 ##
34 ## Input: 26 ## Input:
35 ## 27 ##
36 ## @table @var 28 ## @table @var
37 ## @item rows 29 ## @item rows
83 75
84 function subplot (rows, columns, index) 76 function subplot (rows, columns, index)
85 77
86 __plot_globals__; 78 __plot_globals__;
87 79
80 cf = __current_figure__;
81
88 if (nargin != 3 && nargin != 1) 82 if (nargin != 3 && nargin != 1)
89 print_usage (); 83 print_usage ();
90 endif 84 endif
91 85
92 if (nargin == 1) 86 if (nargin == 1)
122 116
123 ## switching to single plot ? 117 ## switching to single plot ?
124 118
125 oneplot (); 119 oneplot ();
126 120
127 ## FIXME -- do we really need to reset these here? 121 __multiplot_xn__(cf) = 1;
128 122 __multiplot_yn__(cf) = 1;
129 __multiplot_xn__ = 1;
130 __multiplot_yn__ = 1;
131 123
132 else 124 else
133 125
134 ## doing multiplot plots 126 ## doing multiplot plots
135 127
136 if (! __multiplot_mode__ 128 if (! __multiplot_mode__(cf)
137 || __multiplot_xn__ != columns 129 || __multiplot_xn__(cf) != columns
138 || __multiplot_yn__ != rows) 130 || __multiplot_yn__(cf) != rows)
139 131
140 __multiplot_mode__ = 1; 132 __multiplot_mode__(cf) = true;
141 __multiplot_xn__ = columns; 133 __multiplot_xn__(cf) = columns;
142 __multiplot_yn__ = rows; 134 __multiplot_yn__(cf) = rows;
143 __multiplot_xsize__ = __multiplot_scale__(1) ./ columns; 135 __multiplot_xsize__(cf) = 1 / columns;
144 __multiplot_ysize__ = __multiplot_scale__(2) ./ rows; 136 __multiplot_ysize__(cf) = 1 / rows;
145 137
146 __gnuplot_raw__ ("set multiplot;\n"); 138 __gnuplot_raw__ ("set multiplot;\n");
147 139
148 __gnuplot_raw__ (sprintf ("set size %g, %g;\n", 140 __gnuplot_raw__ (sprintf ("set size %g, %g;\n",
149 __multiplot_xsize__, __multiplot_ysize__)); 141 __multiplot_xsize__(cf),
142 __multiplot_ysize__(cf)));
150 endif 143 endif
151 144
152 ## get the sub plot location 145 ## get the sub plot location
153 146
154 yp = fix ((index-1)/columns); 147 yp = fix ((index-1)/columns);
155 xp = index - yp*columns - 1; 148 xp = index - yp*columns - 1;
156 __multiplot_xi__ = ++xp; 149 __multiplot_xi__(cf) = ++xp;
157 __multiplot_yi__ = ++yp; 150 __multiplot_yi__(cf) = ++yp;
158 151
159 ## set the origin 152 ## set the origin
160 153
161 xo = (xp - 1.0) * __multiplot_xsize__; 154 xo = (xp - 1.0) * __multiplot_xsize__(cf);
162 yo = (rows - yp) * __multiplot_ysize__; 155 yo = (rows - yp) * __multiplot_ysize__(cf);
163 156
164 __gnuplot_raw__ (sprintf ("set origin %g, %g;\n", xo, yo)); 157 __gnuplot_raw__ (sprintf ("set origin %g, %g;\n", xo, yo));
165 158
166 endif 159 endif
167 160