子图网格,外面的图例,savefig不起作用

时间:2015-07-23 19:25:07

标签: python matplotlib

我和这个家伙here有同样的问题,所以我想将我的传奇放在情节之外,但是savefig不起作用。此外,我正在使用子图环境。所以,让我在这里尽可能地说出问题:

 fig, axarr = plt.subplots(n,m)
 #... (plotting)...
 axarr[k,l].legend(loc=(X,Y)) # X and Y such that outside of plot
 plt.savefig("test.pdf")

顺便说一句,对我来说关键字'bbox_inches'不起作用。

1 个答案:

答案 0 :(得分:1)

你可以试试这可能有效

lgd = axarr[k,l].legend(loc=(X,Y)) # X and Y such that outside of plot
plt.savefig("test.pdf", bbox_inches='tight', bbox_extra_artists=(lgd,))
相关问题