In order to keep the y-axis tick values from being changed when the figure is resized, you will have to either explicitly set the 'YTick'
property or set the 'YTickMode'
property to 'manual'
(to keep it from being automatically changed). You may also have to explicitly set the 'YLim'
property as well (or set the 'YLimMode'
property to 'manual'
) to keep the limits of the color bar from changing. Here's one possible solution:
labels = get(ch,'YTickLabel'); %# Get the current labels
set(ch,'YLimMode','manual',... %# Freeze the current limits
'YTickMode','manual',... %# Freeze the current tick values
'YTickLabel',strcat(labels,{' dB'})); %# Change the labels
You can also define the tick properties when you create the color bar in your initial call to the COLORBAR function. For example, if you know you will want to have 3 tick values at 10, 20, and 30 with "dB" added to the labels, you can create the color bar in the following way:
ch = colorbar('YLim',[10 30],... &# The axis limits
'YTick',[10 20 30],... %# The tick locations
'YTickLabel',{'10 dB','20 dB','30 dB'}); %# The tick labels
These limits, tick values, and tick labels should also remain unchanged when the figure is resized.