Finding matplotlibrc Matplotlib defaults file

Tell current matplotlibrc location

python -c "import matplotlib; print(matplotlib.matplotlib_fname())"


Location Priority Order

from highest to lowest priority:

  1. matplotlibrc file in current working directory
  2. $MATPLOTLIBRC/matplotlibrc (this is often not set/used)
  3. operating system specific:
    • Linux: ~/.config/matplotlib/matplotlibrc
    • MacOS / Windows:  ~/.matplotlib/matplotlibrc
  4. $(python -c "import site; print(site.getsitepackages()[0])")/matplotlib/mpl-data/matplotlibrc

From my experience, often option #4 is the one the vast majority of people are using. You can therefore help ensure end users have the same plotting experience as you by putting a matplotlibrc file in your Python code directory that users run your script from.

Seaborn makes beautiful Matplotlib defaults

Consider using Seaborn for beautiful matplotlib plots.