我画一个圆:
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import SubplotZero
fig = plt.figure(1, figsize=(6, 6))
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)
centreCircle = plt.Circle((0, 0), 1, color="black", fill=False, lw=2)
# Draw the circles to our plot
ax.add_patch(centreCircle)
plt.axis('equal')
plt.show()
一切正常:
但是当我想增加轴的极限时:
ax.set_ylim(-5, 5)
ax.set_xlim(-5, 5)
我失败了。你知道吗
我怎样才能做到呢?你知道吗
你只需要
甚至
我可能不完全理解这个问题,因为仅仅在代码中添加
ax.set_ylim(-5, 5); ax.set_xlim(-5, 5)
实际上会产生一个很好的绘图。你知道吗但一般来说,当使用相等纵横比时,可以使用
ax.set_aspect("equal", adjustable="box")
使轴调整到您的限制。所以对于不对称极限,这看起来像你可以简单地执行你需要的,而不需要艺术家。如果您可以不使用它,那么下面是以下示例代码:
编辑:使用AxisArtist重做
相关问题 更多 >
编程相关推荐