Mercurial > hg > octave-lyh
annotate scripts/plot/colorbar.m @ 8101:86955a1559c5
improve speed of cell2mat
* * *
trivial fix for previous cell2mat change
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 11 Sep 2008 16:57:12 -0400 |
parents | 1b954fdaf4ff |
children | c066714ee5d5 |
rev | line source |
---|---|
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
1 ## Copyright (C) 2008 David Bateman |
7189 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} colorbar (@var{s}) | |
21 ## @deftypefnx {Function File} {} colorbar ('peer', @var{h}, @dots{}) | |
22 ## Adds a colorbar to the current axes. Valid values for @var{s} are | |
23 ## | |
24 ## @table @asis | |
25 ## @item 'EastOutside' | |
26 ## Place the colorbar outside the plot to the right. This is the default. | |
27 ## @item 'East' | |
28 ## Place the colorbar inside the plot to the right. | |
29 ## @item 'WestOutside' | |
30 ## Place the colorbar outside the plot to the left. | |
31 ## @item 'West' | |
32 ## Place the colorbar inside the plot to the left. | |
33 ## @item 'NorthOutside' | |
34 ## Place the colorbar above the plot. | |
35 ## @item 'North' | |
36 ## Place the colorbar at the top of the plot. | |
37 ## @item 'SouthOutside' | |
38 ## Place the colorbar under the plot. | |
39 ## @item 'South' | |
40 ## Place the colorbar at the bottom of the plot. | |
41 ## @item 'Off', 'None' | |
42 ## Remove any existing colorbar from the plot. | |
43 ## @end table | |
44 ## | |
7264 | 45 ## If the argument 'peer' is given, then the following argument is treated |
46 ## as the axes handle on which to add the colorbar. | |
7189 | 47 ## @end deftypefn |
48 | |
49 | |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
50 function h = colorbar (varargin) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
51 ax = []; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
52 loc = "eastoutside"; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
53 args = {}; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
54 deleting = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
55 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
56 i = 1; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
57 while (i <= nargin) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
58 arg = varargin {i++}; |
7189 | 59 |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
60 if (ischar(arg)) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
61 if (strcmpi (arg, "peer")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
62 if (i > nargin) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
63 error ("colorbar: missing axes handle after 'peer'"); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
64 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
65 ax = vargin{i++} |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
66 if (!isscalar (ax) || ! ishandle (ax) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
67 || strcmp (get (ax, "type"), "axes")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
68 error ("colorbar: expecting an axes handle following 'peer'"); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
69 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
70 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
71 elseif (strcmpi (arg, "north") || strcmpi (arg, "south") |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
72 || strcmpi (arg, "east") || strcmpi (arg, "west") |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
73 || strcmpi (arg, "northoutside") || strcmpi (arg, "southoutside") |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
74 || strcmpi (arg, "eastoutside") || strcmpi (arg, "westoutside")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
75 loc = arg; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
76 elseif (strcmpi (arg, "off") || strcmpi (arg, "none")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
77 deleting = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
78 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
79 args{end+1} = arg; |
7189 | 80 endif |
81 else | |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
82 args{end+1} = arg; |
7189 | 83 endif |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
84 endwhile |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
85 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
86 if (isempty (ax)) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
87 ax = gca (); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
88 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
89 obj = get (ax); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
90 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
91 if (deleting) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
92 objs = findobj (get (ax, "parent"), "type", "axes"); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
93 for i = 1 : length (objs) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
94 if (strcmp (get (objs(i), "tag"), "colorbar") && |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
95 get (objs(i), "axes") == ax) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
96 delete (objs(i)); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
97 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
98 endfor |
7189 | 99 else |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
100 position = obj.position; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
101 clen = rows (get (get (ax, "parent"), "colormap")); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
102 cext = get (ax, "clim"); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
103 cdiff = (cext(2) - cext(1)) / clen / 2; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
104 cmin = cext(1) + cdiff; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
105 cmax = cext(2) - cdiff; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
106 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
107 orig_pos = obj.position; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
108 orig_opos = obj.outerposition; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
109 [pos, cpos, vertical, mirror, aspect] = ... |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
110 __position_colorbox__ (loc, obj, ancestor (ax, "figure")); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
111 set (ax, "activepositionproperty", "position", "position", pos); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
112 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
113 cax = __go_axes__ (get (ax, "parent"), "tag", "colorbar", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
114 "handlevisibility", "off", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
115 "activepositionproperty", "position", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
116 "position", cpos); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
117 addproperty ("location", cax, "radio", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
118 "eastoutside|east|westoutside|west|northoutside|north|southoutside|south", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
119 loc); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
120 addproperty ("axes", cax, "handle", ax); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
121 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
122 if (vertical) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
123 hi = image (cax, [0,1], [cmin, cmax], [1 : clen]'); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
124 if (mirror) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
125 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
126 "ylim", cext, "ylimmode", "manual", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
127 "yaxislocation", "right", args{:}); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
128 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
129 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
130 "ylim", cext, "ylimmode", "manual", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
131 "yaxislocation", "left", args{:}); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
132 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
133 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
134 hi = image (cax, [cmin, cmax], [0,1], [1 : clen]); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
135 if (mirror) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
136 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
137 "xlim", cext, "xlimmode", "manual", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
138 "xaxislocation", "top", args{:}); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
139 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
140 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
141 "xlim", cext, "xlimmode", "manual", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
142 "xaxislocation", "bottom", args{:}); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
143 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
144 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
145 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
146 if (! isnan (aspect)) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
147 set (cax, "dataaspectratio", aspect); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
148 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
149 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
150 ctext = text (0, 0, "", "tag", "colorbar","visible", "off", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
151 "handlevisibility", "off", "xliminclude", "off", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
152 "yliminclude", "off", "zliminclude", "off", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
153 "deletefcn", {@deletecolorbar, cax, orig_pos, orig_opos}); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
154 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
155 set (cax, "deletefcn", {@resetaxis, orig_pos, orig_opos}); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
156 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
157 addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical}) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
158 addlistener (ax, "dataaspectratio", {@update_colorbar_axis, cax}) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
159 addlistener (ax, "position", {@update_colorbar_axis, cax}) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
160 |
7189 | 161 endif |
162 | |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
163 if (nargout > 0) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
164 h = cax; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
165 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
166 endfunction |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
167 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
168 function deletecolorbar (h, d, hc, pos, opos) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
169 ## Don't delete the colorbar and reset the axis size if the |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
170 ## parent figure is being deleted. |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
171 if (ishandle (hc) && strcmp (get (hc, "type"), "axes") && |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
172 (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
173 if (strcmp (get (hc, "beingdeleted"), "off")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
174 delete (hc); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
175 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
176 if (!isempty (ancestor (h, "axes")) && |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
177 strcmp (get (ancestor (h, "axes"), "beingdeleted"), "off")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
178 #set (ancestor (h, "axes"), "position", pos, "outerposition", opos); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
179 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
180 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
181 endfunction |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
182 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
183 function resetaxis (h, d, pos, opos) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
184 if (ishandle (h) && strcmp (get (h, "type"), "axes") && |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
185 (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off")) && |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
186 ishandle (get (h, "axes"))) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
187 #set (get (h, "axes"), "position", pos, "outerposition", opos); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
188 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
189 endfunction |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
190 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
191 function update_colorbar_clim (h, d, hi, vert) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
192 if (ishandle (h) && strcmp (get (h, "type"), "image") && |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
193 (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
194 clen = rows (get (get (h, "parent"), "colormap")); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
195 cext = get (h, "clim"); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
196 cdiff = (cext(2) - cext(1)) / clen / 2; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
197 cmin = cext(1) + cdiff; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
198 cmax = cext(2) - cdiff; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
199 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
200 if (vert) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
201 set (hi, "ydata", [cmin, cmax]); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
202 set (get (hi, "parent"), "ylim", cext); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
203 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
204 set (hi, "xdata", [cmin, cmax]); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
205 set (get (hi, "parent"), "xlim", cext); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
206 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
207 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
208 endfunction |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
209 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
210 function update_colorbar_axis (h, d, cax) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
211 if (ishandle (cax) && strcmp (get (cax, "type"), "axes") && |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
212 (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
213 loc = get (cax, "location"); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
214 obj = get (h); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
215 [pos, cpos, vertical, mirror, aspect] = ... |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
216 __position_colorbox__ (loc, obj, ancestor (h, "figure")); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
217 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
218 if (vertical) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
219 if (mirror) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
220 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
221 "yaxislocation", "right", "position", cpos); |
7189 | 222 else |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
223 set (cax, "xtick", [], "xdir", "normal", "ydir", "normal", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
224 "yaxislocation", "left", "position", cpos); |
7189 | 225 endif |
226 else | |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
227 if (mirror) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
228 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
229 "xaxislocation", "top", "position", cpos); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
230 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
231 set (cax, "ytick", [], "xdir", "normal", "ydir", "normal", |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
232 "xaxislocation", "bottom", "position", cpos); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
233 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
234 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
235 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
236 if (! isnan (aspect)) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
237 aspect |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
238 set (cax, "dataaspectratio", aspect); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
239 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
240 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
241 endfunction |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
242 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
243 function [pos, cpos, vertical, mirr, aspect] = __position_colorbox__ (cbox, obj, cf) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
244 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
245 pos = obj.position; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
246 sz = pos(3:4); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
247 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
248 off = 0; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
249 if (strcmpi (obj.dataaspectratiomode, "manual")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
250 r = obj.dataaspectratio; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
251 if (pos(3) > pos(4)) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
252 switch (cbox) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
253 case {"east", "eastoutside", "west", "westoutside"} |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
254 off = [(pos(3) - pos(4)) ./ (r(2) / r(1)), 0]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
255 endswitch |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
256 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
257 switch (cbox) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
258 case {"north", "northoutside", "south", "southoutside"} |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
259 off = [0, (pos(4) - pos(3)) ./ (r(1) / r(2))]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
260 ## This shouldn't be here except that gnuplot doesn't have a |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
261 ## square window and so a square aspect ratio is not square. |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
262 ## The corrections are empirical. |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
263 if (strcmp (get (cf, "__backend__"), "gnuplot")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
264 if (length (cbox) > 7 && strcmp (cbox(end-6:end),"outside")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
265 off = off / 2; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
266 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
267 off = off / 1.7; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
268 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
269 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
270 endswitch |
7189 | 271 endif |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
272 off = off / 2; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
273 endif |
7189 | 274 |
8101
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
275 switch (cbox) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
276 case "northoutside" |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
277 origin = pos(1:2) + [0., 0.9] .* sz + [1, -1] .* off; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
278 sz = sz .* [1.0, 0.06]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
279 pos(4) = 0.8 * pos(4); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
280 mirr = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
281 vertical = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
282 case "north" |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
283 origin = pos(1:2) + [0.05, 0.9] .* sz + [1, -1] .* off; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
284 sz = sz .* [1.0, 0.06] * 0.9; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
285 mirr = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
286 vertical = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
287 case "southoutside" |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
288 origin = pos(1:2) + off; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
289 sz = sz .* [1.0, 0.06]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
290 pos(2) = pos(2) + pos(4) * 0.2; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
291 pos(4) = 0.8 * pos(4); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
292 mirr = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
293 vertical = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
294 case "south" |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
295 origin = pos(1:2) + [0.05, 0.05] .* sz + off; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
296 sz = sz .* [1.0, 0.06] * 0.9; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
297 mirr = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
298 vertical = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
299 case "eastoutside" |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
300 origin = pos(1:2) + [0.9, 0] .* sz + [-1, 1] .* off; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
301 sz = sz .* [0.06, 1.0]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
302 pos(3) = 0.8 * pos(3); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
303 mirr = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
304 vertical = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
305 case "east" |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
306 origin = pos(1:2) + [0.9, 0.05] .* sz + [-1, 1] .* off; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
307 sz = sz .* [0.06, 1.0] * 0.9; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
308 mirr = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
309 vertical = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
310 case "westoutside" |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
311 origin = pos(1:2) + off; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
312 sz = sz .* [0.06, 1.0]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
313 pos(1) = pos(1) + pos(3) * 0.2; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
314 pos(3) = 0.8 * pos(3); |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
315 mirr = false; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
316 vertical = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
317 case "west" |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
318 origin = pos(1:2) + [0.05, 0.05] .* sz + off; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
319 sz = sz .* [0.06, 1.0] .* 0.9; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
320 mirr = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
321 vertical = true; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
322 endswitch |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
323 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
324 cpos = [origin, sz]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
325 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
326 if (strcmpi (obj.dataaspectratiomode, "manual")) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
327 r = obj.dataaspectratio; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
328 |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
329 if (pos(3) > pos(4)) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
330 if (vertical) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
331 aspect = [1, 0.21, 1]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
332 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
333 aspect = [0.21, 1, 1]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
334 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
335 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
336 if (vertical) |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
337 aspect = [1, 0.21, 1]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
338 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
339 aspect = [0.21, 1, 1]; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
340 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
341 endif |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
342 else |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
343 aspect = NaN; |
86955a1559c5
improve speed of cell2mat
David Bateman <dbateman@free.fr>
parents:
7726
diff
changeset
|
344 endif |
7191 | 345 |
7189 | 346 endfunction |
347 | |
348 %!demo | |
349 %! hold off; | |
350 %! close all; | |
351 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); | |
352 %! imagesc(x) | |
353 %! colorbar(); | |
354 | |
355 %!demo | |
356 %! hold off; | |
357 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); | |
358 %! imagesc(x) | |
359 %! colorbar("westoutside"); | |
360 | |
361 %!demo | |
362 %! hold off; | |
363 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); | |
364 %! imagesc(x) | |
365 %! colorbar("northoutside"); | |
366 | |
367 %!demo | |
368 %! hold off; | |
369 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); | |
370 %! imagesc(x) | |
371 %! colorbar("southoutside"); | |
372 | |
373 %!demo | |
374 %! hold off; | |
375 %! subplot(2,2,1) | |
376 %! contour(peaks()) | |
377 %! colorbar("east"); | |
378 %! subplot(2,2,2) | |
379 %! contour(peaks()) | |
380 %! colorbar("west"); | |
381 %! subplot(2,2,3) | |
382 %! contour(peaks()) | |
383 %! colorbar("north"); | |
384 %! subplot(2,2,4) | |
385 %! contour(peaks()) | |
386 %! colorbar("south"); | |
387 | |
388 %!demo | |
389 %! hold off; | |
390 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); | |
391 %! subplot(2,2,1) | |
392 %! imagesc(x) | |
393 %! colorbar(); | |
394 %! subplot(2,2,2) | |
395 %! imagesc(x) | |
396 %! colorbar("westoutside"); | |
397 %! subplot(2,2,3) | |
398 %! imagesc(x) | |
399 %! colorbar("northoutside"); | |
400 %! subplot(2,2,4) | |
401 %! imagesc(x) | |
402 %! colorbar("southoutside"); | |
403 | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
404 %!demo |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
405 %! hold off; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
406 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
407 %! subplot(1,2,1) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
408 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
409 %! axis square; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
410 %! colorbar(); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
411 %! subplot(1,2,2) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
412 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
413 %! axis square; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
414 %! colorbar("westoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
415 |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
416 %!demo |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
417 %! hold off; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
418 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
419 %! subplot(1,2,1) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
420 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
421 %! axis square; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
422 %! colorbar("northoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
423 %! subplot(1,2,2) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
424 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
425 %! axis square; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
426 %! colorbar("southoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
427 |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
428 %!demo |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
429 %! hold off; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
430 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
431 %! subplot(2,1,1) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
432 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
433 %! axis square; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
434 %! colorbar(); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
435 %! subplot(2,1,2) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
436 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
437 %! axis square; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
438 %! colorbar("westoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
439 |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
440 %!demo |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
441 %! hold off; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
442 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
443 %! subplot(2,1,1) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
444 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
445 %! axis square; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
446 %! colorbar("northoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
447 %! subplot(2,1,2) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
448 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
449 %! axis square; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
450 %! colorbar("southoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
451 |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
452 %!demo |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
453 %! hold off; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
454 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
455 %! subplot(1,2,1) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
456 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
457 %! colorbar(); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
458 %! subplot(1,2,2) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
459 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
460 %! colorbar("westoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
461 |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
462 %!demo |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
463 %! hold off; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
464 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
465 %! subplot(1,2,1) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
466 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
467 %! colorbar("northoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
468 %! subplot(1,2,2) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
469 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
470 %! colorbar("southoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
471 |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
472 %!demo |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
473 %! hold off; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
474 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
475 %! subplot(2,1,1) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
476 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
477 %! colorbar(); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
478 %! subplot(2,1,2) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
479 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
480 %! colorbar("westoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
481 |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
482 %!demo |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
483 %! hold off; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
484 %! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.'); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
485 %! subplot(2,1,1) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
486 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
487 %! colorbar("northoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
488 %! subplot(2,1,2) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
489 %! imagesc(x) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
490 %! colorbar("southoutside"); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
491 |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7264
diff
changeset
|
492 |