フィルターのクリア

How can I plot lat lon and z-data with changing colors?

17 ビュー (過去 30 日間)
Jeremy Salerno
Jeremy Salerno 2022 年 5 月 27 日
編集済み: Cris LaPierre 2022 年 5 月 27 日
I am new to the mapping toolbox, and MATLAB.
I am attempting to simply plot sea level values according to to lat and lon. I would like the color of the data point to be tied to the value of the sea level, so changing based on some standard colormap.
I reviewed and tried editing my code based on this thread. But, I am receiving a strange error related to the map axes.
figure(1)
load coastlines
q=plot(coastlon,coastlat,'k');
hold on
h=scatterm(lat,lon,z_sea_surface,'.', 'MarkerSize', 20)
hold off
When I run this snippet with my data, it gives back this error:
Error using gcm
Not a map axes.
Error in scatterm (line 48)
gcm(ax);
Error in pull_in_netcdf_data (line 105)
h=scatterm(lat,lon,z_sea_surface,'.', 'MarkerSize', 20)
What am I doing wrong? Thanks!

採用された回答

Cris LaPierre
Cris LaPierre 2022 年 5 月 27 日
編集済み: Cris LaPierre 2022 年 5 月 27 日
A couple of the mapping plotting functions come to mind. Your Z value is used to determine the color.
The error you are seeing is because you first use the plot command. That plots to a cartesian axes, not a map axes. You need to create the map axes first. maybe try something like this (untested)?
figure(1)
load coastlines
q=plotm(coastlon,coastlat,'k');
hold on
h=scatterm(lat,lon,z_sea_surface,'.', 'MarkerSize', 20)
hold off

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by