How to force a (small) gap on axis

16 Ansichten (letzte 30 Tage)
Tim
Tim am 16 Dez. 2024
Kommentiert: Adam Danz am 16 Dez. 2024
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!

Antworten (2)

ScottB
ScottB am 16 Dez. 2024
Try:
axis padded
  2 Kommentare
Tim
Tim am 16 Dez. 2024
Exactly what I want, thanks a lot! May your beer always be cold!
Adam Danz
Adam Danz am 16 Dez. 2024
You can also apply this to individual axes using xlim('padded') or with ylim, zlim.

Melden Sie sich an, um zu kommentieren.


Les Beckham
Les Beckham am 16 Dez. 2024
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 Kommentar
Tim
Tim am 16 Dez. 2024
Perfect, thank you, may your beer also always be cold!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by