- Select the line which you want to make invisible in legend.
- Then select the arrow icon from the top, this will open the property inspector.
- Scroll down in the property inspector dailouge box.
- click parent/child item
- In the handle visibility salect the off option.
Figure legend: how to prevent entries from showing?
68 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
My code plots a figure with a few curves, after the code finishes running, I manually add the legend like this:
legend('original', '', '', 'proposed', '', '', 'Proposed with optimisation')
So my figure looks like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/170693/image.png)
I do not need these extra lines after the 'original' and 'proposed', how can I remove the 2, 3, 5, 6th entries? Or how can I add the legend without these? i.e. a legend with only 3 entries?
Many thanks!
0 Kommentare
Antworten (2)
Gulam Dastagir Khan
am 7 Okt. 2020
If the figure is already plotted, then do the following
Your line will not be appeaar in the legend now.
0 Kommentare
Are Mjaavatten
am 22 Feb. 2018
Bearbeitet: Are Mjaavatten
am 22 Feb. 2018
h = plot(....);
legend(h([1,4,7]),'original','proposed','proposed with optimisation')
3 Kommentare
Are Mjaavatten
am 25 Feb. 2018
With your plot (or rather: axes) in focus, try:
h = get(gca,'children')
Most likely, the lines are in the correct order, but you may have to experiment a little. Typing h(1) will show details like linestyle and marker of this line.
Karel Van Wambeke
am 24 Mai 2021
Bearbeitet: Karel Van Wambeke
am 24 Mai 2021
@Are Mjaavatten GOATED
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!