Pergunta

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?

Foi útil?

Solução

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 :)

Outras dicas

As MattDMo mentioned, using a sane matplotlibrc really helps. The book "Probabilistic-Programming-and-Bayesian-Methods-for-Hackers" also uses a nice matplotlibrc. See this for some examples.

Recently I'm using the package seaborn instead of a custom matplotlibrc not only because it makes my plots look great, but also because it adds some functionality for visualizing distributions, linear models and time series.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top