How to add a legend in the Mapping Toolbox?
Show older comments
I'm trying to add a legend for serveral values that I plotted on a map using scatterm().
I simply want to add a legend and I'm having a hard time finding it in the Mapping Toolbox and online in MatLab answers. I want the blue, red, and grey values to be legend('P-Value < 5%', ' 5% < P-Value < 15%' , 'P-Value > 15%') correspondingly. Normal legend() doesn't work.
Here is the code:
latlim = [25 50]; lonlim = [-125 -67];
axe = usamap(latlim, lonlim);
set(axe, 'Visible', 'off');
sheds = shaperead('usastatehi','UseGeoCoords', true, 'BoundingBox', [lonlim', latlim']);
geoshow(axe, sheds, 'FaceColor', [1 1 1])
scatterm(latb, longb, 12, blueVal, 'filled', 'blue')
hold on
scatterm(latr, longr, 12, redVal, 'filled', 'red')
scatterm(latg, longg, 12, [0.7 0.7 0.7])
1 Comment
Adam Danz
on 21 Aug 2019
" Normal legend() doesn't work. "
If you have any trouble implementing the answer (that uses a normal legend), please let us know what the prblems are.
Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!