Mercurial > hg > octave-max
comparison scripts/plot/colorbar.m @ 10549:95c3e38098bf
Untabify .m scripts
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Fri, 23 Apr 2010 11:28:50 -0700 |
parents | eb55e736060e |
children | 23c1910dbd8e |
comparison
equal
deleted
inserted
replaced
10548:479536c5bb10 | 10549:95c3e38098bf |
---|---|
56 while (i <= nargin) | 56 while (i <= nargin) |
57 arg = varargin {i++}; | 57 arg = varargin {i++}; |
58 | 58 |
59 if (ischar(arg)) | 59 if (ischar(arg)) |
60 if (strcmpi (arg, "peer")) | 60 if (strcmpi (arg, "peer")) |
61 if (i > nargin) | 61 if (i > nargin) |
62 error ("colorbar: missing axes handle after \"peer\""); | 62 error ("colorbar: missing axes handle after \"peer\""); |
63 else | 63 else |
64 ax = varargin{i++}; | 64 ax = varargin{i++}; |
65 if (!isscalar (ax) || ! ishandle (ax) | 65 if (!isscalar (ax) || ! ishandle (ax) |
66 || ! strcmp (get (ax, "type"), "axes")) | 66 || ! strcmp (get (ax, "type"), "axes")) |
67 error ("colorbar: expecting an axes handle following \"peer\""); | 67 error ("colorbar: expecting an axes handle following \"peer\""); |
68 endif | 68 endif |
69 endif | 69 endif |
70 elseif (strcmpi (arg, "north") || strcmpi (arg, "south") | 70 elseif (strcmpi (arg, "north") || strcmpi (arg, "south") |
71 || strcmpi (arg, "east") || strcmpi (arg, "west") | 71 || strcmpi (arg, "east") || strcmpi (arg, "west") |
72 || strcmpi (arg, "northoutside") || strcmpi (arg, "southoutside") | 72 || strcmpi (arg, "northoutside") || strcmpi (arg, "southoutside") |
73 || strcmpi (arg, "eastoutside") || strcmpi (arg, "westoutside")) | 73 || strcmpi (arg, "eastoutside") || strcmpi (arg, "westoutside")) |
74 loc = tolower (arg); | 74 loc = tolower (arg); |
75 elseif (strcmpi (arg, "off") || strcmpi (arg, "none")) | 75 elseif (strcmpi (arg, "off") || strcmpi (arg, "none")) |
76 deleting = true; | 76 deleting = true; |
77 else | 77 else |
78 args{end+1} = arg; | 78 args{end+1} = arg; |
79 endif | 79 endif |
80 else | 80 else |
81 args{end+1} = arg; | 81 args{end+1} = arg; |
82 endif | 82 endif |
83 endwhile | 83 endwhile |
107 cmax = cext(2) - cdiff; | 107 cmax = cext(2) - cdiff; |
108 | 108 |
109 orig_pos = obj.position; | 109 orig_pos = obj.position; |
110 orig_opos = obj.outerposition; | 110 orig_opos = obj.outerposition; |
111 [pos, cpos, vertical, mirror] = ... | 111 [pos, cpos, vertical, mirror] = ... |
112 __position_colorbox__ (loc, obj, ancestor (ax, "figure")); | 112 __position_colorbox__ (loc, obj, ancestor (ax, "figure")); |
113 set (ax, "activepositionproperty", "position", "position", pos); | 113 set (ax, "activepositionproperty", "position", "position", pos); |
114 | 114 |
115 cax = __go_axes__ (get (ax, "parent"), "tag", "colorbar", | 115 cax = __go_axes__ (get (ax, "parent"), "tag", "colorbar", |
116 "handlevisibility", "on", | 116 "handlevisibility", "on", |
117 "activepositionproperty", "position", | 117 "activepositionproperty", "position", |
118 "position", cpos); | 118 "position", cpos); |
119 addproperty ("location", cax, "radio", | 119 addproperty ("location", cax, "radio", |
120 "eastoutside|east|westoutside|west|northoutside|north|southoutside|south", | 120 "eastoutside|east|westoutside|west|northoutside|north|southoutside|south", |
121 loc); | 121 loc); |
122 addproperty ("axes", cax, "handle", ax); | 122 addproperty ("axes", cax, "handle", ax); |
123 | 123 |
124 if (vertical) | 124 if (vertical) |
125 hi = image (cax, [0,1], [cmin, cmax], [1 : clen]'); | 125 hi = image (cax, [0,1], [cmin, cmax], [1 : clen]'); |
126 if (mirror) | 126 if (mirror) |
127 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", | 127 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", |
128 "ylim", cext, "ylimmode", "manual", | 128 "ylim", cext, "ylimmode", "manual", |
129 "yaxislocation", "right", args{:}); | 129 "yaxislocation", "right", args{:}); |
130 else | 130 else |
131 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", | 131 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", |
132 "ylim", cext, "ylimmode", "manual", | 132 "ylim", cext, "ylimmode", "manual", |
133 "yaxislocation", "left", args{:}); | 133 "yaxislocation", "left", args{:}); |
134 endif | 134 endif |
135 else | 135 else |
136 hi = image (cax, [cmin, cmax], [0,1], [1 : clen]); | 136 hi = image (cax, [cmin, cmax], [0,1], [1 : clen]); |
137 if (mirror) | 137 if (mirror) |
138 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", | 138 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", |
139 "xlim", cext, "xlimmode", "manual", | 139 "xlim", cext, "xlimmode", "manual", |
140 "xaxislocation", "top", args{:}); | 140 "xaxislocation", "top", args{:}); |
141 else | 141 else |
142 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", | 142 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", |
143 "xlim", cext, "xlimmode", "manual", | 143 "xlim", cext, "xlimmode", "manual", |
144 "xaxislocation", "bottom", args{:}); | 144 "xaxislocation", "bottom", args{:}); |
145 endif | 145 endif |
146 endif | 146 endif |
147 | 147 |
148 ctext = text (0, 0, "", "tag", "colorbar","visible", "off", | 148 ctext = text (0, 0, "", "tag", "colorbar","visible", "off", |
149 "handlevisibility", "off", "xliminclude", "off", | 149 "handlevisibility", "off", "xliminclude", "off", |
150 "yliminclude", "off", "zliminclude", "off", | 150 "yliminclude", "off", "zliminclude", "off", |
151 "deletefcn", {@deletecolorbar, cax, orig_pos, orig_opos}); | 151 "deletefcn", {@deletecolorbar, cax, orig_pos, orig_opos}); |
152 | 152 |
153 set (cax, "deletefcn", {@resetaxis, orig_pos, orig_opos}); | 153 set (cax, "deletefcn", {@resetaxis, orig_pos, orig_opos}); |
154 | 154 |
155 addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical}) | 155 addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical}) |
156 addlistener (ax, "plotboxaspectratio", {@update_colorbar_axis, cax}) | 156 addlistener (ax, "plotboxaspectratio", {@update_colorbar_axis, cax}) |
171 (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))) | 171 (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))) |
172 if (strcmp (get (hc, "beingdeleted"), "off")) | 172 if (strcmp (get (hc, "beingdeleted"), "off")) |
173 delete (hc); | 173 delete (hc); |
174 endif | 174 endif |
175 if (!isempty (ancestor (h, "axes")) && | 175 if (!isempty (ancestor (h, "axes")) && |
176 strcmp (get (ancestor (h, "axes"), "beingdeleted"), "off")) | 176 strcmp (get (ancestor (h, "axes"), "beingdeleted"), "off")) |
177 set (ancestor (h, "axes"), "position", pos, "outerposition", opos); | 177 set (ancestor (h, "axes"), "position", pos, "outerposition", opos); |
178 endif | 178 endif |
179 endif | 179 endif |
180 endfunction | 180 endfunction |
181 | 181 |
210 if (ishandle (cax) && strcmp (get (cax, "type"), "axes") && | 210 if (ishandle (cax) && strcmp (get (cax, "type"), "axes") && |
211 (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))) | 211 (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))) |
212 loc = get (cax, "location"); | 212 loc = get (cax, "location"); |
213 obj = get (h); | 213 obj = get (h); |
214 [pos, cpos, vertical, mirror] = ... | 214 [pos, cpos, vertical, mirror] = ... |
215 __position_colorbox__ (loc, obj, ancestor (h, "figure")); | 215 __position_colorbox__ (loc, obj, ancestor (h, "figure")); |
216 | 216 |
217 if (vertical) | 217 if (vertical) |
218 if (mirror) | 218 if (mirror) |
219 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", | 219 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", |
220 "yaxislocation", "right", "position", cpos); | 220 "yaxislocation", "right", "position", cpos); |
221 else | 221 else |
222 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", | 222 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", |
223 "yaxislocation", "left", "position", cpos); | 223 "yaxislocation", "left", "position", cpos); |
224 endif | 224 endif |
225 else | 225 else |
226 if (mirror) | 226 if (mirror) |
227 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", | 227 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", |
228 "xaxislocation", "top", "position", cpos); | 228 "xaxislocation", "top", "position", cpos); |
229 else | 229 else |
230 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", | 230 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", |
231 "xaxislocation", "bottom", "position", cpos); | 231 "xaxislocation", "bottom", "position", cpos); |
232 endif | 232 endif |
233 endif | 233 endif |
234 | 234 |
235 endif | 235 endif |
236 endfunction | 236 endfunction |
243 off = 0; | 243 off = 0; |
244 if (strcmpi (obj.plotboxaspectratiomode, "manual")) | 244 if (strcmpi (obj.plotboxaspectratiomode, "manual")) |
245 r = obj.plotboxaspectratio; | 245 r = obj.plotboxaspectratio; |
246 if (pos(3) > pos(4)) | 246 if (pos(3) > pos(4)) |
247 switch (cbox) | 247 switch (cbox) |
248 case {"east", "eastoutside", "west", "westoutside"} | 248 case {"east", "eastoutside", "west", "westoutside"} |
249 off = [(pos(3) - pos(4)) ./ (r(2) / r(1)), 0]; | 249 off = [(pos(3) - pos(4)) ./ (r(2) / r(1)), 0]; |
250 endswitch | 250 endswitch |
251 else | 251 else |
252 switch (cbox) | 252 switch (cbox) |
253 case {"north", "northoutside", "south", "southoutside"} | 253 case {"north", "northoutside", "south", "southoutside"} |
254 off = [0, (pos(4) - pos(3)) ./ (r(1) / r(2))]; | 254 off = [0, (pos(4) - pos(3)) ./ (r(1) / r(2))]; |
255 ## This shouldn't be here except that gnuplot doesn't have a | 255 ## This shouldn't be here except that gnuplot doesn't have a |
256 ## square window and so a square aspect ratio is not square. | 256 ## square window and so a square aspect ratio is not square. |
257 ## The corrections are empirical. | 257 ## The corrections are empirical. |
258 if (strcmp (get (cf, "__backend__"), "gnuplot")) | 258 if (strcmp (get (cf, "__backend__"), "gnuplot")) |
259 if (length (cbox) > 7 && strcmp (cbox(end-6:end),"outside")) | 259 if (length (cbox) > 7 && strcmp (cbox(end-6:end),"outside")) |
260 off = off / 2; | 260 off = off / 2; |
261 else | 261 else |
262 off = off / 1.7; | 262 off = off / 1.7; |
263 endif | 263 endif |
264 endif | 264 endif |
265 endswitch | 265 endswitch |
266 endif | 266 endif |
267 off = off / 2; | 267 off = off / 2; |
268 endif | 268 endif |
269 | 269 |