How do I get the modern style matplotlib plots often seen in iPython Notebook examples?

Take this page, for example, a sample of which is posted below:

enter image description here

It has matplotlib examples with gray background and more subtle coloring, but when I’m running the same examples, I get the more traditionally colored plots with white background and strong colors. This also seems to be the style used in the pandas documentation.

How can I change the default style locally to match their style?

Best answer

If you read through the page you linked, just above the Plotting in Pandas section is the following line:

If you want to make your plots look pretty like mine, steal the matplotlibrc file from Huy Nguyen.

In the post is a link to this gist, which contains the matplotlibrc file. Make sure you read through the whole thing and customize it, as for example he has MacOSX as his backend, which you may want to change.

To use the file, save it as ~/.matplotlib/matplotlibrc and restart any running instances of IPython. Your plots should now look prettier 🙂