필터 지우기
필터 지우기

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 CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by