matplotlib绘制椭圆轮廓

时间:2013-10-12 09:18:47

标签: matplotlib contour ellipse

我试图画出类似的东西: enter image description here

主要思想是在某个特定范围内绘制不同颜色的椭圆,例如[-6,6]。

我了解可以使用plt.contour函数。但我不明白如何生成线。

1 个答案:

答案 0 :(得分:3)

我个人不会对轮廓进行此操作,因为您需要添加我认为不需要的高程信息?

matplotlibEllipse,它是Artist的子类。以下示例将单个椭圆添加到绘图中。

import matplotlib as mpl
ellipse = mpl.patches.Ellipse(xy=(0, 0), width=2.0, height=1.0)
fig, ax = plt.subplots()
fig.gca().add_artist(ellipse)

ax.set_aspect('equal')
ax.set_xlim(-2, 2)
ax.set_ylim(-2, 2)

enter image description here

然后你需要研究如何获得你想要的效果,我会have a read of the docs通常会让事情变得透明alpha