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 comentario

Image Analyst
Image Analyst el 29 de Nov. de 2011
cbarf? Isn't that what happens when you go to a college party?

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Nov. de 2011

0 votos

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 comentarios

Jakob
Jakob el 29 de Nov. de 2011
Do you mean one contour level?
There are supposed to be 36 levels for a range of 180.
Walter Roberson
Walter Roberson el 29 de Nov. de 2011
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 el 29 de Nov. de 2011
But they are the same in both arguments anyway.
I'm sorry but I don't really get your point.
Walter Roberson
Walter Roberson el 29 de Nov. de 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 el 29 de Nov. de 2011
Thank you very much! That solved it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Nov. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by