To define the axes for just one subplot colorabar

5 ビュー (過去 30 日間)
Sophia
Sophia 2016 年 4 月 12 日
*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
Muhammad Usman Saleem 2016 年 4 月 13 日
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 件のコメント
Sophia
Sophia 2016 年 4 月 13 日
Thanks this works too..:-)
Muhammad Usman Saleem
Muhammad Usman Saleem 2016 年 4 月 14 日
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 日
編集済み: Muhammad Usman Saleem 2016 年 4 月 13 日
For setting range of your own desire, try this please
caxis([0, 6])
>> colorbar
Usman
  1 件のコメント
Sophia
Sophia 2016 年 4 月 13 日
Thanks it works!

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by