Plotting filled contours on top of worldmap

37 次查看(过去 30 天)
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

采纳的回答

Voss
Voss 2022-6-4
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 个评论

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by