How to not include an item in a legend
22 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Is it possible to change whats displayed on a legend. Im plotting 3 data sets, but data set 1 and 2 are the same, only that data set 2 plots over dataset 1 with a black box if a certain condition is met.
I therefore want to remove dataset2 from the legend?
Thanks for any pointers
0 Commenti
Risposta accettata
Più risposte (3)
Julian Hapke
il 5 Gen 2015
ok, here's the solution: you can tell legend() with which plot handle the legend entry is associated, by:
clf;
plot(rand(10,4));
a=get(gca,'Children');
legend([a(4);a(1)],{'bla','bli'})
note that the first created plot is at the last index of the children array
regards
2 Commenti
Julian Hapke
il 5 Gen 2015
you could add the data set with the black boxes at last and then only define 2 legend entries.
0 Commenti
Vedere anche
Categorie
Scopri di più su Legend in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!