仅在yyaxes中绘制四个图中的两个

时间:2015-08-25 14:17:50

标签: matlab plot

我正在尝试使用plotyy并坚持在两个y轴上绘制四个图表并且它不起作用。

有人能看出问题出在哪里吗?

它只绘制前两个图:

load dexpan2Cp;
x1=dexpan2Cp(:,2);
x1=x1/3600;
y1=((dexpan2Cp(:,3)+dexpan2Cp(:,4))/2000)*32.5;
load Dexpan2_2C;
x2=Dexpan2_2C(:,1);
x2=x2/3600;
y2=Dexpan2_2C(:,2);
A = importdata('Scan Session94-Dexpan19.txt','\t',5); 
Dexpan19p=A.data;
save('Dexpan19p.mat','Dexpan19p');
x3=Dexpan19p(:,2);
x3=x3/3600;
y3=((Dexpan19p(:,3)+Dexpan19p(:,4))/2000)*32.5;
load Dexpan19C;
x4=Dexpan19C(:,1);
x4=x4/3600;
y4=Dexpan19C(:,2)+3.3;
x1 = x1(x1<115.7); y1 = y1(1: length(x1) , :);
x2 = x2(x2<115.7); y2 = y2(1: length(x2), :);
x3 = x3(x3<115.7); y3 = y3(1: length(x3), :);
x4 = x4(x4<115.7); y4 = y4(1: length(x4), :);
hold off;
figure;
[ax, h1, h2] = plotyy(x1,y1,x2,y2);
set(h1,'g',y1,'DisplayName','1');
set(h2,'b',y2,'DisplayName','2e');
hold(ax(1),'on');
plot(ax(1),x3,y3,'r',y3,'DisplayName','3');
hold(ax(2),'on');
plot(ax(2),x4,y4,'k',y4,'DisplayName','4');
xlabel('Time (h)');
ylabel(ax(1),' Pressure (MPa)');
ylabel(ax(2),'Tempereture (°C)');
legend('show');

1 个答案:

答案 0 :(得分:0)

您似乎使用了无效的语法,并没有告诉我们您在执行代码时收到的错误。特别是,在绘制前两行后,您的代码会出错 - 因此您只能绘制2行。

要使其正常工作,应将您的四行更改为

cf logs yourAppName