How can I change the line colour in a geoplot based on data?
38 ビュー (過去 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!