matplotlib绘制椭圆轮廓

matplotlib绘制椭圆轮廓,matplotlib,contour,ellipse,Matplotlib,Contour,Ellipse,我试图画一些类似的东西: 其主要思想是在某些特定范围内绘制具有不同颜色的椭圆,例如从[-6,6] 我知道可以使用plt.contour功能。但我不知道如何生成线。我个人不会对等高线进行此操作,因为您需要添加有关高程的信息,而我认为您不需要这些信息 matplotlib具有eliple,它是Artist的子类。以下示例将单个椭圆添加到绘图中 import matplotlib as mpl ellipse = mpl.patches.Ellipse(xy=(0, 0), width=2.0, h

我试图画一些类似的东西:

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


我知道可以使用
plt.contour
功能。但我不知道如何生成线。

我个人不会对等高线进行此操作,因为您需要添加有关高程的信息,而我认为您不需要这些信息

matplotlib
具有
eliple
,它是
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)


然后你需要研究如何获得你想要的效果,一般来说,我会通过
alpha
使事情透明,我个人不会对contour这样做,因为你需要添加我认为你不想要的高程信息

matplotlib
具有
eliple
,它是
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)

然后你需要研究如何获得你想要的效果,我通常会通过
alpha
来实现透明化