Legends as pointers in matlab plot
11 views (last 30 days)
Show older comments
ANKUR KUMAR
on 24 Oct 2017
Answered: Walter Roberson
on 24 Oct 2017
I have plotted a India map and over that, I have used geoshow to show few stations. I have assigned all the plane stations by blue dots and other stations by black triangular dots. How can I put these two things in the legend in matlab plot?
0 Comments
Accepted Answer
Walter Roberson
on 24 Oct 2017
The easiest way is to create a fake graphics object with coordinates NaN, NaN but with the appropriate shape and color and line attributes; do this repeatedly for each entry and record the handles. Then legend() against those handles with appropriate text in a cell array.
For example,
L(1) = plot(nan, nan, 'b.', 'MarkerSize', 5);
T{1} = 'Urmar Tanda';
L(2) = plot(nan, nan, 'b*', 'MarkerSize', 5);
T{2} = 'Pattamundai';
L(3) = plot(nan, nan, 'kv', 'MarkerSize', 8);
T{3} = 'Lakheri';
L(4) = plot(nan, nan, 'k^', 'MarkerSize', 8);
T{4} = 'Sirsa';
legend(L, T)
0 Comments
More Answers (0)
See Also
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!