How can I change the line colour in a geoplot based on data?

19 次查看(过去 30 天)
I am using the geoplot function to track different fishing boat movements and wanted the lines to have different colours based on the fishing method used; eg blue for trawling, yellow for nets, red for lines. I have tried a few different commands but haven't had any luck yet. Below is the code used to generate the geoplots so far:
boat = readtable('2014S.xlsx');
figure
lat1 = boat.Latitude(vms.ID == 1);
lon1 = boat.Longitude(vms.ID == 1);
geoplot(lat1,lon1,'.-','DisplayName','1');
hold on
lat2 = boat.Latitude(vms.ID == 2);
lon2 = boat.Longitude(vms.ID == 2);
geoplot(lat2,lon2,'.-','DisplayName','2');
lat3 = boat.Latitude(vms.ID == 3);
lon3 = boat.Longitude(vms.ID == 3);
geoplot(lat3,lon3,'.-','DisplayName','3');
%GeoLimits
nlat = [49.1500 51.0000];
nlon = [-7.0000 -4.3000];
%Legend
lgd = legend;
lgd.FontSize = 12;
lgd.Title.String = '2014 Data';

回答(1 个)

darova
darova 2021-8-9
Try set
h1 = geoplot(..);
set(h1,'color','r')
  2 个评论
BRENDON QUEIROZ
BRENDON QUEIROZ 2021-8-9
Thank you, that has helped me change the colour freely but I want to have each boat to be coloured based on the fishing method they used which I have in my original data spreadsheet. Is there a way I can do that?
darova
darova 2021-8-11
Maybe you mean this
[x,y] = pol2cart((0:.1:2*pi),1);
% x(end) = nan;
cmap = rand(5,3); % 5 colors - 5 methods (RGB columns)
ii = randi(5,[numel(x) 1]); % numbers 1 .. 5
cmap = cmap(ii,:); % mix colors
p.vertices = [x(:) y(:)]; % points
tmp = 1:numel(x);
p.faces = [1:tmp(end-1); 2:tmp(end)]'; % connection of points
p.faceVertexCData = cmap; % color data
patch(p,'edgecolor','interp','linewidth',2)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by