To define the axes for just one subplot colorabar

조회 수: 1 (최근 30일)
Sophia
Sophia 2016년 4월 12일
댓글: Muhammad Usman Saleem 2016년 4월 14일
*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

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by