Skip to content

Commit

Permalink
DOC: enable matplotlib plot_directive to include figures in docstrings (
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche authored and jreback committed Mar 7, 2018
1 parent dd2b224 commit 5782ab8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
'ipython_sphinxext.ipython_console_highlighting',
# lowercase didn't work
'IPython.sphinxext.ipython_console_highlighting',
'matplotlib.sphinxext.plot_directive',
'sphinx.ext.intersphinx',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
Expand All @@ -85,6 +86,14 @@
if any(re.match("\s*api\s*", l) for l in index_rst_lines):
autosummary_generate = True

# matplotlib plot directive
plot_include_source = True
plot_formats = [("png", 90)]
plot_html_show_formats = False
plot_html_show_source_link = False
plot_pre_code = """import numpy as np
import pandas as pd"""

# Add any paths that contain templates here, relative to this directory.
templates_path = ['../_templates']

Expand Down
9 changes: 9 additions & 0 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2537,6 +2537,15 @@ def line(self, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
Examples
--------
.. plot::
:context: close-figs
>>> s = pd.Series([1, 3, 2])
>>> s.plot.line()
"""
return self(kind='line', **kwds)

Expand Down

0 comments on commit 5782ab8

Please sign in to comment.