How to define the colorbar for subplots
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sophia
el 6 de Abr. de 2016
Comentada: Walter Roberson
el 8 de Abr. de 2016
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] );
Respuesta aceptada
Walter Roberson
el 6 de Abr. de 2016
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 comentarios
Walter Roberson
el 8 de Abr. de 2016
h = colorbar('peer', cbax, 'southoutside', ...
'position', [left1 cb_bottom cb_width cb_height] );
Más respuestas (0)
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!