Mercurial > octave-nkf
comparison scripts/plot/subplot.m @ 8804:995f8b064b32
subplot.m: Compatible placement of subplots.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 18 Feb 2009 11:53:56 -0500 |
parents | 4142982c66c6 |
children | eb63fbe60fab |
comparison
equal
deleted
inserted
replaced
8803:35ea4f816bc9 | 8804:995f8b064b32 |
---|---|
101 endif | 101 endif |
102 | 102 |
103 units = get (0, "defaultaxesunits"); | 103 units = get (0, "defaultaxesunits"); |
104 unwind_protect | 104 unwind_protect |
105 set (0, "defaultaxesunits", "normalized") | 105 set (0, "defaultaxesunits", "normalized") |
106 pos = subplot_position (rows, columns, index, "outerposition", units); | 106 pos = subplot_position (rows, columns, index, "position", units); |
107 | 107 |
108 cf = gcf (); | 108 cf = gcf (); |
109 | 109 |
110 set (cf, "nextplot", "add"); | 110 set (cf, "nextplot", "add"); |
111 | 111 |
123 ## Skip legend and colorbar objects. | 123 ## Skip legend and colorbar objects. |
124 if (strcmp (get (child, "tag"), "legend") || | 124 if (strcmp (get (child, "tag"), "legend") || |
125 strcmp (get (child, "tag"), "colorbar")) | 125 strcmp (get (child, "tag"), "colorbar")) |
126 continue; | 126 continue; |
127 endif | 127 endif |
128 objpos = get (child, "outerposition"); | 128 objpos = get (child, "position"); |
129 if (all (objpos == pos)) | 129 if (all (objpos == pos)) |
130 ## If the new axes are in exactly the same position as an | 130 ## If the new axes are in exactly the same position as an |
131 ## existing axes object, use the existing axes. | 131 ## existing axes object, use the existing axes. |
132 found = true; | 132 found = true; |
133 tmp = child; | 133 tmp = child; |
150 endfor | 150 endfor |
151 | 151 |
152 if (found) | 152 if (found) |
153 set (cf, "currentaxes", tmp); | 153 set (cf, "currentaxes", tmp); |
154 else | 154 else |
155 pos = subplot_position (rows, columns, index, "outerposition", units); | |
155 pos2 = subplot_position (rows, columns, index, "position", units); | 156 pos2 = subplot_position (rows, columns, index, "position", units); |
156 tmp = axes ("outerposition", pos, "position", pos2); | 157 tmp = axes ("outerposition", pos, "position", pos2); |
157 endif | 158 endif |
158 | 159 |
159 unwind_protect_cleanup | 160 unwind_protect_cleanup |
196 | 197 |
197 if (strcmp (position_property, "outerposition") ) | 198 if (strcmp (position_property, "outerposition") ) |
198 ## Calculate the outerposition/position inset | 199 ## Calculate the outerposition/position inset |
199 if (rows > 1) | 200 if (rows > 1) |
200 inset.top = 8/420; | 201 inset.top = 8/420; |
201 inset.bottom = max (polyval ([0.1382,-0.0026], width), 16/420); | 202 inset.bottom = max (polyval ([0.1382,-0.0026], height), 16/420); |
202 else | 203 else |
203 inset.bottom = margins.bottom; | 204 inset.bottom = margins.bottom; |
204 inset.top = margins.top; | 205 inset.top = margins.top; |
205 endif | 206 endif |
206 if (columns > 1) | 207 if (columns > 1) |
225 xp = index(:) - yp*columns - 1; | 226 xp = index(:) - yp*columns - 1; |
226 yp = (rows - 1) - yp; | 227 yp = (rows - 1) - yp; |
227 | 228 |
228 x0 = xp .* (width + margins.column) + margins.left; | 229 x0 = xp .* (width + margins.column) + margins.left; |
229 y0 = yp .* (height + margins.row) + margins.bottom; | 230 y0 = yp .* (height + margins.row) + margins.bottom; |
231 | |
232 if (strcmp (position_property, "outerposition") ) | |
233 x0 = x0 - inset.left; | |
234 y0 = y0 - inset.bottom; | |
235 endif | |
230 | 236 |
231 if (numel(x0) > 1) | 237 if (numel(x0) > 1) |
232 x1 = max (x0) + width; | 238 x1 = max (x0) + width; |
233 y1 = max (y0) + height; | 239 y1 = max (y0) + height; |
234 x0 = min (x0); | 240 x0 = min (x0); |