Merge two plots with the same y axis
Hello there,
I have two sets of parameter, x1 and x2 and they both vary with depth. Since the scale span of x1 is different to that of x2, what I want to do is to put the axis of x2 above, as the secondary plot (see fig below). Anyone can help me to fix this?
x1 = 0:0.1:5;
y1 = 0:1:50;
y2 = 0:1:90;
x2 = y2.^0.9;
figure;
subplot(1,2,1)
plot(x1,y1);
ylabel(‘Depth (m)’);
xlabel(‘Length’);
subplot(1,2,2);
plot(x2,y2,’r’);
ylabel(‘Depth (m)’);
xlabel(‘Power’);
Please find attached the data, or please access the code above to generate the data.
ThanksHello there,
I have two sets of parameter, x1 and x2 and they both vary with depth. Since the scale span of x1 is different to that of x2, what I want to do is to put the axis of x2 above, as the secondary plot (see fig below). Anyone can help me to fix this?
x1 = 0:0.1:5;
y1 = 0:1:50;
y2 = 0:1:90;
x2 = y2.^0.9;
figure;
subplot(1,2,1)
plot(x1,y1);
ylabel(‘Depth (m)’);
xlabel(‘Length’);
subplot(1,2,2);
plot(x2,y2,’r’);
ylabel(‘Depth (m)’);
xlabel(‘Power’);
Please find attached the data, or please access the code above to generate the data.
Thanks Hello there,
I have two sets of parameter, x1 and x2 and they both vary with depth. Since the scale span of x1 is different to that of x2, what I want to do is to put the axis of x2 above, as the secondary plot (see fig below). Anyone can help me to fix this?
x1 = 0:0.1:5;
y1 = 0:1:50;
y2 = 0:1:90;
x2 = y2.^0.9;
figure;
subplot(1,2,1)
plot(x1,y1);
ylabel(‘Depth (m)’);
xlabel(‘Length’);
subplot(1,2,2);
plot(x2,y2,’r’);
ylabel(‘Depth (m)’);
xlabel(‘Power’);
Please find attached the data, or please access the code above to generate the data.
Thanks overlay plot, two axis MATLAB Answers — New Questions