Move the legend of pandas plot

Move the legend of pandas plot

有時候legend字太多會擋到圖,這時可以用.legend(bbox_to_anchor=(1.5, 1)):

pd.DataFrame(sample_array, columns=sample_columns,index=sample_index).plot.bar().legend(bbox_to_anchor=(1.5, 1))

legend就會顯示在圖的右邊

 


未分類

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *