简体   繁体   English

为什么在MATLAB中绘制的圆圈显示为椭圆?

[英]Why does a circle plotted in MATLAB appear as an ellipse?

I wonder in MATLAB how I would plot a circle and show it correctly instead of by default showing it as an ellipse. 我想知道在MATLAB中我将如何绘制圆圈并正确显示它而不是默认显示为椭圆形。 I guess it has something to do with the local coordinate system in the axis. 我想这与轴上的局部坐标系有关。

You can use the command axis equal to set the data units to be the same on each axis. 您可以使用命令axis equal在每个轴上将数据单位设置为相同。 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;

在此输入图像描述

In addition to using axis equal as @gnovice suggested, you can turn off the stretch-to-fill feature by using daspect : 除了使用axis equal @gnovice建议的axis equal 之外 ,您还可以使用daspect关闭拉伸到填充功能:

daspect manual

or even setting the axes aspect ratios explicitly to: 甚至将轴纵横比明确设置为:

daspect([1 1 1])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM