V_CBLABEL add a label to a colorbar c=(l,h) Inputs: L Label string for colorbar H Handle of the colorbar, axis or figure [default = current figure] Outputs: C Handle of the colorbar
0001 function c=v_cblabel(l,h) 0002 %V_CBLABEL add a label to a colorbar c=(l,h) 0003 % 0004 % Inputs: 0005 % 0006 % L Label string for colorbar 0007 % H Handle of the colorbar, axis or figure [default = current figure] 0008 % 0009 % Outputs: 0010 % 0011 % C Handle of the colorbar 0012 0013 % Copyright (C) Mike Brookes 2000-2009 0014 % Version: $Id: v_cblabel.m 10865 2018-09-21 17:22:45Z dmb $ 0015 % 0016 % VOICEBOX is a MATLAB toolbox for speech processing. 0017 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 0018 % 0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0020 % This program is free software; you can redistribute it and/or modify 0021 % it under the terms of the GNU General Public License as published by 0022 % the Free Software Foundation; either version 2 of the License, or 0023 % (at your option) any later version. 0024 % 0025 % This program is distributed in the hope that it will be useful, 0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0028 % GNU General Public License for more details. 0029 % 0030 % You can obtain a copy of the GNU General Public License from 0031 % http://www.gnu.org/copyleft/gpl.html or by writing to 0032 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0034 0035 if nargin<2 0036 h=gcf; 0037 end 0038 switch get(h,'Type') 0039 case 'axes' 0040 if strcmp(get(h,'Tag'),'Colorbar') 0041 c=h; 0042 else 0043 while ~strcmp(get(h,'Type'),'figure') 0044 h=get(h,'Parent'); % find parent figure 0045 if h==0 0046 error('cannot find parent figure'); 0047 end 0048 end 0049 c=findobj(h,'tag','Colorbar'); 0050 if isempty(c) 0051 error('There is no colour bar on this figure') 0052 end 0053 % we could look for the nearest colorbar to the selected axes 0054 c=c(1); % for now use the most recently added colorbar 0055 end 0056 case 'figure' 0057 c=findobj(h,'tag','Colorbar'); 0058 if isempty(c) 0059 error('There is no colour bar on this figure') 0060 end 0061 c=c(1); % use the most recently added colorbar 0062 otherwise 0063 error('h argument must be colorbar, axis or figure handle'); 0064 end 0065 set(get(c,'ylabel'),'string',l);