How to define the colorbar for subplots
5 次查看(过去 30 天)
显示 更早的评论
I have 10 subplots in a figure i want to define one colorbar for the whole figure, However the contour range is different for all the plots
% To plot the mean sea ice drift
left1 = 0.42;
cb_bottom = 0.08 ;
cb_width = 0.20 ;
cb_height = 0.02 ;
subplot(2,5,6)
hold on;
m_proj('stereographic','lat',90,'long',300,'radius',33,'rect','on');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 78 84 90]);
m_contourf(long,lat,mdmn_wr,'linestyle','none');
m_coast('patch',[.6 .6 .6]);
xlabel('Mean of Median Winter Sea Ice Drift 1979-2014','visible','on')
% To plot the median sea ice drift
subplot(2,5,7)
hold on;
m_proj('stereographic','lat',90,'long',300,'radius',33,'rect','on');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 78 84 90]);
m_contourf(long,lat,mdn_wr,'linestyle','none');
m_coast('patch',[.6 .6 .6]);
xlabel('Median Winter Sea Ice Drift 1979-2014','visible','on')
% To plot the standard deviation of sea ice drift
subplot(2,5,8)
hold on;
m_proj('stereographic','lat',90,'long',300,'radius',33,'rect','on');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 78 84 90]);
m_contourf(long,lat,std_mdn_wr,'linestyle','none');
m_coast('patch',[.6 .6 .6]);
xlabel('Standard Deviation of Median Winter Sea Ice Drift 1979-2014','visible','on')
% To plot the Skewness of sea ice drift
subplot(2,5,9)
hold on;
m_proj('stereographic','lat',90,'long',300,'radius',33,'rect','on');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 78 84 90]);
m_contourf(long,lat,skw_mdn_wr,'linestyle','none');
m_coast('patch',[.6 .6 .6]);
xlabel(' Skewness of Median Winter Sea Ice Drift 1979-2014','visible','on')
% To plot the flatness of sea ice drift
subplot(2,5,10)
hold on;
m_proj('stereographic','lat',90,'long',300,'radius',33,'rect','on');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 78 84 90]);
m_contourf(long,lat,kts_mdn_wr,'linestyle','none');
m_coast('patch',[.6 .6 .6]);
xlabel(' Kurtosis of Median Winter Sea Ice Drift 1979-2014','visible','on')
h = colorbar;
set(h,'location','southoutside',...
'position',[left1 cb_bottom cb_width cb_height] );
4 个评论
采纳的回答
Walter Roberson
2016-4-6
colorbar are associated with axes, but each subplot is its own axes.
To get a colorbar spanning the whole range, it would have to be associated with an axes whose caxis property was the whole range. You might want to create an axes for this purpose. You do not need to plot anything in the axes, and it could have its box turned off, no labels, background color 'none' and so on. You just have to be careful about the positioning: any subplot() call afterwards that would overlap that axes will have the effect of deleting the axes.
4 个评论
Walter Roberson
2016-4-8
h = colorbar('peer', cbax, 'southoutside', ...
'position', [left1 cb_bottom cb_width cb_height] );
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!