フィルターのクリア

Plotting filled contours on top of worldmap

14 ビュー (過去 30 日間)
Mathan
Mathan 2022 年 6 月 4 日
コメント済み: Voss 2022 年 6 月 4 日
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 件のコメント
Mathan
Mathan 2022 年 6 月 4 日
Ah ok..I get that now. Thank you so much.
Voss
Voss 2022 年 6 月 4 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by