legend symbol disappears when plotting a polyshape
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sim
el 28 de Jun. de 2024
Editada: Afiq Azaibi
el 7 de Oct. de 2024
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 comentarios
Respuesta aceptada
Star Strider
el 28 de Jun. de 2024
I don’t have any specific suggestions.
It works with one output, however not more than one. That the legend function has more than oue output is not documented, nor are the behaviours associated with the additional outputs. The second output (‘objh1’ here) can be used to change the marker properties, however without markers, there is nothing to change. (Experimenting with its properties didn’t bring back the patch in the legend.) Since the additional outputs are undocumented, you will likely need to Contact Support and ask about this. Also, ask for published documentation on the additional outputs be made freely available.
Include the URL of this thread in your note to MathWorks so you don’t have to repeat all this.
figure
p=plot(polyshape([0 0 1 1],[1 0 0 1]));
h = legend(p);
get(h)
figure
p=plot(polyshape([0 0 1 1],[1 0 0 1]));
[h,objh1,objh2]=legend(p);
get(h)
get(objh1)
get(objh2)
.
0 comentarios
Más respuestas (1)
Afiq Azaibi
el 4 de Oct. de 2024
Editada: Afiq Azaibi
el 7 de Oct. de 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;
0 comentarios
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!