How to setting one horizontal axis for 2 subplot?

조회 수: 5 (최근 30일)
galaxy
galaxy 2022년 10월 11일
편집: Martin Pryde 2022년 10월 12일
Hi all,
I have a question about subplot. How can we plot 2 suplots, but only one horizontal axis.
subplot(3, 1, 1:2);
plot(rand(10, 1), 'b.-', 'LineWidth', 2);
grid on;
subplot(3, 1, 3);
plot(rand(10, 1), 'b.-', 'LineWidth', 2);
grid on;
My expection as:
Thank you so much

채택된 답변

VBBV
VBBV 2022년 10월 11일
편집: VBBV 2022년 10월 12일
subplot(3, 1, 1:2);
plot(rand(10, 1), 'b.-', 'LineWidth', 2);
xticks(1:10)
grid on;
xticklabels({})
subplot(3, 1, 3);
plot(rand(10, 1), 'b.-', 'LineWidth', 2);
grid on;
  댓글 수: 3
VBBV
VBBV 2022년 10월 12일
add xticks
galaxy
galaxy 2022년 10월 12일
Thank you so much.
It is OK

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

추가 답변 (1개)

Martin Pryde
Martin Pryde 2022년 10월 12일
편집: Martin Pryde 2022년 10월 12일
ax1 = subplot(3,1,1:2);
plot(ax1,rand(10,1),'b.-','LineWidth',2);
ax2 = subplot(3, 1, 3);
plot(ax2,rand(10,1),'b.-','LineWidth',2);
grid(ax1,'on');
xlim(ax1,[1,10]);
xticks(ax1,1:10);
xticklabels(ax1,{})
grid(ax2,'on');
xticks(ax2,1:10);
xlim(ax2,[1,10]);

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by