필터 지우기
필터 지우기

Creating plot with double x axis

조회 수: 25 (최근 30일)
jack london
jack london 2021년 12월 13일
댓글: jack london 2021년 12월 14일
Hi everyone,
I want to plot graph with two x axis. One is at the base level other one is at the uppermost level.
I plot u1 wrt y-axis also I want add u2 wrt to y-axis.
I write code below . How I add u2 datas as an second x-axis on the upper level ? Thanks for answer.
Simialr to this example
clear
clc
y = [2 3 4 5 6 7 8 9 10 15 20 25 30 40 50 60 80 100 150 200 280]
u1 =[6.76 7.11 7.48 7.79 8.03 8.30 8.49 8.72 8.91 9.70 10.16 10.44 10.53 10.71 10.76 10.81 10.90 11.0 11.07 11.1 11.02]
u2 =[19.0 18.1 17.0 16.2 15.8 15.4 15.1 14.4 14.1 12.8 13.2 12.5 11.8 11.1 10.5 10.5 9.3 9.2 8.5 7.9 7.3]
plot(u1,y,'p-','LineWidth',1,'Marker','square','LineStyle','none'); xlabel('u1 (m/s)'); ylabel('y (mm)');

채택된 답변

David Hill
David Hill 2021년 12월 13일
Why not just use subplot?
subplot(2,1,1)
plot(u1,y)
subplot(2,1,2)
plot(u2,y)
  댓글 수: 5
David Hill
David Hill 2021년 12월 14일
y = [2 3 4 5 6 7 8 9 10 15 20 25 30 40 50 60 80 100 150 200 280];
u1 =[6.76 7.11 7.48 7.79 8.03 8.30 8.49 8.72 8.91 9.70 10.16 10.44 10.53 10.71 10.76 10.81 10.90 11.0 11.07 11.1 11.02];
u2 =[19.0 18.1 17.0 16.2 15.8 15.4 15.1 14.4 14.1 12.8 13.2 12.5 11.8 11.1 10.5 10.5 9.3 9.2 8.5 7.9 7.3];
t=tiledlayout(1,1);
ax1=axes(t);
plot(ax1,u1,y,'-r','Marker','square','DisplayName','x = -100 mm');
ax2=axes(t);
plot(ax2,u2,y,'-k','Marker','o','DisplayName','x = +100 mm');
ax2.XAxisLocation='top';
ax2.Color = 'none';
ax1.XColor = 'r';
ylabel(ax1,'y (mm)');
xlabel(ax1,'u1 (m/s)');
xlabel(ax2,'u2 (m/s)');
xlim(ax1,[0 12]);
xlim(ax2,[0 20]);
legend(ax1,'Location','northwest');
legend(ax2,'Location', 'southwest');
jack london
jack london 2021년 12월 14일
Thank you so much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by