I cannot create a complete legend that includes all the lines. I am plotting a dual axis graph and I can get a legend for the first line associated with each y-axis, but not the remaining lines.
Thanks in advance.
Here is the script that I have written:
x=time/60; Bay1S=(Bay1S86BRT-Bay1S86LT).*(1/15).*(5.678)./Bay1S86HF; Bay1SHF=Bay1S86HF; [AX1,H1,H2]=plotyy(x,Bay1S,x,Bay1SHF); set(H1,'Linestyle', '-') set(H2,'Linestyle', '--') set(H1, 'Color', 'g') set(H2, 'Color', 'g') title('Thermal Effectiveness at 86" AFF') set(get(AX1(1),'Ylabel'),'String','Thermal Effectiveness') set(get(AX1(2),'Ylabel'),'String','Heat Flux (W/m^2)') xlabel('Time (hrs)') set(gca,'XTick', 0:1:24) set(AX1(2),'YLim',[-6 -3]) set(AX1(2),'YTick',(-6:0.5:-3)) set(AX1(1),'YLim',[0 1.5]) set(AX1(1),'YTick',(0:.25:1.5)) hold(AX1(1)); hold(AX1(2)); Bay2S=(Bay2S86BRT-Bay2S86LT).*(1/15).*(5.678)./Bay2S86HF; Bay2SHF=Bay2S86HF; plot(AX1(1),x,Bay2S,'r-'); plot(AX1(2),x,Bay2SHF,'r--'); Bay1N=(Bay1N86BRT-Bay1N86LT).*(1/15).*(5.678)./Bay1N86HF; Bay1NHF=Bay1N86HF; plot(AX1(1),x,Bay1N,'c-'); plot(AX1(2),x,Bay1NHF,'c--') Bay2N=(Bay2N86BRT-Bay2N86LT).*(1/15).*(5.678)./Bay2N86HF; Bay2NHF=Bay2N86HF; plot(AX1(1),x,Bay2N,'m-'); plot(AX1(2),x,Bay2NHF,'m--'); legend([H1;H2],'Bay1S','Bay2S','Bay1N','Bay2N','Bay1SHF','Bay2SHF','Bay1NHF','Bay2NHF');
Best Answer