可直接複制運作,根據需要修改!
%繪圖資料
x=0:0.1:20;
y1=sin(x);
y2=cos(x);
% 繪圖
[hAx,hLine1,hLine2] =plotyy(x',y1,x',y2);
%設定圖幅
xlim( hAx( 1 ), [1 10] );
xlim( hAx( 2 ), [1 10]);
%設定線型
hLine1.LineStyle = '-';
hLine2.LineStyle = '--';
%設定線寬
hLine1.LineWidth=1.0;
hLine2.LineWidth=1.0;
%設定标記
hLine1.Marker='o';
hLine2.Marker='^';
%設定圖例
legend('Y1','Y2','Location','northeast','Fontsize',16,'Fontname','宋體','FontWeight','bold','linewidth',0.6)
% 設定字型(應該先設定全局字型為Times New Roman,然後設定宋體這些,否則宋體顯示不全)
set(gcf,'color','w');
set(hAx(1),'Fontsize',16,'linewidth',1.0);
set(hAx(2),'Fontsize',16,'linewidth',1.0);
% set(gca,'Fontsize',16,'Fontname','Times New Roman','FontWeight','normal','linewidth',1.6);
xlabel('時間/s','Fontsize',16,'Fontname','宋體','FontWeight','bold');
ylabel(hAx(1),'Y1/℃','Fontsize',16,'Fontname','宋體','FontWeight','bold') ;
ylabel(hAx(2),'Y2/cm','Fontsize',16,'Fontname','宋體','FontWeight','bold');