Error using cbarf colorbar

Hey there, I am trying to plot a colorbar next to my contourplot like this:
m_proj('mollweid','clong',180);
m_contourf(Lon_coord,Lat_coord,Inc,36);
cbarf(Inc,36,'vertical','linear');
So I am plotting magnetic inclination for earths surface via longitude and latitude. The plot works very well but the cbarf returns the following error:
??? Error using ==> set
Bad property value found.
Object Name : axes
Property Name : 'YLim'
Values must be increasing and non-NaN.
Error in ==> ylim at 44
set(ax,'ylim',val);
Error in ==> cbarf at 224
ylim(yl)
Error in ==> jkb_script at 49
cbarf(Inc,36,'vertical','linear');
There is a script of my professor which uses cbarf quite similar so it shouldn't be very wrong. Maybe the projection applies settings to the axes that confuse cbar? Thanks for your help!
Jakob

댓글 수: 1

Image Analyst
Image Analyst 2011년 11월 29일
cbarf? Isn't that what happens when you go to a college party?

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 29일

0 개 추천

Glancing at the code it appears to me that that problem would occur if you only specify one level.
I did not run the code through a debugger to be sure of that, however.

댓글 수: 5

Jakob
Jakob 2011년 11월 29일
Do you mean one contour level?
There are supposed to be 36 levels for a range of 180.
Walter Roberson
Walter Roberson 2011년 11월 29일
I do not see any support in the cbarf file contribution for the possibility of specifying the number of levels, just the actual levels.
Jakob
Jakob 2011년 11월 29일
But they are the same in both arguments anyway.
I'm sorry but I don't really get your point.
Walter Roberson
Walter Roberson 2011년 11월 29일
You are using a user-contribution, cbarf, not a MATLAB provided routine, and expecting that the behavior for it will match that of a completely different user-contribution, m_contourf, by a different author, from the m_map package at http://www.eos.ubc.ca/~rich/private/mapug.html -- a behavior that the documentation for the second user-contribution does not describe as existing but which happens to work.
The work-around to bring the contributions in to alignment is to extract the levels chosen by the contour routine.
[c, h] = m_contourf(Lon_coord,Lat_coord,Inc,36);
clear c
levels = get(h,'LevelList');
cbarf(Inc,levels,'vertical','linear');
Jakob
Jakob 2011년 11월 29일
Thank you very much! That solved it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

질문:

2011년 11월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by