How to plot points on map axes with varying colors using scatterm?
Show older comments
I have three vectors: lat, lon, depth. They are of equal length. When I run the code below, I get an error saying: Error using scatter
Color must be one RGB triplet, an m-by-3 matrix of RGB triplets with one color per scatter point, or an m-by-1 vector with one value per scatter point.". I don't understand, because my depth vector, which is being used for color, is the same size as my latitude vector.
%Load in data
data = readmatrix("Lin14_cores.csv","NumHeaderLines",1);
lon = data(:,1);
lat = data(:,2);
depth = data(:,4);
%Plot datapoints on map axes with colors showing depth
load coastlines
ax = axesm("MapProjection","mollweid","MapLatLimit",[-60 60], "MapLonLimit",[-180 180], 'Frame', 'on');
plotm(coastlat,coastlon)
scatterm(ax, lat,lon, ones(length(lat))*50, depth);
colormap("autumn")
Can anyone help me fix this.
Accepted Answer
More Answers (1)
Manas
on 16 Jun 2023
0 votes
Hi Samuel,
Can you provide the coastlines file?
Also, you can checkout this answer and try out if it works for you
Categories
Find more on Thematic Maps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!