comparison scripts/plot/draw/colorbar.m @ 19596:0e1f5a750d00

maint: Periodic merge of gui-release to default.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 10:24:46 -0500
parents 04a00ba54557 446c46af4b42
children 4197fc428c7d
comparison
equal deleted inserted replaced
19592:37d37297acf8 19596:0e1f5a750d00
60 ## Place the colorbar at the bottom of the plot. 60 ## Place the colorbar at the bottom of the plot.
61 ## @end table 61 ## @end table
62 ## 62 ##
63 ## To remove a colorbar from a plot use any one of the following keywords for 63 ## To remove a colorbar from a plot use any one of the following keywords for
64 ## the @var{delete_option}: @qcode{"delete"}, @qcode{"hide"}, @qcode{"off"}. 64 ## the @var{delete_option}: @qcode{"delete"}, @qcode{"hide"}, @qcode{"off"}.
65 ## 65 ##
66 ## If the argument @qcode{"peer"} is given, then the following argument is 66 ## If the argument @qcode{"peer"} is given, then the following argument is
67 ## treated as the axes handle in which to add the colorbar. Alternatively, 67 ## treated as the axes handle in which to add the colorbar. Alternatively,
68 ## If the first argument @var{hax} is an axes handle, then the colorbar is 68 ## If the first argument @var{hax} is an axes handle, then the colorbar is
69 ## added to this axis, rather than the current axes returned by @code{gca}. 69 ## added to this axis, rather than the current axes returned by @code{gca}.
70 ## 70 ##
76 ## 76 ##
77 ## The optional return value @var{h} is a graphics handle to the created 77 ## The optional return value @var{h} is a graphics handle to the created
78 ## colorbar object. 78 ## colorbar object.
79 ## 79 ##
80 ## Implementation Note: A colorbar is created as an additional axes to the 80 ## Implementation Note: A colorbar is created as an additional axes to the
81 ## current figure with the @qcode{"tag"} property set to @qcode{"colorbar"}. 81 ## current figure with the @qcode{"tag"} property set to @qcode{"colorbar"}.
82 ## The created axes object has the extra property @qcode{"location"} which 82 ## The created axes object has the extra property @qcode{"location"} which
83 ## controls the positioning of the colorbar. 83 ## controls the positioning of the colorbar.
84 ## @seealso{colormap} 84 ## @seealso{colormap}
85 ## @end deftypefn 85 ## @end deftypefn
86 86
147 # set (hcb, "location", loc); 147 # set (hcb, "location", loc);
148 # endif 148 # endif
149 # if (! isempty (args)) 149 # if (! isempty (args))
150 # set (hcb, args{:}); 150 # set (hcb, args{:});
151 # endif 151 # endif
152 ax = get (get (hcb, "parent"), "currrentaxes"); 152 ax = get (get (hcb, "parent"), "currrentaxes");
153 endif 153 endif
154 endif 154 endif
155 155
156 if (isempty (loc)) 156 if (isempty (loc))
157 loc = "eastoutside"; 157 loc = "eastoutside";
158 endif 158 endif
159 if (isempty (ax)) 159 if (isempty (ax))
160 ax = gca (); 160 ax = gca ();
178 set (ax, "activepositionproperty", "position"); 178 set (ax, "activepositionproperty", "position");
179 obj = get (ax); 179 obj = get (ax);
180 obj.__cbar_hax__ = ax; 180 obj.__cbar_hax__ = ax;
181 position = obj.position; 181 position = obj.position;
182 ## FIXME: Should this be ancestor to accommodate hggroups? 182 ## FIXME: Should this be ancestor to accommodate hggroups?
183 hpar = get (ax, "parent"); 183 hpar = get (ax, "parent");
184 clen = rows (get (hpar, "colormap")); 184 clen = rows (get (hpar, "colormap"));
185 cext = get (ax, "clim"); 185 cext = get (ax, "clim");
186 cdiff = (cext(2) - cext(1)) / clen / 2; 186 cdiff = (cext(2) - cext(1)) / clen / 2;
187 cmin = cext(1) + cdiff; 187 cmin = cext(1) + cdiff;
188 cmax = cext(2) - cdiff; 188 cmax = cext(2) - cdiff;