matplotlib.legend()函数用法

matplotlib.legend()函数用法

用的较多,作为记录

legend语法参数如下: matplotlib.pyplot.legend(*args, **kwargs)

matplotlib.legend()函数用法

几个暂时主要用的参数:

(1)设置图例位置

使用loc参数 plt.legend(loc=upper left')

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'

(2)设置图例字体

设置字体大小

fontsize : int or float or {‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’}