How to position the legend and legend box at my required place in the figure?

14 ビュー (過去 30 日間)
Thanigaivel Raja T
Thanigaivel Raja T 2016 年 10 月 4 日
回答済み: Marc Jakobi 2016 年 10 月 5 日
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.

採用された回答

Marc Jakobi
Marc Jakobi 2016 年 10 月 5 日
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 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by