有时默认的图例位置不符合我们的需要,那么我们可以使用下面的代码对legend位置进行调整. plt.legend(loc='String or Number', bbox_to_anchor=(num1, num2)) 其中,第一个参数loc,设置它可以遵循以下的表格 String Number upper right 1 upper left 2 lower left 3 lower right 4 right 5 center left 6 center right 7 lower cent
转自:https://www.cnblogs.com/alimin1987/p/8047833.html import matplotlib.pyplot as pltimport numpy as npimport pandas as pdx= np.arange(1,20,1)plt.plot(x,x**2,label='Fast')#label为标签plt.plot(x,x*2,label='Mormal')#lplt.legend(loc=0,ncol=2)#图例及位置: 1右上角,2
import matplotlib.pyplot as plt import math import numpy as np x = np.arange(-0.85,0.95,0.05) #获得函数结果 y1 = [math.log(1-a) for a in x] #画图 plt.plot(x, y1, linewidth=2, color='#007500', label='log1.5(x)') plt.legend(loc='lower right')#在右下角显示计算用的函数 plt.