Hi,
I am trying to plot two data sets.
One of them ranges from -40:40 while the other ranges from -50:50.
The plots look fine when I use xlim([-40,40]) and show appropriate number of axis points on the x-axis.
However, when I use xlim([-50,50]), the plot only shows 3 points on x-axis. (please refer to the picture attached)
How can I show more points on x-axis when using xlim([-50,50]) ?
Thanks in advance.

 채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 5일

1 개 추천

The plot is showing many points on the x axis.
What it is not showing is many ticks on the x axis.
When you do not specify the tick locations yourself, the plotting software tries to fill in "nice" ticks. It prefers multiples of 10, and then multiples of 5, and then multiples of 1. It has a lower bound on the number of nice tick locations, and it has an upper bound on the number of nice tick locations.
The multiples of 50 that are generated are multiples of 10 and 5 both, so they are favoured. Multiples of 10 as is used for the other plot are not as favored because of the number of ticks that would be generated.
If plot were to generate more then it would probably generate -50 -25 0 25 50.
You can resolve this by using xticks() to indicate exactly where you want the ticks to go.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by