


FIND_COLORBAR Finds the colorbar associated with a given axes. CBARAX = FIND_COLORBAR(AX) returns the handle of the colorbar associated with the axes AX. If no colorbar is found, CBAR_AX will be empty.


0001 function cbarax = find_colorbar(ax) 0002 %FIND_COLORBAR Finds the colorbar associated with a given axes. 0003 % CBARAX = FIND_COLORBAR(AX) returns the handle of the colorbar 0004 % associated with the axes AX. If no colorbar is found, CBAR_AX will be 0005 % empty. 0006 0007 %%%%% TMW's COLORBAR function creates a hidden proxy text object in a 0008 %%%%% plot when it associates a colorbar with it. 0009 shh = get(0, 'ShowHiddenHandles'); set(0, 'ShowHiddenHandles', 'on'); 0010 proxy = findobj(get(ax, 'Children'), 'Tag', 'ColorbarDeleteProxy'); 0011 set(0, 'ShowHiddenHandles', shh); 0012 0013 %%%%% The proxy's UserData contains a handle to the colorbar ... 0014 cbarax = get(proxy, 'UserData'); % (get will return [] if proxy is [])