Legend colors do not match plot colors.
显示 更早的评论
I have an Excel file (attached) that contains the latitude and longitude, starting and ending, for 198 tornadoes that occured between 2008 and 2018. I have a program (below) that plots each set of coordinates and colors it according to year. However, the legend colors do not match the plot colors. I have checked several of the questions posted here, but none seem to deal with for loops and if statements. Any help would be greatly appreciated! An if anyone can provide guidance on adding a scale ruler to this project, I would be greatful.
c01 = [0.2422 0.1504 0.6603];
c02 = [0.2803 0.2782 0.9221];
c03 = [0.2440 0.4358 0.9988];
c04 = [0.1540 0.5902 0.9218];
c05 = [0.0297 0.7082 0.8163];
c06 = [0.1938 0.7758 0.6251];
c07 = [0.5044 0.7993 0.3480];
c08 = [0.8634 0.7406 0.1596];
c09 = [0.9892 0.8136 0.1885];
c10 = [0.9769 0.9839 0.0805];
c11 = [0.2791 0.2625 0.9064];
data = xlsread('Tornado Data - 4th Clean No Duplicate Entries.xlsm');
for x = 1:length(data)
if data(x,2) == 2008
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c01,'Marker','*')
hold on;
elseif data(x,2) == 2009
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c02,'Marker','*')
hold on;
elseif data(x,2) == 2010
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c03,'Marker','*')
hold on;
elseif data(x,2) == 2011
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c04,'Marker','*')
hold on;
elseif data(x,2) == 2012
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c05,'Marker','*')
hold on;
elseif data(x,2) == 2013
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c06,'Marker','*')
hold on;
elseif data(x,2) == 2014
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c07,'Marker','*')
hold on;
elseif data(x,2) == 2015
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c08,'Marker','*')
hold on;
elseif data(x,2) == 2016
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c09,'Marker','*')
hold on;
elseif data(x,2) == 2017
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c10,'Marker','*')
hold on;
else
geoplot([data(x,8) data(x,10)],[data(x,9) data(x,11)],...
'LineWidth',0.5,'Color',c11,'Marker','*')
hold on;
end
end
lgd = legend({'2008','2009','2010','2011','2012','2013','2014','2015','2016','2017','2018'},'Location','eastoutside');
title(lgd,'Year')
geobasemap('colorterrain')
title('Tornado Strikes 2008 - 2018')
2 个评论
Jason Brown
2019-1-31
编辑:Walter Roberson
2019-1-31
Kevin Phung
2019-1-31
are the dates not in order?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!