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';
0 个评论
回答(1 个)
darova
2021-8-9
Try set
h1 = geoplot(..);
set(h1,'color','r')
2 个评论
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 Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!