How to define the colorbar for subplots

조회 수: 5 (최근 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 CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by