Legends as pointers in matlab plot

11 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2017-10-24
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 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by