Functions | |
while (i<=nargin) arg | |
if (ischar(arg)) if(strcmpi(arg | |
endif endif | elseif (strcmpi(arg,"north")||strcmpi(arg,"south")||strcmpi(arg,"east")||strcmpi(arg,"west")||strcmpi(arg,"northoutside")||strcmpi(arg,"southoutside")||strcmpi(arg,"eastoutside")||strcmpi(arg,"westoutside")) loc |
elseif (strcmpi(arg,"off")||strcmpi(arg,"none")) deleting | |
endif endwhile | if (isempty(ax)) ax |
if (!isempty(cax)) delete(cax) | |
endif unwind_protect_cleanup | set (0,"showhiddenhandles", showhiddenhandles) end_unwind_protect if(!deleting) obj |
set (ax,"activepositionproperty","position","position", pos) | |
addproperty ("location", cax,"radio","eastoutside|east|westoutside|west|northoutside|north|southoutside|south", loc) | |
addproperty ("axes", cax,"handle", ax) | |
if (vertical) hi | |
if (mirror) set(cax | |
else | set (cax,"xtick",[],"xdir","normal","ydir","normal","ylim", cext,"ylimmode","manual","yaxislocation","left", args{:}) |
else | set (cax,"ytick",[],"xdir","normal","ydir","normal","xlim", cext,"xlimmode","manual","xaxislocation","bottom", args{:}) |
endif endif | if (!isnan(aspect)) set(cax |
set (cax,"deletefcn",{@resetaxis, orig_pos, orig_opos}) | |
addlistener (ax,"clim",{@update_colorbar_clim, hi, vertical}) addlistener(ax | |
endif endfunction function | deletecolorbar (h, d, hc, pos, opos) if(ishandle(hc)&&strcmp(get(hc |
endif endfunction function axes && | isempty (gcbf())||strcmp(get(gcbf() |
endif endfunction function axes off | if (strcmp(get(hc,"beingdeleted"),"off")) delete(hc) |
endif | if (!isempty(ancestor(h,"axes"))&&strcmp(get(ancestor(h,"axes"),"beingdeleted"),"off")) set(ancestor(h |
endif endif endfunction function | resetaxis (h, d, pos, opos) if(ishandle(h)&&strcmp(get(h |
endif endif endfunction function axes off && | ishandle (get(h,"axes"))) set(get(h |
endif endfunction function | update_colorbar_clim (h, d, hi, vert) if(ishandle(h)&&strcmp(get(h |
if (vert) set(hi | |
set (get(hi,"parent"),"ylim", cext) | |
else | set (hi,"xdata",[cmin, cmax]) |
set (get(hi,"parent"),"xlim", cext) | |
endif endif endfunction function | update_colorbar_axis (h, d, cax) if(ishandle(cax)&&strcmp(get(cax |
else | set (cax,"xtick",[],"xdir","normal","ydir","normal","yaxislocation","left","position", cpos) |
else | set (cax,"ytick",[],"xdir","normal","ydir","normal","xaxislocation","bottom","position", cpos) |
if (strcmpi(obj.dataaspectratiomode,"manual")) r | |
if (pos(3) > pos(4)) switch(cbox) case | |
endswitch else | switch (cbox) case |
pos (4)=0.8 *pos(4) | |
pos (2) | |
pos (3)=0.8 *pos(3) | |
pos (1) | |
if (strfind(cbox,"outside")) scale | |
endif | if (sz(1) > sz(2)) dx |
cpos (1) | |
cpos (3) | |
cpos (2) | |
cpos (4) | |
!imagesc (x)%!colorbar() | |
!demo!clf | !contour (peaks())%!colorbar("west") |
!demo!clf | !subplot (2, 2, 1)%!contour(peaks())%!colorbar("east") |
!subplot (2, 2, 2)%!contour(peaks())%!colorbar("west") | |
!subplot (2, 2, 3)%!contour(peaks())%!colorbar("north") | |
!subplot (2, 2, 4)%!contour(peaks())%!colorbar("south") | |
!subplot (1, 2, 1)%!imagesc(x)%!axis square | |
!colorbar () | |
!subplot (1, 2, 2)%!imagesc(x)%!axis square | |
!colorbar ("westoutside") | |
!colorbar ("northoutside") | |
!colorbar ("southoutside") | |
!subplot (2, 1, 1)%!imagesc(x)%!axis square | |
!subplot (2, 1, 2)%!imagesc(x)%!axis square | |
!colorbar ("east") | |
!xlim ([1, 64])%!ylim([1 | |
!contour (x)%!xlim([1 | |
!ylim ([1, 64])%!colorbar() | |
!demo!clf | !imagesc (1./hilb(99)) |
!set (h, 'yscale', 'log') | |
!demo!clf | !imagesc (log10(1./hilb(99))) |
!set (h,"yticklabel", sprintf('10^{%g}|', ytick)) | |
!imagesc (1./hilb(n)) | |
!imagesc (x, y, 1./hilb(n)) | |
!imagesc (y, x, 1./hilb(n)) | |
colorbar!demo!clf!axes!colorbar!hold on | !contour (peaks)%!hold off%!demo%!clf%!plot([0 |
colorbar!demo!clf!axes!colorbar!hold on | !colorbar ("eastoutside")%!axis square%!demo%!clf%!plot([0 |
Variables | |
function | h |
loc = "eastoutside" | |
args = {} | |
deleting = false | |
i = 1 | |
peer if(i > nargin) error("colorbar else | ax |
endif | showhiddenhandles = get (0, "showhiddenhandles") |
unwind_protect | set (0,"showhiddenhandles","on") cax = findobj (get (ax, "parent"), "tag", "colorbar", "type", "axes", "axes", ax) |
position = obj.position | |
clen = rows (get (get (ax, "parent"), "colormap")) | |
cext = get (ax, "clim") | |
cdiff = (cext(2) - cext(1)) / clen / 2 | |
cmin = cext(1) + cdiff | |
cmax = cext(2) - cdiff | |
orig_pos = obj.position | |
orig_opos = obj.outerposition | |
cax | |
xtick | |
xdir | |
normal | |
ydir | |
ylim | |
ylimmode | |
manual | |
yaxislocation | |
right = find (def(1:right-1) != " ", 1, "last") | |
endif else | hi = image (cax, [cmin, cmax], [0,1], [1 : clen]) |
ytick | |
xlim | |
xlimmode | |
xaxislocation | |
top | |
endif endif | dataaspectratio |
endif endif | aspect = NaN |
endif | ctext |
endif endfunction function | type |
endif endfunction function axes && | beingdeleted |
endif | axes |
endif | pos |
endif | outerposition |
endif | opos |
ydata | |
obj = get (h) | |
cpos = [origin, sz] | |
endif endif endfunction | function [pos, cpos, vertical, mirr, aspect] |
sz = pos(3:4) | |
off = 0 | |
mirr = true | |
vertical = false | |
case north | origin = pos(1:2) + [0.05, 0.9] .* sz + [1, -1] .* off |
actual_pos = __actual_axis_position__ (obj) | |
else | scale = 0.9 |
else | dy = (1-scale)*actual_pos(4) |
endif endfunction!demo!clf | !n = 64 |
x = kron (1:n,ones(n,1)) | |
!h = colorbar | |
!ytick = get(h, "ytick") | |
y = linspace(0,1,n) | |
axis | equal |
!colorbar | ( | "east" | ) |
!colorbar | ( | "southoutside" | ) |
!colorbar | ( | "northoutside" | ) |
!colorbar | ( | "westoutside" | ) |
!colorbar | ( | ) |
!contour | ( | x | ) |
!demo ! clf !contour | ( | peaks() | ) |
!imagesc | ( | y | , | |
x | , | |||
1./ | hilbn | |||
) |
!imagesc | ( | x | , | |
y | , | |||
1./ | hilbn | |||
) |
!imagesc | ( | 1./ | hilbn | ) |
!demo ! clf !imagesc | ( | log10(1./hilb(99)) | ) |
!demo ! clf !imagesc | ( | 1./ | hilb99 | ) |
!imagesc | ( | x | ) |
!set | ( | h | , | |
"yticklabel" | , | |||
sprintf('10^{%g}|', ytick) | ||||
) |
!set | ( | h | , | |
'yscale' | , | |||
'log' | ||||
) |
!subplot | ( | 2 | , | |
1 | , | |||
2 | ||||
) |
!subplot | ( | 2 | , | |
1 | , | |||
1 | ||||
) |
!subplot | ( | 1 | , | |
2 | , | |||
2 | ||||
) |
!subplot | ( | 1 | , | |
2 | , | |||
1 | ||||
) |
!subplot | ( | 2 | , | |
2 | , | |||
4 | ||||
) |
!subplot | ( | 2 | , | |
2 | , | |||
3 | ||||
) |
!subplot | ( | 2 | , | |
2 | , | |||
2 | ||||
) |
!demo ! clf !subplot | ( | 2 | , | |
2 | , | |||
1 | ||||
) |
!xlim | ( | ) |
!ylim | ( | ) |
addlistener | ( | ax | , | |
"clim" | ||||
) |
addproperty | ( | "axes" | , | |
cax | , | |||
"handle" | , | |||
ax | ||||
) |
addproperty | ( | "location" | , | |
cax | , | |||
"radio" | , | |||
"eastoutside|east|westoutside|west|northoutside|north|southoutside|south" | , | |||
loc | ||||
) |
cpos | ( | 4 | ) |
cpos | ( | 2 | ) |
cpos | ( | 3 | ) |
cpos | ( | 1 | ) |
endif endfunction function deletecolorbar | ( | h | , | |
d | , | |||
hc | , | |||
pos | , | |||
opos | ||||
) |
elseif | ( | strcmpi(arg,"off")||strcmpi(arg,"none") | ) |
endif endif elseif | ( | strcmpi(arg,"north")||strcmpi(arg,"south")||strcmpi(arg,"east")||strcmpi(arg,"west")||strcmpi(arg,"northoutside")||strcmpi(arg,"southoutside")||strcmpi(arg,"eastoutside")||strcmpi(arg,"westoutside") | ) |
endif if | ( | sz(1) | , | |
sz(2) | ||||
) |
if | ( | strfind(cbox,"outside") | ) |
if | ( | pos(3) | , | |
pos(4) | ||||
) |
if | ( | strcmpi(obj.dataaspectratiomode,"manual") | ) |
if | ( | vert | ) |
endif if | ( | ! | isemptyancestor(h,"axes"))&&strcmp(get(ancestor(h,"axes"),"beingdeleted"),"off" | ) |
if | ( | mirror | ) |
if | ( | vertical | ) |
if | ( | ! | isemptycax | ) |
if | ( | ischar(arg) | ) |
endif endif endfunction function axes && isempty | ( | gcbf() | ) |
pos | ( | 1 | ) |
pos | ( | 3 | ) | [pure virtual] |
pos | ( | 2 | ) |
pos | ( | 4 | ) | [pure virtual] |
endif endif endfunction function resetaxis | ( | h | , | |
d | , | |||
pos | , | |||
opos | ||||
) |
else set | ( | cax | , | |
"ytick" | , | |||
"xdir" | , | |||
"normal" | , | |||
"ydir" | , | |||
"normal" | , | |||
"xaxislocation" | , | |||
"bottom" | , | |||
"position" | , | |||
cpos | ||||
) |
else set | ( | cax | , | |
"xtick" | , | |||
"xdir" | , | |||
"normal" | , | |||
"ydir" | , | |||
"normal" | , | |||
"yaxislocation" | , | |||
"left" | , | |||
"position" | , | |||
cpos | ||||
) |
set | ( | cax | , | |
"deletefcn" | ||||
) |
else set | ( | cax | , | |
"ytick" | , | |||
"xdir" | , | |||
"normal" | , | |||
"ydir" | , | |||
"normal" | , | |||
"xlim" | , | |||
cext | , | |||
"xlimmode" | , | |||
"manual" | , | |||
"xaxislocation" | , | |||
"bottom" | ||||
) |
else set | ( | cax | , | |
"xtick" | , | |||
"xdir" | , | |||
"normal" | , | |||
"ydir" | , | |||
"normal" | , | |||
"ylim" | , | |||
cext | , | |||
"ylimmode" | , | |||
"manual" | , | |||
"yaxislocation" | , | |||
"left" | ||||
) |
set | ( | ax | , | |
"activepositionproperty" | , | |||
"position" | , | |||
"position" | , | |||
pos | ||||
) |
endif unwind_protect_cleanup set | ( | 0 | , | |
"showhiddenhandles" | , | |||
showhiddenhandles | ||||
) |
endif endif endfunction function update_colorbar_axis | ( | h | , | |
d | , | |||
cax | ||||
) |
endif endfunction function update_colorbar_clim | ( | h | , | |
d | , | |||
hi | , | |||
vert | ||||
) |
while | ( | i<= | nargin | ) |
!h = colorbar |
colorbar !demo ! clf !n = 64 |
!ytick = get(h, "ytick") |
actual_pos = __actual_axis_position__ (obj) |
args = {} |
cext = get (ax, "clim") |
Initial value:
text (0, 0, "", "tag", "colorbar","visible", "off", "handlevisibility", "off", "xliminclude", "off", "yliminclude", "off", "zliminclude", "off", "deletefcn", {@deletecolorbar, cax, orig_pos, orig_opos})
view endif dataaspectratio |
deleting = false |
else dy = (1-scale)*actual_pos(4) |
axis equal |
i = 1 |
mirr = true |
obj = get (h) |
margin obj position = obj.position |
else scale = 0.9 |
unwind_protect set(0,"showhiddenhandles","on") cax = findobj (get (ax, "parent"), "tag", "colorbar", "type", "axes", "axes", ax) |
endif showhiddenhandles = get (0, "showhiddenhandles") |
sz = pos(3:4) |
vertical = false |
x = kron (1:n,ones(n,1)) |
y = linspace(0,1,n) |