天天看點

Matlab畫雙軸折線圖

Matlab畫雙軸折線圖

資料:

Matlab畫雙軸折線圖

代碼:

clc
close all
clear all
AA = xlsread('2.xlsx');
x = AA(:,1);
y1 =  AA(:,2);
y2 =  AA(:,3);
hold on;
[AX,H1,H2] =plotyy(x,y1,x,y2,@plot);% 擷取坐标軸、圖像句柄
set(get(AX(1),'ylabel'),'string', 'Numbers of literature each year','fontsize',14);
set(get(AX(2),'ylabel'),'string', 'Numbers of accumulated literature year','fontsize',14);
xlabel('Year','fontsize',14);

set(AX(1),'ytick', [0:15:150]); %設定y軸間隔
set(AX(2),'ytick',[0:150:1500])

set(AX,'xlim',[1973 2018]) % 設定x軸範圍
set(H1,'Linestyle','-');
set(H2,'Linestyle','-');

set(gcf,'color','white')
set(gca,'linewidth',0.5) %設定邊框寬度  
legend([H1,H2],{'Annual number';'Accumulated number'});

           

打開圖設定标記等:

Matlab畫雙軸折線圖

繼續閱讀