![](/img/trans.png)
[英]Python Pandas MultiIndex Plot has incorrectly colored legend
[英]Incorrectly placed legend in python pandas
我正在使用foll。 代碼在python pandas中繪制圖例,但未正確顯示:
# Create plot
fig = plt.figure()
plt.rc('legend',**{'fontsize':8})
ax = df.resample('M', how='mean').plot(colormap=cols)
# Create a legend with transparent box around it
leg = plt.legend(fancybox = None, bbox_to_anchor=(0.5, -0.02), ncol=3)
leg.get_frame().set_linewidth(0.5)
leg.get_frame().set_alpha(0.5)
ax.set_ylabel('Percentiles')
# Place legend in right place and output
fig.subplots_adjust(bottom=0.2)
我該如何解決? 我希望圖例不在情節中,但可見且不被部分截斷。
bbox_to_anchor中的第二個參數控制y軸。 嘗試更改它,例如:
leg = plt.legend(fancybox = None, bbox_to_anchor=(0.5, -0.04), ncol=3)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.