How to force a (small) gap on axis

Hi,
when I plot data with values from -1 to 1, the y-axis ranges from -1 to 1, resulting in the graph reaching the top and bottom of the plot, which looks bad.
If my values range from -pi to pi, the axis will go from -4 to 4, resulting in the graph not reaching the top and bottom, which looks much better.
Is there a way to switch to a mode where there is always a (small) gap?
I know I can define the min/max of the axis, but I don't want to do it manually for each plot or define a formula on my own.
Many thanks!

답변 (2개)

ScottB
ScottB 2024년 12월 16일

0 개 추천

Try:
axis padded

댓글 수: 2

Tim
Tim 2024년 12월 16일
Exactly what I want, thanks a lot! May your beer always be cold!
Adam Danz
Adam Danz 2024년 12월 16일
You can also apply this to individual axes using xlim('padded') or with ylim, zlim.

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

Les Beckham
Les Beckham 2024년 12월 16일

0 개 추천

You can use the axis command to specify some padding around the data
plot(-1:0.1:1)
grid on
plot(-1:0.1:1)
axis padded
grid on

댓글 수: 1

Tim
Tim 2024년 12월 16일
Perfect, thank you, may your beer also always be cold!

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

카테고리

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

제품

릴리스

R2024b

태그

질문:

Tim
2024년 12월 16일

댓글:

2024년 12월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by