Plotting filled contours on top of worldmap

37 vues (au cours des 30 derniers jours)
Mathan
Mathan le 4 Juin 2022
Commenté : Voss le 4 Juin 2022
Hi all,
I was trying to plot a filled contour on top of a worldmap but for some reason one of the values seem to be drawn all over the map as shown. I used the following code:
lat = 30:5:75;
lon = 5:5:50;
temp = [20, 18, 45, 53, 5, 44, 13, 11, 35, 48];
lat=reshape(lat,2,[]);
lon=reshape(lon,2,[]);
temp=reshape(temp,2,[]);
load coastlines
worldmap('world')
contourfm(lat,lon,temp)
geoshow(coastlat,coastlon,'color','k')
contourcbar
colormap(jet)
However the following block of code with contourm is giving a contour line with all the different colors (values) in temp plotted:
lat = 30:5:75;
lon = 5:5:50;
temp = [20, 18, 45, 53, 5, 44, 13, 11, 35, 48];
lat=reshape(lat,2,[]);
lon=reshape(lon,2,[]);
temp=reshape(temp,2,[]);
load coastlines
worldmap('world')
contourm(lon,lat,temp)
geoshow(coastlat,coastlon,'color','k')
contourcbar
colormap(jet)
Wondering how to get the same while using contourfm and a worldmap, and where I have been doing it wrong.
Thanks

Réponse acceptée

Voss
Voss le 4 Juin 2022
I'm not able to see the problem as described, using the data posted.
However, check the order of the arguments you're using in contourm. You have contourm(lon,lat,temp), but contourfm(lat,lon,temp).
lat should be first in both.
lat = -85:5:85;
lon = -175:5:175;
[lat,lon] = meshgrid(lat,lon);
temp = 5+48*rand(size(lat));
figure()
load coastlines
worldmap('world')
contourfm(lat,lon,temp)
geoshow(coastlat,coastlon,'color','k')
contourcbar
colormap(jet)
figure()
load coastlines
worldmap('world')
% contourm(lon,lat,temp)
contourm(lat,lon,temp)
geoshow(coastlat,coastlon,'color','k')
contourcbar
colormap(jet)
  6 commentaires
Mathan
Mathan le 4 Juin 2022
Ah ok..I get that now. Thank you so much.
Voss
Voss le 4 Juin 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by