700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > python怎么改变字体大小_如何在matplotlib图上更改字体大小

python怎么改变字体大小_如何在matplotlib图上更改字体大小

时间:2023-06-01 16:47:24

相关推荐

python怎么改变字体大小_如何在matplotlib图上更改字体大小

如果你像我这样的控制狂,你可能想要明确设置你所有的字体大小:

import matplotlib.pyplot as plt

SMALL_SIZE = 8

MEDIUM_SIZE = 10

BIGGER_SIZE = 12

plt.rc('font', size=SMALL_SIZE) # controls default text sizes

plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title

plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels

plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels

plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels

plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize

plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title

请注意,您还可以设置调用rc方法的大小matplotlib:

import matplotlib

SMALL_SIZE = 8

matplotlib.rc('font', size=SMALL_SIZE)

matplotlib.rc('axes', titlesize=SMALL_SIZE)

# and so on ...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。