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

17 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 27 Mai 2022
Bearbeitet: Cris LaPierre am 27 Mai 2022
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

Weitere Antworten (0)

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by