could anyone help me to solve the issue with respect to the following code

1 次查看(过去 30 天)
code:
x=[0 1 2 3 4 5 6 7 8 9 10]
A = [0 0.62 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93]
B = [0 0.32 0.60 0.75 0.86 0.90 0.88 0.89 0.90 0.91 0.92]
figure
subplot(2,2,1)
plot(x,A,'-*')
plot(x,B,'-^')
title('subplot 1')
A=[3.0 8.7 8.85 9.1 9.2 9.3 9.4 9.5 9.5 9.5 9.5]
B=[3.0 7.9 8.75 8.9 9.0 9.1 9.2 9.3 9.3 9.3 9.3 ]
subplot(2,2,2)
plot(x,A,'-^')
plot(x,B,'-+')
title('Subplot 2')
xlabel('data1')
ylabel('data2')
I want to the plot the graph in two subplots placing side by side and i want to have come xlabel by placing at the middle of two subplots and ylabel
to be placed to the left .
Each subplot should contain two curves A and B inside it .
Could anyone please help me on this.

采纳的回答

Raj
Raj 2019-7-5
Use this:
x=[0 1 2 3 4 5 6 7 8 9 10]
A = [0 0.62 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93]
B = [0 0.32 0.60 0.75 0.86 0.90 0.88 0.89 0.90 0.91 0.92]
figure
subplot(1,2,1) % corrected
plot(x,A,'-*')
hold on %added
plot(x,B,'-^')
title('subplot 1')
ylabel('data2') % shifted
A=[3.0 8.7 8.85 9.1 9.2 9.3 9.4 9.5 9.5 9.5 9.5]
B=[3.0 7.9 8.75 8.9 9.0 9.1 9.2 9.3 9.3 9.3 9.3 ]
subplot(1,2,2) % corrected
plot(x,A,'-^')
hold on % added
plot(x,B,'-+')
title('Subplot 2')
xlh = xlabel('data1');
xlh.Position(1) = xlh.Position(1) - abs(xlh.Position(1) * 1.35);
Note: To shift x label, I have used accepted answer from here.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by