MATLAB Answers

Plot not displaying given axis limits

1 view (last 30 days)
Samantha Boger
Samantha Boger on 17 Oct 2020
Answered: Nagasai Bharat on 20 Oct 2020
When trying to plot a graph I have set the limit using the following code:
ylimit = 1.5;
axis equal
But the plot produced does not have that axis limit:
Does anyone know why this is happening and how to stop it?


VBBV on 18 Oct 2020
Comment axis equal and plot it
%if true
% code
% end
ylimit = 1.5;
%axis equal
VBBV on 18 Oct 2020
Or use xlim just like ylim. Ylim seems to work fine.
% if true
% code
xlimit = 3;
%axis equal
Adam Danz
Adam Danz on 18 Oct 2020
We don't see enough of your code to see what's causing that. It could be caused by any of these possibilities or another reason
  • The cirlce isn't complete and the axes are fine.
  • you're Setting xlim somewhere
If you're setting axis equal prior to ylim, it would also cause this problem. For example,
th = linspace(0,2*pi,100);
x = sin(th);
y = cos(th);
hold on
plot(-3.5, 0, 'g*')
axis equal
ylim([-1.5, 1.5])
grid on

Sign in to comment.

Answers (1)

Nagasai Bharat
Nagasai Bharat on 20 Oct 2020
From my understanding you are trying to limit your plot axis."axis equal" command uses the same length for the data units along each axis but not exactly plot in that range.
The following resources might help you achieve your objective.


Sign in to comment.


Community Treasure Hunt

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

Start Hunting!