2013-10-12 96 views
2

我試圖繪製類似的東西: enter image description herematplotlib繪製橢圓輪廓​​

的主要思想是從繪製不同顏色的橢圓在一些特定的範圍內,例如[-6,6]。我知道plt.contour函數可以使用。但我不明白如何生成線條。

回答

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完成的效果。