2013-01-02 14 views

回答

0

當您創建補丁包括kwarg label,前

## bunch of code 
ax.add_patch(mpl.patches.Rectangle(...,label='fail')) 
## bunch of code 
ax.plot(...,label='some line') 
## bunch of code 
ax.legend() 

,它將被automaigically添加到您的傳奇。並且會爲每個添加了標籤的藝術家添加條目。

如果您通過legend(hands,labs)製作圖例,只需將修補程序對象添加到hands列表中,就像您將Line2D對象一樣。 legend真的在artists上工作,其中patchLine2D都源自於。