This questions is vaguely answered elsewhere. Therefore, please answer it before down voting and marking it as duplicate. I have searched Stackoverflow and MATLAB forum
I am trying to plot the spatial plot of India (see below), with multiple subplots. Here I want to use one representative color bar as shown in the figure.
The color bar which I am getting is for the last subplots, and it's values does not corresponds with other subplots.
Below is, how I am trying to add the color bar and respective output
ax(1)=subplot(2,3,1)
worldmap('India');
shape=shaperead('India.shp', 'UseGeoCoords', true);
geoshow(shape, 'FaceColor', 'w')
hold on
geoshow(lat,lon,data_fill, 'DisplayType', 'surface');
colormap('hsv');
.
.
.
ax(6)=subplot(2,3,6)
worldmap('India');
shape=shaperead('India.shp', 'UseGeoCoords', true);
geoshow(shape, 'FaceColor', 'w')
hold on
geoshow(lat,lon,data_fill, 'DisplayType', 'surface');
colormap('hsv');
h=colorbar;
cmin = min(data_fill_of_all_sub_plot);
cmax = max(data_fill_of_all_sub_plot);
if mod(cmax,5)==0
cmax=cmax+5;
else
cmax=cmax+(5-mod(cmax,5));
end
caxis([cmin cmax]) % to fix the colormap scale
set(h, 'Position', [.95 .42 .01 .5])
Output
How to put a single color bar for all the subplots?
