How to force a (small) gap on axis

18 次查看(过去 30 天)
Tim
Tim 2024-12-16
评论: Adam Danz 2024-12-16
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
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
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

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by