Stretching Legend Box between two axes

2 次查看(过去 30 天)
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