天天看点

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画双轴折线图

继续阅读