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

조회 수: 1 (최근 30일)
jaah navi
jaah navi 2019년 7월 5일
답변: Raj 2019년 7월 5일
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