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!
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!