Legend in several columns

859 vues (au cours des 30 derniers jours)
Auryn_
Auryn_ le 30 Nov 2018
Modifié(e) : nadia naji le 18 Déc 2022
Hi,
Every time I wanted to split my legend into more than one column I always used the function "columnlegend".
Now i am creating plots with a loop, as below:
legendLables=[];
for iM=1:length(Mvec)
plot(Xvec,F(iM,:), '*-', 'LineWidth',3,'Markersize',3); hold all
legendLables=[legendLables,{['$M=' num2str(Mvec(iM)) '$']}];
end
In this case the function columnlegend does not work, when I use:
columnlegend(6,legendLables,'NorthWest');
or
columnlegend(6,legendLables{:},'NorthWest');
Coudl you please help me?
Thanks in advance!
  3 commentaires
Walter Roberson
Walter Roberson le 1 Déc 2018
What difficulty are you observing when you use the File Exchange contribution columnlegend() ?
Auryn_
Auryn_ le 2 Déc 2018
I used 'NumColumns',2 with the normal Legend command and it works.

Connectez-vous pour commenter.

Réponse acceptée

madhan ravi
madhan ravi le 1 Déc 2018
  2 commentaires
Sebastian Lopez
Sebastian Lopez le 5 Déc 2020
Thanks, that helped!
nadia naji
nadia naji le 18 Déc 2022
Modifié(e) : nadia naji le 18 Déc 2022
I am using Mtalab R2017b, but when I used
legend({'cluster1','cluster2','cluster3','cluster4','cluster5','cluster6'},'NumColumns',2)
it produced this error:Unknown property: NumColumns.
what should I do? we can not legend with multiple columns in older versions?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by