Skip to content

Commit 1ea5e2c

Browse files
jorisvandenbosschepandres
authored andcommitted
DOC: enable matplotlib plot_directive to include figures in docstrings (pandas-dev#20015)
1 parent fc3e50f commit 1ea5e2c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

doc/source/conf.py

+9
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
'ipython_sphinxext.ipython_console_highlighting',
6464
# lowercase didn't work
6565
'IPython.sphinxext.ipython_console_highlighting',
66+
'matplotlib.sphinxext.plot_directive',
6667
'sphinx.ext.intersphinx',
6768
'sphinx.ext.coverage',
6869
'sphinx.ext.mathjax',
@@ -85,6 +86,14 @@
8586
if any(re.match("\s*api\s*", l) for l in index_rst_lines):
8687
autosummary_generate = True
8788

89+
# matplotlib plot directive
90+
plot_include_source = True
91+
plot_formats = [("png", 90)]
92+
plot_html_show_formats = False
93+
plot_html_show_source_link = False
94+
plot_pre_code = """import numpy as np
95+
import pandas as pd"""
96+
8897
# Add any paths that contain templates here, relative to this directory.
8998
templates_path = ['../_templates']
9099

pandas/plotting/_core.py

+9
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,15 @@ def line(self, **kwds):
25372537
Returns
25382538
-------
25392539
axes : matplotlib.AxesSubplot or np.array of them
2540+
2541+
Examples
2542+
--------
2543+
2544+
.. plot::
2545+
:context: close-figs
2546+
2547+
>>> s = pd.Series([1, 3, 2])
2548+
>>> s.plot.line()
25402549
"""
25412550
return self(kind='line', **kwds)
25422551

0 commit comments

Comments
 (0)