Text increments of the x-axis

조회 수: 1 (최근 30일)
Luke Megonigal
Luke Megonigal 2020년 12월 1일
답변: Steve Eddins 2020년 12월 1일
Hello
A question about the appearance of a plot's x-axis.
I have a plot whose domain is [0 4]. I can plot this and have xlim([0 4]). When I do this, the plot has x-increments labeled 0, 1, 2, 3, 4, as you would expect.
Is there any way to remove '0' and '4' from being named? In other words, is there a way to make the plot look the same as before, that is, have the same xlimit, but remove '0' and '4' such that it only says '1', '2', '3'?
Thanks,
The application is plotting mode shapes.

답변 (1개)

Steve Eddins
Steve Eddins 2020년 12월 1일
Sure, you can set the XTicks property of the axes object directly.
ax = gca;
ax.XTicks = [1 2 3];
A shortcut for this is:
xticks([1 2 3])

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by