White space at the beginning and ending of xaxis
48 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Happy Bear
am 13 Jul. 2020
Kommentiert: Adam Danz
am 13 Jul. 2020
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/331298/image.png)
Hello everyone,
I made this graph but I want to have some white spacing between the yaxis and the first bin. And then I want some white spacing between the last bin and the right axis of the figure. Just like in this figure:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/331301/image.png)
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 13 Jul. 2020
Bearbeitet: Adam Danz
am 13 Jul. 2020
axis(ax, 'tight') % where ax is your axis handle.
will set the axis limits so the edges of the plot touch the max and min of your data.
After running that command, you can run the lines below to add +/- 5% of your data range to each side of the x and y axes.
xlim(ax, xlim(ax) + [-1,1]*range(xlim(ax)).* 0.05)
ylim(ax, ylim(ax) + [-1,1]*range(ylim(ax)).* 0.05)
If you only want to apply this to the x-axis limits,
yl = ylim(ax);
axis(ax, 'tight')
ylim(ax, yl)
xlim(ax, xlim(ax) + [-1,1]*range(xlim(ax)).* 0.05)
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!