2

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'
5
  • 1
    What do you get from matplotlib.get_configdir()? Commented Mar 16, 2015 at 10:07
  • 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. Commented Mar 16, 2015 at 10:11
  • @Marius see my edit to the question. Commented Mar 16, 2015 at 11:13
  • 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. Commented Mar 16, 2015 at 11:15
  • @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. Commented Mar 16, 2015 at 11:38

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.