legend symbol disappears when plotting a polyshape
Mostra commenti meno recenti
p=plot(polyshape([0 0 1 1],[1 0 0 1]));
legend(p);
Instead, if I try to get both outputs of the legend with a polyshape, the symbol of the polyshape disappears:
p=plot(polyshape([0 0 1 1],[1 0 0 1]));
[h,objh]=legend(p);
How can I still see/visualise the symbol of the polyshape, when I need to get both outputs of the legend?
5 Commenti
Sim
il 28 Giu 2024
How are you using the second output? Why do you need it? I'm interested.
As @Star Strider mentioned, additional outputs after the first output to legend are not documented and have led to all sorts of issues. The option to request additional outputs to legend will be removed in the future.
Star Strider
il 28 Giu 2024
@Adam Danz — Some of that capability — among which are the ability to change the marker and line properties only in the legend — needs to be preserved somehow, if the second output is eliminated. Perhaps those can be part of the Children field, or even a new field. Eliminiating the second output could break a lot of existing code.
Adam Danz
il 17 Lug 2024
Risposta accettata
Più risposte (1)
Afiq Azaibi
il 4 Ott 2024
Modificato: Afiq Azaibi
il 7 Ott 2024
Using multiple outputs from the legend command is discouraged. You mentioned how you are trying to change the size of the icons which isn't currently supported but is one we are aware of. This might not be exactly what you are looking for but one way to change the size of the icon starting in R2024b, you can leverage the legend's IconColumnWidth property to adjust the width allocated to the icon of the legend.
p=plot(polyshape([0 0 1 1],[1 0 0 1]));
l=legend(p);
l.IconColumnWidth = 10;
In some cases when all the icons are markers, the value of IconColumnWidth will be adjusted to be narrow automatically but in all other cases, it will have its old default value which can still be adjusted.
scatter(rand(3,10), rand(3,10), 'filled');
l = legend;
Categorie
Scopri di più su Legend in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






