After some misadventures with matplotlib (misadventures due to the famous display errors, if you really need to know, if you don't configure correctly your matplolib you can generate empty figures… see the backend section later :o) I talked about the joy of having a matplotlibrc and how life is easier with one.
It's just a configuration file for matplotlib (just like your bashrc) that avoids to play with the options dynamically, and to keep them sitting close to you for your next use.
You'll admit that for backends issues (the source you use in matploblib, more details here), on servers without X servers and to have a consistent style for every figure in your thesis, it's quite useful!
It's quite simple, matplotlib is going to look at 4 different places when it loads:
Just run the following lines in your iPython3 shell:
To be short (yes, thank you very much, I know how to keep it short from times to times ^^): every configuration of matplotlib you wish to keep from one time to another.
I do think about the backend you use.
To do that, just add the following lines in your matplotlibrc:
# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo
# MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG # Template.
# You can also deploy your own backend outside of matplotlib by
# referring to the module name (which must be in the PYTHONPATH) as
backend : Agg
And, so that the backend finds automatically another solution in case of conflicts:
# if you are running pyplot inside a GUI and your backend choice
# conflicts, we will automatically try to find a compatible one for
# you if backend_fallback is True
Some coolish options:
interactive : False
toolbar : toolbar2 # None | toolbar2 ("classic" is deprecated)
timezone : Europe # a pytz timezone string, e.g., US/Central or Europe/Paris
Yes, everything before is great, but I promised consistent figures throughout your thesis!
In fact, you can specify everything in your matplotlibrc: from how the lines look in boxplots, through the fonts and the use of LaTeX.
Rather than giving you a list that long, I suggest you check this git repository. You'll find demos of several matplotlibrc: some R-like, some ggplot-like,… and since we are in the middle of the wonderful world of configuration files, please know that a lot of those exist (some are even listed in that git repository).
Here you go, go to your favorite text editor and go create your own matplotlibrc.Share on Twitter Share on Facebook