这应该很简单:我想设置 matplotlib 的样式
suptitle
。
文档说
fontproperties
是可以作为参数提供的字体属性的字典。
所以:
import matplotlib.pyplot as plt
import matplotlib as mpl
fig, ax = plt.subplots()
ax.set_xlim(0, 1)
fdct = {'color': 'r', 'fontsize': 32}
# Generates error
fig.suptitle('A title', fontproperties=fdct)
# Works
fig.suptitle('A title', fontsize=32)
第一个命令生成
TypeError: FontProperties.__init__() got an unexpected keyword argument 'color'
但是为什么呢?我想使用字体属性的字典来设置字幕样式,就像我对
Text
的其他实例所做的那样。