Legend with multiple columns and problem with alignement for last entry
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear matlab comunity,
I used the legend property "NumColumns=2" to get 2 colums in my legend. However, I would like the last (longer) entry NOT to affect the alignment of the upper ones ("c" and "d"). Is there a possibility to do this?

0 comentarios
Respuestas (1)
Star Strider
el 6 de Feb. de 2024
There does not appear to be anying in Legend Properties that would directly address that problem. The only approach I can think of would be to break up ‘Long sentence’ into more than one line. This reduces the gap, however it would not completely eliminate it.
x = 0:0.01:1;
y = sin((1:5).'*2*pi*x);
figure
plot(x, y(1,:), 'DisplayName','a')
hold on
plot(x, y(2,:), 'DisplayName','b')
plot(x, y(5,:), 'DisplayName',sprintf('%s\n%s','Long','sentence'))
plot(x, y(3,:), 'DisplayName','c')
plot(x, y(4,:), 'DisplayName','d')
hold off
legend('Location','best', 'NumColumns',2)
.
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!
