plt.legend(loc=‘String or Number’, bbox_to_anchor=(num1, num2))
这个参数来定位图例的大概位置,string参数包括
best (自动找一个最好的位置,但有时不符合我们的预期)
upper right(右上角)
upper left (左上角)
lower left (左下角)
lower right (右下角)
right (右,和center right位置一样)
center left (中间偏左)
center right (中间偏右)
lower center(中间偏下)
upper center(中间偏上)
center(正中间)
ax1[0].legend(list(df1), fontsize=6, loc='upper left')
参考:
python中matplotlib调整图例位置_liuxiaoru_的博客-CSDN博客_matplotlib 图例位置



