Stretching Legend Box between two axes

2 ビュー (過去 30 日間)
Sasan Rafii-Tabrizi
Sasan Rafii-Tabrizi 2018 年 11 月 13 日
回答済み: Prakhar Jain 2018 年 11 月 16 日
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}$}');

回答 (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.


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