如何在子图中添加图例

时间:2017-09-16 16:48:55

标签: python matplotlib plot legend

我有这个情节 enter image description here

我想在图表的下方水平放置带有颜色代码的图例。如果我可以在图表和图例中选择颜色,那也很棒。现在它生成为

fix,axes=plt.subplots(nrows=5,ncols=4, figsize=(20,20))
plots=[]
for i in range(0,5):
    for j in range(0,4):
        x = list(bdf.groupby('condition').mean().   [bdf.columns[detection_idx]])
        y1 = list(df.groupby('condition').mean() [df.columns[aesthetic_idx]])
    plots.append(axes[i][j].scatter(x,y1, c = range(0, len(conditions))))
    s = list(scenes.values())[i*4+j]
    axes[i][j].title.set_text(s)
    axes[i][j].set_xlabel('Detection accuracy')
    axes[i][j].set_ylabel('Visual aesthetics')
    aesthetic_idx+=4
    detection_idx+=1
    plt.figlegend(tuple(plots), tuple(conditions), loc='lower left', bbox_to_anchor=(0.0, -0.1), ncol=len(conditions))

0 个答案:

没有答案