How to change the axis length in a plot?

조회 수: 3 (최근 30일)
Denise Selegato
Denise Selegato 2016년 1월 13일
댓글: Star Strider 2016년 1월 14일
In the figure, the x axis for the first subplot has only 3 elements. How can I set this feature for all the other subplots? For each one will only have 3 ticks insted of variate x axis elements. Thank you

채택된 답변

Star Strider
Star Strider 2016년 1월 13일
You can change the axis labels in each subplot individually:
x = linspace(2, 3);
y = sin(2*pi*(x-2)).^2;
figure(1)
subplot(2,1,1)
plot(x, y) % Default Axis Tick Labels
title('Subplot 1')
sp2 = subplot(2,1,2);
plot(x, y)
xt = get(sp2, 'XTick'); % Current 'XTick' Values For Subplot #2
xtn = linspace(min(xt), max(xt), 3); % Define New 'XTick' Values for Subplot #2
set(sp2, 'XTick', xtn) % Set New 'XTick' Values for Subplot #2
title('Subplot 2')
  댓글 수: 2
Denise Selegato
Denise Selegato 2016년 1월 14일
That is exactly what I was looking for. Thank you.
Star Strider
Star Strider 2016년 1월 14일
My pleasure.

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

추가 답변 (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