当图例在图外时,用plt.savefig保存的图片图例只保存了一半,在plt.savefig中加入“ bbox_inches = 'tight'”参数即可 plt.savefig('path', bbox_inches = 'tight')