MATLAB 双Y轴 多线条 多图例 绘制方法和代码
figure;
[AX,H1,H2] = plotyy(frameIdx,PSNRY,frameIdx,SSIM);
set(AX(1),'yTick',[20 : 2 : 50]) %设置右边Y轴的刻度
set(AX(2),'yTick',[0.8 : 0.02: 1]) %设置左边Y轴的刻度
set(get(AX(1),'Ylabel'),'string','PSNR');
set(get(AX(2),'Ylabel'),'string','SSIM');
set(H1,'marker','x','color','r');
set(H2,'marker','o','color','k');
hold on;
[H3] = plot(frameIdx,PSNRU,'-^m','MarkerSize', 3);
[H4] = plot(frameIdx,PSNRV,'-db','MarkerSize', 3);
for gopIdx = 1 : totalGop
[H5] = line([(gopIdx-1)*gopLen,(gopIdx-1)*gopLen],[30, 50],'color','g','LineWidth',2);
textContent = strcat('\rightarrow No. ',num2str(gopIdx), ' Gop');
text((gopIdx-1)*gopLen,35,textContent);
end
xlabel('frameIdx');
title('Quality');
set(gca,'xtick',0:10:frameNum);
H = legend([H1,H2,H3,H4,H5],{'PSNR_Y','SSIM','PSNR_U','PSNR_V','Gop Info'});
set(h,'Fontsize',13);
grid off;