How to position the legend and legend box at my required place in the figure?
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Thanigaivel Raja T
il 4 Ott 2016
Risposto: Marc Jakobi
il 5 Ott 2016
This is my code for the legend section of my figure.
[w,hO]=legend({'a_{occ}','a_{exp}'},'Location','southeast','FontName','Arial','Fontsize',6,'FontWeight','bold');
set([hO(3),hO(5)],'Xdata',[0.6 0.7]);
legend boxon
set(gcf, 'paperunits', 'centimeters', 'paperposition', [0 0 7.5 5.625])
The figure I get as output is attached.
With regard to the figure, I want the legend to be placed anywhere between (x1,y1)=(130,-20) (x2,y2)=(145,-30) w.r.t my plot axis. I also want a legend box positioned surrounding it precisely.
What should be my code changes for this? Also explain how it would work?
Thanks in advance.
0 Commenti
Risposta accettata
Marc Jakobi
il 5 Ott 2016
It will be difficult to determine the precise location automatically. You can manually position it using the 'Position' property. For example:
w.Position = [bottom, top, width, height];
The position values are normalized to the figure window's position by default (values between 0 and 1). By changing the bottom and top coordinates, you can move the legend to where you want it. By changing the width and height, you can change its size (and get the box to wrap around it precisely).
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Legend in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!