World map scatterm legend issue

2 次查看(过去 30 天)
Quentin D
Quentin D 2019-2-14
Hi everyone!
I'm trying to plot a range of location (deposits) on a world map through scatterm.
The size of the circle is proportionnal to 'Tonnage" and the color depends on "Type"
I managed to get the plot I want except that the legend is only showing one entry!
I get the following warning:
Warning: Ignoring extra legend entries.
> In legend>process_inputs (line 566)
In legend>make_legend (line 310)
In legend (line 261)
In Map (line 32)
[num, txt]= xlsread( 'Map.xlsx');
Name=txt(2:end,1);
Country=txt(2:end,2);
Type=txt(2:end,3);
Lat=num(:,1);
Long=num(:,2);
Tonnage=num(:,3);
worldmap world
geoshow('landareas.shp', 'FaceColor', [0.9 0.9 0.9]);
Area=10+400*rescale(Content);
[Types, ~, idx] = unique(Type);
num_groups = size(Types, 1);
cmap = jet(num_groups);
color=cmap(idx,:);
h=scatterm(Lat,Long,Area,color);
legend(h,Types);
I couldn't find a quick solution. If Iremove the handle "h" then the legend display the lines from the world map.
Any ideas?
Thanks!

回答(1 个)

Amy Haskins
Amy Haskins 2019-3-20
If you don't need a specific projection or additional overlays, I would recommend giving geobubble a try instead (introduced in R2017b). It's made for exactly this type of chart and will construct nice legends for you.
I think the alternative would be to filter your data set by type and generate the scatter plot for each type individually.

类别

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

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by