Stretching Legend Box between two axes

조회 수: 6 (최근 30일)
Sasan Rafii-Tabrizi
Sasan Rafii-Tabrizi 2018년 11월 13일
답변: Prakhar Jain 2018년 11월 16일
Hello,
in the appendix I have a figure with two subplots. It would be nice if the legend box would reach from the left Y-axis to the right Y-Axis. Has anyone got an idea? The code I used to format the legend so far is the following one:
leg1 = legend('\boldmath{$\dot{Q}_{sh,t}$}','\boldmath{$\dot{P}_{t}$}','\boldmath{$\dot{Q}_{S,t}$}','\boldmath{$\dot{Q}_{L,t}$}','\boldmath{$\dot{Q}_{IST\rightarrow DSHP,t}$}','\boldmath{$\dot{Q}_{TS\rightarrow DSHP,t}$}'...
,'\boldmath{$\dot{Q}_{TS\rightarrow IST,t}$}','\boldmath{$T_{TES,t,1}$}','\boldmath{$T_{HC,t}$}','\boldmath{$T_{IST,t}$}','\boldmath{$T_{TS,out,t}$}');
set(leg1,'Interpreter','latex');
set(leg1,'FontSize',10);
legend('Location','northoutside','Orientation','horizontal');
Regards,
SR89

답변 (1개)

Prakhar Jain
Prakhar Jain 2018년 11월 16일
Hi Sasan,
Custom location and size, specified as a four-element vector of the form [left bottom width height]. The first two values, left and bottom, specify the distance from the lower left corner of the figure to the lower left corner of the legend. The last two values, width andheight, specify the legend dimensions. The Units property determines the position units.
If you specify the Position property, then MATLAB® automatically changes the Location property to 'none'.
example: legend({'A','B'},'Position',[0.2 0.6 0.1 0.2]);
You can change the width to more to make it appear to full length as shown in figure attached by you.
Follow this link for more legend properties.
Hope this helps.
Thanks.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by