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 ...
从matplotlib documentation
这会将所有项的字体设置为kwargs对象
font
指定的字体。或者,您也可以使用
rcParams
update
方法,如this answer中所建议的:或者
您可以在Customizing matplotlib page上找到可用属性的完整列表。
如果你像我一样是个控制狂,你可能需要显式地设置所有字体大小:
注意,您还可以设置调用
rc
方法对matplotlib
的大小:相关问题 更多 >
编程相关推荐