Need help with Plots

Hi everyone,
I am trying to plot a map. I was given a file with coastlines which I mapped using "load" and "plot". Now I am trying to add a set of values to the map using "pcolor" the issue is that when I try to plot it it looks like this: http://img267.imageshack.us/i/matlabb.png/
The plot on the left is my failed map, the black box being the plot on the right. I am trying to plot that values on the right onto the map but it doesn't look right =S.
Any suggestions on how I would go about this?

 Réponse acceptée

Matt Tearle
Matt Tearle le 17 Fév 2011

0 votes

Or is the problem that the colors should cover the whole map (instead of a small box in the middle)? In which case the problem is that the x & y values are indices (1 to 38 or so) instead of actual x/y values. In that case, you need to define some x & y coordinates to map the 38 pixels to 360/180 degrees, and then do pcolor(x,y,z)

5 commentaires

Andrew
Andrew le 17 Fév 2011
This might be my problem I think that I need the colors set to the entire map xD. How would I go about defining the x/y coordinates to map the 360/180.
Matt Tearle
Matt Tearle le 17 Fév 2011
Depends on the math! But assuming it's just a linear scaling, use
[m,n] = size(z);
x = linspace(-180,180,n);
y = linspace(-90,90,n);
Matt Tearle
Matt Tearle le 17 Fév 2011
D'oh. m, not n for y.
Andrew
Andrew le 17 Fév 2011
Thanks it worked!
Matt Tearle
Matt Tearle le 17 Fév 2011
:)
And thanks for the feedback

Connectez-vous pour commenter.

Plus de réponses (1)

Matt Tearle
Matt Tearle le 17 Fév 2011

0 votes

It's hard to tell exactly from the image, but it looks like maybe it's just the lines that make it look like a black box. Try turning them off:
h = pcolor(...);
set(h,'linestyle','none')

1 commentaire

Andrew
Andrew le 17 Fév 2011
Ah, that made the colors go on. I don't think the area should be just right there though xD. It's hard to explain how I got those colors but its related to spherical harmonics. I can post all my code if needed

Connectez-vous pour commenter.

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by