How to create 2 legends in one figure?

17 views (last 30 days)
Ince
Ince on 3 Nov 2017
Commented: dpb on 5 Nov 2017
Hello, I have created two legends in one figure but I dont know how to set the second legend also outside the figure like the another one (screenshot). I think the solution is in this line (I found it in another community) but I dont no how to change it: a=axes('position',get(gca,'position'),'visible','off'); Thanks!
figure(1)
d1=plot(daten.bst.t_Step(1200:2405,1)*3600,daten.bst.T_01(1200:2405,1),'b');
hold on
t1=plot(daten.bst.t_Step(1200:2405,1)*3600,daten.bst.T_01(1200:2405,1),'b');
t2=plot(daten.bst.t_Step(1200:2405,1)*3600,daten.bst.T_02(1200:2405,1)+0.1071,'r');
t3=plot(daten.bst.t_Step(1200:2405,1)*3600,daten.bst.T_03(1200:2405,1)+0.0085,'m');
d2=plot((daten2.bst.t_Step(394:1599,1))*3600,daten2.bst.T_01(394:1599,1),'b--');
plot((daten2.bst.t_Step(394:1599,1)-0.006944)*3600,daten2.bst.T_02(394:1599,1)+0.183,'r--');
plot((daten2.bst.t_Step(394:1599,1)-0.006944)*3600,daten2.bst.T_03(394:1599,1)+0.0708,'m--');
hold off
set(gca);
xlabel('Zeit in s');
ylabel('Temperatur in °C');
xlim([0 1200])
grid on
legend([d1 d2],'1,5 Nm','2 Nm','Location','NorthEastOutside');
a=axes('position',get(gca,'position'),'visible','off');
legend(a,[t1 t2 t3],'T01','T02','T03','Location','EastOutside');
  8 Comments
Ince
Ince on 4 Nov 2017
dpd, I followed your first point and it worked! Thank youu
dpb
dpb on 5 Nov 2017
Glad to help...sequence is important sometimes...

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!