Wednesday 6 August 2014

How to add colorbar ( adjust its size and label) to a plot in Matlab?

1. Use 'colorbar'

c=colorbar('vert'); % vert adds colorbar to z-axis values. 'horiz' adds color bar to x-values.

2. Reduce the size of the colorbar

xa1=get(gca,'position');
xa=get(c,'Position');
xa(3)=0.03;
xa(4)=0.65;

set(c,'Position',xa)

3. Adding title to the colorbar (this sits on top)

title(c,'Hz')

4. Adding ylabel to it (along vertical axis)

ylabel('Error')

Example:


No comments:

Post a Comment