Align the Legend Title to the Legend body

68 visualizzazioni (ultimi 30 giorni)
Sim
Sim il 14 Set 2020
Commentato: Sim il 23 Set 2020
Hi, How can I align the Legend Title to the Legend body (variables, etc..)? Maybe left-aligned ?
  5 Commenti
Sim
Sim il 14 Set 2020
Modificato: Sim il 14 Set 2020
Thanks a lot! Just submitted to the MATLAB support :)
Adam Danz
Adam Danz il 14 Set 2020
I'd be interesting in whatever you find.

Accedi per commentare.

Risposte (1)

Ayush Gupta
Ayush Gupta il 18 Set 2020
The legend title is by-default left aligned to legend body. Refer to the code below which generates the following picture and read the documentation on how to add legend title, here.
x = linspace(0,pi);
y1 = cos(x);
plot(x,y1)
hold on
y2 = cos(2*x);
plot(x,y2)
hold off
lgd = legend('cos(x)','cos(2x)');
title(lgd,'My Legend Title')
  6 Commenti
Adam Danz
Adam Danz il 23 Set 2020
I've checked since I made that comment and legend titles are not supported with the updated features.
In fact, I wrote a Community Highlights about these new features.
Title alignment is controlled by the new "TitleHorizontalAlignment" property of axes. Legends still do not have such a property.
Sim
Sim il 23 Set 2020
Oh cool, thanks a lot for highlighting that feature... So, if not working for the Legends, my MATLAB ticket opening was worth it :)

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by