我写的和我的书一样。但这不起作用,每次都会出现相同的错误。
>>> import matplotlib as mpl
>>> my_font = { 'family' : 'sans-serif', 'weight' : 'normal', 'size' : 22, 'color' : 'red'}
>>> mpl.rc('font', **my_font)
来了
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 817, in __setitem__
cval = self.validate[key](val)
KeyError: 'font.color'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 1159, in rc
rcParams[key] = v
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 824, in __setitem__
'list of valid parameters.' % (key,))
KeyError: 'font.color is not a valid rc parameter. See rcParams.keys() for a list of valid parameters.'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 1162, in rc
'name "%s"') % (key, g, name))
KeyError: 'Unrecognized key "font.color" for group "font" and name "color"'
该如何解决该问题?