Josh Josh - 6 months ago 72
Python Question

ggplot styles in Python

When I look at the plotting style in the Pandas documentation, the plots look different from the default one. It seems to mimic the ggplot "look and feel".

Same thing with the seaborn's package.

How can I load that style? (even if I am not using a notebook?)


Update: If you have matplotlib >= 1.4, there is a new style module which has a ggplot style by default. To activate this, use:

from matplotlib import pyplot as plt'ggplot')

This is recommended above the styling through the pandas options as explained below (and is also used in the pandas docs now).

For pandas, use:

pd.options.display.mpl_style = 'default'

and this will give you the 'ggplot-like' style for matplotlib figures (Note that the name is a bit confusing as this is not enabled by default, and this should actually be added to the docs).

For seaborn, as Paul H commented, it is enough to import seaborn

By the way, if you really want something like ggplot in python with ggplot syntax (and not only ggplot-like style), there is also a python ggplot library based on pandas: