首页 > 解决方案 > 让图例留在底部 matplotlib python

问题描述

我有一个包含大约 30 条不同曲线的图表,我想在图例中显示它们。但它太长了,它们并不都适合。我想把它们放在底部,我该怎么做?

fig = plt.figure()
for i in range(len(data)):
    print(i)
    x1 = data.loc[0][5:-4]
    y1 = data.loc[i][5:-4]
    y1.replace(' ',100.0,inplace=True)
    x = list(reversed(x1))
    y = list(reversed(y1))
    report_num = data.loc[i,'Report No']
    plt.plot(x, y, label = report_num)
    plt.xscale('log')
    plt.grid()   
    plt.yticks(yints)
    plt.xticks(x,x,rotation=40)   
    plt.title('Particle Size Distribution Curve - %s'%(report_num))
    plt.legend(loc=1)  

标签: pythonmatplotliblegend

解决方案


推荐阅读