Remove an item in legend
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I have a legend like
x, y, spline
I would like the legend to only show x, y and not show spline as a dataset. How can I do this? I would preferably not have to redo the whole image.
0 comentarios
Respuestas (2)
Sean de Wolski
el 7 de Mayo de 2013
How abotu just calling legend again without the input for the line you don't want:
hLine = plot(1:10,1:10,'r-',1:10,10:-1:1,'b-');
hLegend = legend(hLine,'up','down');
Now to remove it:
%Add another legend:
legend(hLine(1),'up')
2 comentarios
Sean de Wolski
el 7 de Mayo de 2013
There might be a way to do this by removing children from the Legend and from shortening the string property:
get(hLegend)
Then use set() to change the ones you need.
Laura F
el 6 de Mayo de 2022
I hope, that I understand the question right. I had the same problem and solved it like this:
Lgnd = legend('show','Orientation','horizontal');
Lgndstr = Lgnd.String(1:2);
Lgnd.String = Lgndstr;
0 comentarios
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!