Question

I wonder in MATLAB how I would plot a circle and show it correctly instead of by default showing it as an ellipse. I guess it has something to do with the local coordinate system in the axis.

Was it helpful?

Solution

You can use the command axis equal to set the data units to be the same on each axis. Here's an example:

theta = linspace(0, 2*pi, 100);
subplot(121);                     % Show the default plot
plot(cos(theta), sin(theta));
title('Default axes settings');
subplot(122);                     % Show a plot with equal data units
plot(cos(theta), sin(theta));
title('Equalized tick spacing');
axis equal;

enter image description here

OTHER TIPS

In addition to using axis equal as @gnovice suggested, you can turn off the stretch-to-fill feature by using daspect:

daspect manual

or even setting the axes aspect ratios explicitly to:

daspect([1 1 1])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top