ToNoY
ToNoY

Reputation: 1378

Axis scaling in matlab

I was trying to set my plot axes "tight" using the following simple command in Matlab-

axis tight

which can also be done using-

axis([xmin xmax ymin ymax])

But by doing this, I found that a few my data points falling on the top of all axes as you can see here: https://docs.google.com/file/d/0B6GUNg-8d30vaUhVQVFOaTJKc1E/edit?usp=sharing

However, when I generate the same figure without the tight command, it looks even worse because too much space on both sides as you may see here: https://docs.google.com/file/d/0B6GUNg-8d30vZ0JZR0JZYmhIeVU/edit?usp=sharing

I would like to know if there's any function in Matlab that would help me to represent this scatter plot close to the tight scenario without letting any of my data points falling on any of the axis. say, 5% space on all sides. Thanks.

Upvotes: 1

Views: 313

Answers (1)

Roney Michael
Roney Michael

Reputation: 3994

You could just provide for the space manually:

[xmin, xmax] = xlim;
[ymin, ymax] = ylim;

x_tol = (xmax-xmin)*0.05;    %(5%) tolerance
y_tol = (ymax-ymin)*0.05;    %(5%) tolerance

axis([xmin-x_tol xmax+x_tol ymin-y_tol ymax+y_tol])

Upvotes: 2

Related Questions