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

18 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by