I have the following subplot, and to print the images I'm using the imagesc
command. How can I make the size of the color bar matching the two plots and a label stating "[m]" or "[deg]" just right next to the color bar (written with horizontal alignment)?
f_prova3 = figure();
s1 = subplot(1,2,1); imagesc(DEM); axis equal; axis off;
hb1 = colorbar('location','eastoutside');
s2 = subplot(1,2,2); imagesc(slopeMap_int); colormap jet, axis equal;axis off;
hb2 = colorbar('location','eastoutside');
Sorry, it seems I can not add the image directly. Thanks for Your help
You can add axis tight
to adjust the height and use label properties to adjust the labels:
DEM = magic(5);
slopeMap_int = magic(5);
f_prova3 = figure();
s1 = subplot(1,2,1); imagesc(DEM); axis equal; axis tight; axis off;
hb1 = colorbar('location','eastoutside');
s2 = subplot(1,2,2); imagesc(slopeMap_int); colormap jet; axis equal; axis tight; axis off;
hb2 = colorbar('location','eastoutside');
hb1.Label.String = '[m]';
hb1.Label.Rotation = 0;
hb1.Label.HorizontalAlignment = 'Left';
hb2.Label.String = '[deg]';
hb2.Label.Rotation = 0;
hb2.Label.HorizontalAlignment = 'Left';
I tested in Matlab R2016a.