python – matplotlib.legend()函数中的loc参数解析

loc参数代表的是图例的位置,要是在画图的时候不设置这个参数,那么就不会出现图例。

loc参数可以选择10个参数,分别代表了不同位置,感兴趣的可以一个个去试一下(哈哈)

0: ‘best’

1: ‘upper right’

2: ‘upper left’

3: ‘lower left’

4: ‘lower right’

5: ‘right’

6: ‘center left’

7: ‘center right’

8: ‘lower center’

9: ‘upper center’

10: ‘center’

plt.legend(loc=’lower right’)等价于plt.legend(loc=4)

上面的代码的含义是将图例显示在图的右下角

Original: https://blog.csdn.net/fuheshi/article/details/121452858
Author: fuheshi
Title: python – matplotlib.legend()函数中的loc参数解析

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/764710/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球