# Plotting filled contours on top of worldmap

5 views (last 30 days)
Mathan on 4 Jun 2022
Commented: Voss on 4 Jun 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,[]);
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,[]);
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 on 4 Jun 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()
worldmap('world')
contourfm(lat,lon,temp)
geoshow(coastlat,coastlon,'color','k')
contourcbar
colormap(jet)
figure()
worldmap('world')
% contourm(lon,lat,temp)
contourm(lat,lon,temp)
geoshow(coastlat,coastlon,'color','k')
contourcbar
colormap(jet)
Voss on 4 Jun 2022
You're welcome!