天天看點

使用plt為python作的圖添加圖例

參考

plt.legend(labels=["sin function","cos function"],loc="lower right",fontsize=6)  
#labels為圖例的文字标注,loc為圖例放置的位置

           
loc參數的含義
best :自動選擇最佳位置。
upper right :将圖例放在右上角。
upper left :将圖例放在左上角。
lower left :将圖例放在左下角。
lower right :将圖例放在右下角。
right :将圖例放在右邊。
center left :将圖例放在左邊居中的位置。
center right :将圖例放在右邊居中的位置。
lower center :将圖例放在底部居中的位置。
upper center :将圖例放在頂部居中的位置。
center :将圖例放在中心。