Error using cbarf colorbar

1 view (last 30 days)
Jakob
Jakob on 28 Nov 2011
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 Comment
Image Analyst
Image Analyst on 29 Nov 2011
cbarf? Isn't that what happens when you go to a college party?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 29 Nov 2011
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 Comments
Walter Roberson
Walter Roberson on 29 Nov 2011
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 on 29 Nov 2011
Thank you very much! That solved it.

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!