Mercurial > hg > octave-lyh
comparison scripts/plot/colorbar.m @ 17129:b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
* scripts/geometry/voronoi.m, scripts/image/imagesc.m,
scripts/plot/__plt_get_axis_arg__.m, scripts/plot/axes.m, scripts/plot/cla.m,
scripts/plot/colorbar.m, scripts/plot/hold.m, scripts/plot/legend.m,
scripts/plot/plotmatrix.m, scripts/plot/plotyy.m,
scripts/plot/private/__errplot__.m, scripts/plot/private/__plt__.m,
scripts/plot/view.m: Use new isaxes function to simplify code.
* scripts/plot/shading.m: Use Octave convention for spacing of parentheses.
* scripts/plot/zlabel.m: Correct %!test incorrectly calling plot3 with figure
handle.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 31 Jul 2013 16:27:49 -0700 |
parents | eaab03308c0b |
children | df4c4b7708a4 |
comparison
equal
deleted
inserted
replaced
17128:7649779e6ebd | 17129:b5d6314314fc |
---|---|
106 case "peer" | 106 case "peer" |
107 if (i > nargin) | 107 if (i > nargin) |
108 error ('colorbar: missing axes handle after "peer"'); | 108 error ('colorbar: missing axes handle after "peer"'); |
109 else | 109 else |
110 ax = varargin{i++}; | 110 ax = varargin{i++}; |
111 if (! isscalar (ax) || ! ishandle (ax) | 111 if (! isscalar (ax) && ! isaxes (ax)) |
112 || ! strcmp (get (ax, "type"), "axes")) | |
113 error ('colorbar: expecting an axes handle following "peer"'); | 112 error ('colorbar: expecting an axes handle following "peer"'); |
114 endif | 113 endif |
115 endif | 114 endif |
116 case {"north", "south", "east", "west", | 115 case {"north", "south", "east", "west", |
117 "northoutside", "southoutside", "eastoutside", "westoutside"} | 116 "northoutside", "southoutside", "eastoutside", "westoutside"} |
251 endfunction | 250 endfunction |
252 | 251 |
253 function deletecolorbar (h, d, hc, orig_props) | 252 function deletecolorbar (h, d, hc, orig_props) |
254 ## Don't delete the colorbar and reset the axis size if the | 253 ## Don't delete the colorbar and reset the axis size if the |
255 ## parent figure is being deleted. | 254 ## parent figure is being deleted. |
256 if (ishandle (hc) && strcmp (get (hc, "type"), "axes") | 255 if (isaxes (hc) |
257 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off"))) | 256 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off"))) |
258 if (strcmp (get (hc, "beingdeleted"), "off")) | 257 if (strcmp (get (hc, "beingdeleted"), "off")) |
259 delete (hc); | 258 delete (hc); |
260 endif | 259 endif |
261 if (!isempty (ancestor (h, "axes")) | 260 if (!isempty (ancestor (h, "axes")) |
270 endif | 269 endif |
271 endif | 270 endif |
272 endfunction | 271 endfunction |
273 | 272 |
274 function resetaxis (cax, d, ax, orig_props) | 273 function resetaxis (cax, d, ax, orig_props) |
275 if (ishandle (ax) && strcmp (get (ax, "type"), "axes")) | 274 if (isaxes (ax)) |
276 ## FIXME: Probably don't want to delete everyone's listeners on colormap. | 275 ## FIXME: Probably don't want to delete everyone's listeners on colormap. |
277 dellistener (get (ax, "parent"), "colormap"); | 276 dellistener (get (ax, "parent"), "colormap"); |
278 dellistener (ax, "clim"); | 277 dellistener (ax, "clim"); |
279 dellistener (ax, "dataaspectratio"); | 278 dellistener (ax, "dataaspectratio"); |
280 dellistener (ax, "dataaspectratiomode"); | 279 dellistener (ax, "dataaspectratiomode"); |
290 set (ax, "units", units); | 289 set (ax, "units", units); |
291 endif | 290 endif |
292 endfunction | 291 endfunction |
293 | 292 |
294 function update_colorbar_clim (hax, d, hi, vert) | 293 function update_colorbar_clim (hax, d, hi, vert) |
295 if (ishandle (hax) && strcmp (get (hax, "type"), "axes") | 294 if (isaxes (hax) |
296 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off"))) | 295 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off"))) |
297 clen = rows (get (get (hax, "parent"), "colormap")); | 296 clen = rows (get (get (hax, "parent"), "colormap")); |
298 cext = get (hax, "clim"); | 297 cext = get (hax, "clim"); |
299 cdiff = (cext(2) - cext(1)) / clen / 2; | 298 cdiff = (cext(2) - cext(1)) / clen / 2; |
300 cmin = cext(1) + cdiff; | 299 cmin = cext(1) + cdiff; |
329 endif | 328 endif |
330 endfunction | 329 endfunction |
331 | 330 |
332 function update_colorbar_axis (h, d, cax, orig_props) | 331 function update_colorbar_axis (h, d, cax, orig_props) |
333 | 332 |
334 if (ishandle (cax) && strcmp (get (cax, "type"), "axes") | 333 if (isaxes (cax) |
335 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off"))) | 334 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off"))) |
336 loc = get (cax, "location"); | 335 loc = get (cax, "location"); |
337 obj = get (h); | 336 obj = get (h); |
338 obj.__cbar_hax__ = h; | 337 obj.__cbar_hax__ = h; |
339 obj.position = orig_props.position; | 338 obj.position = orig_props.position; |