close all clf x = 1:3; [hax,h1,h2]=plotyy(x,2:4,x,6:-1:4); hold on [~,h3,h4]=plotyy(x,3:5,x,5:-1:3); h5=plot(hax(2),x,5:7); set(h1,'color','r') set(h2,'color','g') set(h3,'color','b') set(h4,'color','m') set(h5,'color','c') hl = legend([h1,h2,h3,h4,h5],'2-4 red','6-4 green','3-5 blue','5-3 magenta','5-7 cyan'); set(hl,'fontsize',14)