matplotlib中轴('equal')和轴('scaled')之间的差异

2024-05-13 18:42:39 发布

您现在位置:Python中文网/ 问答频道 /正文

在参考文献中,它们被描述为:

axis('equal') changes limits of x or y axis so that equal increments of x and y have the same length; a circle is circular.:

axis('scaled') achieves the same result by changing the dimensions of the plot box instead of the axis data limits.:

但我不理解“通过改变绘图框的尺寸”这一部分。 所以我直接比较

import numpy as np
import matplotlib.pyplot as plt

plt.close('all')

x = np.array(np.linspace(-np.pi, np.pi))
y = np.sin(x)

ax1 = plt.subplot(2, 1, 1)
ax1 = plt.plot(x, y)
plt.axis('scaled')

ax1 = plt.subplot(2, 1, 2)
plt.plot(x, y)
plt.axis('equal')

enter image description here

与plt.axis('scaled')一起绘制时,只有一个细微的差别,即宽度较短。

我怎么才能更好地知道区别呢?


Tags: oftheimportplotasnppiplt