matplotlib 找不到配置文件 matplotlibrc

matplotlib cannot find configuration file matplotlibrc

我在 Ubuntu 14.04 上使用 matplotlib 1.3.1 和 python 3.4.0。我想在 .config/matplotlib/matplotlibrc 中使用 matplotlibrc configuration file。然而,matplotlib 似乎无法找到它:

~$ ls ~/.config/matplotlib/
matplotlibrc
~$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
/usr/lib/python3/dist-packages/matplotlib/__init__.py:766: UserWarning: Could not find matplotlibrc; using defaults
  warnings.warn('Could not find matplotlibrc; using defaults')
/usr/lib/python3/dist-packages/matplotlib/__init__.py:882: UserWarning: could not find rc file; returning defaults
  warnings.warn(message)

我的matplotlibrc的内容是here的默认内容。

如何让matplotlib找到配置文件?

编辑:

>>> matplotlib.get_configdir()
'/home/<me>/.matplotlib'

matplotlib.get_configdir() 的文档字符串中,我发现如果 .matplotlib/ 存在,matplotlib 将不会查找 ~/.config

因此即使 ~/.config/matplotlib/matplotlibrc 存在,您也应该完全删除 ~/.matplotlib 目录。

请注意,之后我还必须 delete matplotlib's fontcache

我在这里找到了我的,而无需删除 .matplotlib 目录

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc