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

조회 수: 34 (최근 30일)
BRENDON QUEIROZ
BRENDON QUEIROZ 2021년 8월 9일
댓글: darova 2021년 8월 11일
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