Mercurial > hg > octave-lyh
comparison scripts/plot/subplot.m @ 1541:47bd45a30dda
[project @ 1995-10-06 03:40:11 by jwe]
author | jwe |
---|---|
date | Fri, 06 Oct 1995 03:40:11 +0000 |
parents | 749b8b19733f |
children | c694fe5956e3 |
comparison
equal
deleted
inserted
replaced
1540:749b8b19733f | 1541:47bd45a30dda |
---|---|
58 # Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU | 58 # Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU |
59 | 59 |
60 # global variables to keep track of multiplot options | 60 # global variables to keep track of multiplot options |
61 | 61 |
62 global multiplot_mode | 62 global multiplot_mode |
63 global multi_xsize multi_ysize | 63 global multiplot_xsize multiplot_ysize |
64 global multi_xn multi_yn | 64 global multiplot_xn multiplot_yn |
65 global multi_xi multi_yi | 65 global multiplot_xi multiplot_yi |
66 | 66 |
67 # This is a real kludge. We gnuplot should be made so that replot can | 67 # This is a real kludge. We gnuplot should be made so that replot can |
68 # be executed while doing multiple plots... | 68 # be executed while doing multiple plots... |
69 | 69 |
70 global multiplot_save_auto_replot = automatic_replot | 70 global multiplot_save_auto_replot = automatic_replot |
80 automatic_replot = 0; | 80 automatic_replot = 0; |
81 endif | 81 endif |
82 | 82 |
83 if (nargin == 1) | 83 if (nargin == 1) |
84 | 84 |
85 if (! is_scalar (rows)) | 85 if (! (is_scalar (rows) && rows >= 0)) |
86 error ("subplot: input rcn has to be a scalar"); | 86 error ("subplot: input rcn has to be a positive scalar"); |
87 endif | 87 endif |
88 | 88 |
89 xnp = rows; | 89 tmp = rows; |
90 rows = round (xnp/100); | 90 index = rem (tmp, 10); |
91 columns = round ((xnp - 100*rows)/10); | 91 tmp = (tmp - index) / 10; |
92 index = xnp - 10*columns - 100*rows; | 92 columns = rem (tmp, 10); |
93 tmp = (tmp - columns) / 10; | |
94 rows = rem (tmp, 10); | |
93 | 95 |
94 elseif (! (is_scalar (columns) && is_scalar (rows) && is_scalar (index))) | 96 elseif (! (is_scalar (columns) && is_scalar (rows) && is_scalar (index))) |
95 error ("subplot: columns, rows, and index have to be scalars"); | 97 error ("subplot: columns, rows, and index have to be scalars"); |
96 endif | 98 endif |
97 | 99 |
113 | 115 |
114 set nomultiplot; | 116 set nomultiplot; |
115 set size 1,1 | 117 set size 1,1 |
116 set origin 0,0 | 118 set origin 0,0 |
117 | 119 |
118 multi_xn = 1; | 120 multiplot_xn = 1; |
119 multi_yn = 1; | 121 multiplot_yn = 1; |
120 multiplot_mode = 0; | 122 multiplot_mode = 0; |
121 | 123 |
122 # Someone may have reset it betweeen calls... | 124 # Someone may have reset it betweeen calls... |
123 | 125 |
124 if (! isstr (automatic_replot) && ! automatic_replot) | 126 if (! isstr (automatic_replot) && ! automatic_replot) |
125 automatic_replot = multiplot_save_auto_replot; | 127 automatic_replot = multiplot_save_auto_replot; |
126 endif | 128 endif |
127 | 129 |
128 return; | 130 else |
131 | |
132 # doing multiplot plots | |
133 | |
134 doagain = 0; | |
135 | |
136 if (exist ("multiplot_mode") != 1) | |
137 doagain = 1; | |
138 elseif (multiplot_mode != 1 || multiplot_xn != columns | |
139 || multiplot_yn != rows) | |
140 doagain = 1; | |
141 endif | |
142 | |
143 if (doagain) | |
144 | |
145 multiplot_mode = 1; | |
146 multiplot_xn = columns; | |
147 multiplot_yn = rows; | |
148 multiplot_xsize = 1.0 ./ columns; | |
149 multiplot_ysize = 1.0 ./ rows; | |
150 | |
151 set multiplot; | |
152 | |
153 eval (sprintf ("set size %g, %g", multiplot_xsize, multiplot_ysize)); | |
154 | |
155 endif | |
156 | |
157 # get the sub plot location | |
158 | |
159 yp = fix ((index-1)/columns); | |
160 xp = index - yp*columns - 1; | |
161 multiplot_xi = ++xp; | |
162 multiplot_yi = ++yp; | |
163 | |
164 # set the origin | |
165 | |
166 xo = (xp - 1.0)*multiplot_xsize; | |
167 yo = (rows - yp)*multiplot_ysize; | |
168 | |
169 eval (sprintf ("set origin %g, %g", xo, yo)); | |
129 | 170 |
130 endif | 171 endif |
131 | 172 |
132 # doing multiplot plots | |
133 | |
134 doagain = 0; | |
135 | |
136 if (exist ("multiplot_mode") != 1) | |
137 doagain = 1; | |
138 elseif (multiplot_mode != 1 || multi_xn != columns || multi_yn != rows) | |
139 doagain = 1; | |
140 endif | |
141 | |
142 if (doagain) | |
143 | |
144 multiplot_mode = 1; | |
145 multi_xn = columns; | |
146 multi_yn = rows; | |
147 multi_xsize = 1.0 ./ columns; | |
148 multi_ysize = 1.0 ./ rows; | |
149 | |
150 set multiplot; | |
151 | |
152 eval (sprintf ("set size %g, %g", multi_xsize, multi_ysize)); | |
153 | |
154 endif | |
155 | |
156 # get the sub plot location | |
157 | |
158 yp = round ((index-1)/columns); | |
159 xp = index - yp*columns - 1; | |
160 multi_xi = ++xp; | |
161 multi_yi = ++yp; | |
162 | |
163 # set the origin | |
164 | |
165 xo = (xp - 1.0)*multi_xsize; | |
166 yo = (rows - yp)*multi_ysize; | |
167 | |
168 eval (sprintf ("set origin %g, %g", xo, yo)); | |
169 | |
170 endfunction | 173 endfunction |