To define the axes for just one subplot colorabar

5 次查看(过去 30 天)
*For subplot(1,7,5)- I want to define the range of colorabar [0 6]*
subplot(1,7,4)
m_proj('Stereographic','lat',90,'long',300,'radius',35,'rect','on');
m_contourf(long,lat,oct_skw_anom ,'linestyle','none');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 76 80 84 88 90]);
m_coast('patch',[.6 .6 .6],'edgecolor','k');
m_elev('contour',[ ],'edgecolor',' ');
colorbar( 'location','southoutside');
subplot(1,7,5)
m_proj('Stereographic','lat',90,'long',300,'radius',35,'rect','on');
m_contourf(long,lat,oct_kts_anom ,'linestyle','none');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 76 80 84 88 90]);
m_coast('patch',[.6 .6 .6],'edgecolor','k');
m_elev('contour',[ ],'edgecolor',' ');
caxis = ([0, 6]);
h = colorbar(caxis, 'southoutside');
  1 个评论
Muhammad Usman Saleem
there is an error
Undefined function 'm_proj' for input arguments of type 'char'.
in this line
m_proj('Stereographic','lat',90,'long',300,'radius',35,'rect','on');

请先登录,再进行评论。

采纳的回答

Mike Garrity
Mike Garrity 2016-4-13
There are two different things you could mean here.
One is that you want the colormap to start where the data = 0 and end where the data = 6. You actually do that with the axes object, not the colorbar. The colorbar is just showing the mapping that the axes is using.
The subplot command returns a handle to the axes. So you'd want to do something like this:
ax = subplot(1,7,5)
m_proj('Stereographic','lat',90,'long',300,'radius',35,'rect','on');
m_contourf(long,lat,oct_kts_anom ,'linestyle','none');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 76 80 84 88 90]);
m_coast('patch',[.6 .6 .6],'edgecolor','k');
m_elev('contour',[ ],'edgecolor',' ');
caxis(ax,[0 6])
colorbar('southoutside')
Note, you had a variable named caxis, that's also the name of the function you use to set the color range on the axes, so you might get a conflict there. You probably want to rename that variable and clear it from your workspace.
The other thing you might mean here is that you only want the colorbar to show a portion of the color range. This won't change the mapping between data values and colors. It's just like "zooming in" on the colorbar. The details of how you do this has changed a bit in the last couple of versions of MATLAB, but in R2016a, you would do this:
c = colorbar('southoutside');
c.Limits = [0 6];
or this:
colorbar('southoutside','Limits',[0 6])
  6 个评论
Muhammad Usman Saleem
I got confuse, whether this simile is for me or for some other comments? =D

请先登录,再进行评论。

更多回答(1 个)

Muhammad Usman Saleem
编辑:Muhammad Usman Saleem 2016-4-13
For setting range of your own desire, try this please
caxis([0, 6])
>> colorbar
Usman

类别

Help CenterFile Exchange 中查找有关 Orange 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by