필터 지우기
필터 지우기

How to remove or add portions of the x-axis that isn't being used

조회 수: 7 (최근 30일)
Christopher Arreola
Christopher Arreola 2021년 12월 10일
편집: Voss 2021년 12월 10일
So this is what I'm working with: As you can see, the graph for both functions ends at 5 but the x-axis continues until 6. I would also like to add the grid in the second graph so that the y-axis ends at 5 instead of 4. How do I fix it?

답변 (1개)

Voss
Voss 2021년 12월 10일
편집: Voss 2021년 12월 10일
There are different ways to do it:
xlim('tight'); % option 1
xlim([-4 5]); % option 2
set(gca(),'XLim',[-4 5]); % option 3
It looks like you've used subplot to get the two axes, so note that you have to set the x-limits for each one (unless they're linked).
Slimiar functionality exists for the y-limits: use ylim or set the 'YLim' of the axes.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by