Skip to content

DOC: Change plot style to matplotlib decault from ggplot #17462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/10min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
import matplotlib
matplotlib.style.use('ggplot')
# matplotlib.style.use('default')
pd.options.display.max_rows = 15

#### portions of this were borrowed from the
Expand Down
2 changes: 1 addition & 1 deletion doc/source/computation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
np.set_printoptions(precision=4, suppress=True)
import pandas as pd
import matplotlib
matplotlib.style.use('ggplot')
# matplotlib.style.use('default')
import matplotlib.pyplot as plt
plt.close('all')
pd.options.display.max_rows=15
Expand Down
2 changes: 1 addition & 1 deletion doc/source/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
pd.options.display.max_rows=15

import matplotlib
matplotlib.style.use('ggplot')
# matplotlib.style.use('default')

np.set_printoptions(precision=4, suppress=True)

Expand Down
2 changes: 1 addition & 1 deletion doc/source/dsintro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pd.options.display.max_rows = 15

import matplotlib
matplotlib.style.use('ggplot')
# matplotlib.style.use('default')
import matplotlib.pyplot as plt
plt.close('all')

Expand Down
2 changes: 1 addition & 1 deletion doc/source/gotchas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Frequently Asked Questions (FAQ)
import pandas as pd
pd.options.display.max_rows = 15
import matplotlib
matplotlib.style.use('ggplot')
# matplotlib.style.use('default')
import matplotlib.pyplot as plt
plt.close('all')

Expand Down
2 changes: 1 addition & 1 deletion doc/source/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pandas as pd
pd.options.display.max_rows = 15
import matplotlib
matplotlib.style.use('ggplot')
# matplotlib.style.use('default')
import matplotlib.pyplot as plt
plt.close('all')
from collections import OrderedDict
Expand Down
2 changes: 1 addition & 1 deletion doc/source/missing_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pandas as pd
pd.options.display.max_rows=15
import matplotlib
matplotlib.style.use('ggplot')
# matplotlib.style.use('default')
import matplotlib.pyplot as plt

.. _missing_data:
Expand Down
28 changes: 18 additions & 10 deletions doc/source/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
np.set_printoptions(precision=4, suppress=True)
pd.options.display.max_rows = 15
import matplotlib
matplotlib.style.use('ggplot')
# matplotlib.style.use('default')
import matplotlib.pyplot as plt
plt.close('all')

Expand All @@ -24,13 +24,6 @@ We use the standard convention for referencing the matplotlib API:

import matplotlib.pyplot as plt

The plots in this document are made using matplotlib's ``ggplot`` style (new in version 1.4):

.. code-block:: python

import matplotlib
matplotlib.style.use('ggplot')

We provide the basics in pandas to easily create decent looking plots.
See the :ref:`ecosystem <ecosystem.visualization>` section for visualization
libraries that go beyond the basics documented here.
Expand Down Expand Up @@ -134,7 +127,7 @@ For example, a bar plot can be created the following way:
plt.figure();

@savefig bar_plot_ex.png
df.iloc[5].plot(kind='bar'); plt.axhline(0, color='k')
df.iloc[5].plot(kind='bar');

.. versionadded:: 0.17.0

Expand All @@ -154,7 +147,7 @@ and :ref:`DataFrame.boxplot() <visualization.box>` methods, which use a separate

Finally, there are several :ref:`plotting functions <visualization.tools>` in ``pandas.plotting``
that take a :class:`Series` or :class:`DataFrame` as an argument. These
include
include:

* :ref:`Scatter Matrix <visualization.scatter_matrix>`
* :ref:`Andrews Curves <visualization.andrews_curves>`
Expand Down Expand Up @@ -1049,6 +1042,21 @@ be colored differently.
Plot Formatting
---------------

Setting the plot style
~~~~~~~~~~~~~~~~~~~~~~

From version 1.5 and up, matplotlib offers a range of preconfigured plotting styles. Setting the
style can be used to easily give plots the general look that you want.
Setting the style is as easy as calling ``matplotlib.style.use(my_plot_style)`` before
creating your plot. For example you could do ``matplotlib.style.use('ggplot')`` for ggplot-style
plots.

You can see the various available style names at ``matplotlib.style.available`` and it's very
easy to try them out.

General plot style arguments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Most plotting methods have a set of keyword arguments that control the
layout and formatting of the returned plot:

Expand Down