How to obtain handlers to line objects from a legend object?

3 vues (au cours des 30 derniers jours)
Mats Jansson
Mats Jansson le 5 Juin 2018
Commenté : Lina KORONFEL le 14 Juil 2020
Is it possible to obtain the line-handlers from a legend-handler? Example:
hLines = plot(x1, y1, x2, y2, ...);
hLegend = legend(hLines, {'Text1', 'Text2', ...});
The figure, axes, lines and legend may now be changed via code or GUI. Some plotted lines are not included in the legend. Is there a way to obtain the lines that corresponds to the legend?
Best regards

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Juin 2018
In R2014b and later, if you have a legend, hLegend, that is displaying text for only some of the lines you passed in (for example you passed in too few text strings), and you wish to find out which line handles do have entries in the legend, then
hLegend.PlotChildren
  1 commentaire
Mats Jansson
Mats Jansson le 5 Juin 2018
Thanks!
This is exactly what I need. It seems to be completly undocumented in R2017b.

Connectez-vous pour commenter.

Plus de réponses (1)

Yair Altman
Yair Altman le 12 Juil 2018
Modifié(e) : Yair Altman le 12 Juil 2018

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by