我在 Ubuntu 14.04 上使用 matplotlib 1.3.1 和 python 3.4.0。我想使用 matplotlibrc configuration file在 .config/matplotlib/matplotlibrc 中。然而 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之后。
关于python - matplotlib 找不到配置文件 matplotlibrc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29073802/