2
votes

I am using matplotlib 1.3.1 with python 3.4.0 on Ubuntu 14.04. I would like to use a matplotlibrc configuration file in .config/matplotlib/matplotlibrc. However it seems like matplotlib is unable to find it:

~$ 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)

The content of my matplotlibrc is the default one from here.

How can I make matplotlib find the configuration file?

EDIT:

>>> matplotlib.get_configdir()
'/home/<me>/.matplotlib'
2
What do you get from matplotlib.get_configdir()? - Marius
Do you have the correct permissions to read ~/.config/matplotlib/matplotlibrc? chmod u+rwx ~/.config/matplotlib and chmod u+r ~/.config/matplotlib/matplotlibrc might help. - unutbu
@Marius see my edit to the question. - fouronnes
OK, so it looks like you should be putting the matplotlibrc file in ~/.matplotlib rather than ~/.config/matplotlib then. Not sure why the config path would have changed. - Marius
@Marius But when I do that I get the message UserWarning: Found matplotlib configuration in ~/.matplotlib/. To conform with the XDG base directory standard, this configuration location has been deprecated on Linux, and the new location is now '/home/me/.config'/matplotlib/. Please move your configuration there to ensure that matplotlib will continue to find it in the future. So I'd like to use the correct location, or at least get rid of the warning. - fouronnes

2 Answers

3
votes

From the docstring of matplotlib.get_configdir() I discovered that matplotlib will not look in ~/.config if .matplotlib/ exists.

So even though ~/.config/matplotlib/matplotlibrc exists, you should delete the ~/.matplotlib directory entirely.

Note that I also had to delete matplotlib's fontcache afterwards.

0
votes

I found mine here without having to delete the .matplotlib dir

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