Plot Legend

15 次查看(过去 30 天)
Jason
Jason 2011-4-7
Is there anyway to get rid of the first data with the legend() command? I just want it to show the second data, because the first data is a patch.
I have something like this:
legendtext = 'testing'
legend([repmat(' ',1,length(legendtext));legendtext], 'location', 'northeastoutside')
That code allow me to have text starting with the second data, but the symbol for the first data still show up because of it being a patch.

采纳的回答

Jiro Doke
Jiro Doke 2011-4-7
If you look at the documentation for legend, there's a syntax where you can specify the handles to the graphics objects you want to create a legend for.
hPatch = patch([1 2.5 4 3 2], [2 1 2 3 3], [1 0.5 0.5]);
hold on;
hLines = plot(4*rand(5, 2));
% Create legend just for the lines
legend(hLines, 'Line 1', 'Line 2', 'Location', 'NortheastOutside');

更多回答(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