How to define the colorbar for subplots

6 ビュー (過去 30 日間)
Sophia
Sophia 2016 年 4 月 6 日
コメント済み: Walter Roberson 2016 年 4 月 8 日
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
Walter Roberson 2016 年 4 月 7 日
m_proj is from the M_map toolbox http://www.eos.ubc.ca/~rich/map.html
Sophia
Sophia 2016 年 4 月 8 日
Muhammad Usman Saleem.. You need m_map toolbox in your matlab path to make it work.

サインインしてコメントする。

採用された回答

Walter Roberson
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 件のコメント
Sophia
Sophia 2016 年 4 月 8 日
Error using scribe\private\colorbarv6 Too many input arguments.
cbar = colorbarv6(varargin{:});
Walter Roberson
Walter Roberson 2016 年 4 月 8 日
h = colorbar('peer', cbax, 'southoutside', ...
'position', [left1 cb_bottom cb_width cb_height] );

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by