8000 adding keyword plotting · matplotlib/matplotlib@b97d6ec · GitHub
[go: up one dir, main page]

Skip to content

Commit b97d6ec

Browse files
committed
adding keyword plotting
1 parent dc9c93d commit b97d6ec

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

doc/_static/mpl.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ body {
1919
}
2020

2121
a {
22-
color: #CA7900;
22+
color: #CA7900 !important;
2323
text-decoration: none;
2424
}
2525

doc/conf.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
extensions = ['matplotlib.sphinxext.mathmpl', 'sphinxext.math_symbol_table',
3030
'sphinx.ext.autodoc', 'matplotlib.sphinxext.only_directives',
3131
'sphinx.ext.doctest', 'sphinx.ext.autosummary',
32-
'sphinx.ext.inheritance_diagram',
32+
'sphinx.ext.inheritance_diagram', 'sphinx.ext.intersphinx',
3333
'sphinx_gallery.gen_gallery',
3434
'matplotlib.sphinxext.plot_directive',
3535
'sphinxext.github',
@@ -88,6 +88,13 @@ def _check_deps():
8888

8989
autodoc_docstring_signature = True
9090

91+
intersphinx_mapping = {
92+
'python': ('http://docs.python.org/', None),
93+
'numpy': ('http://docs.scipy.org/doc/numpy-dev/', None),
94+
'scipy': ('http://scipy.github.io/devdocs/', None),
95+
'pandas': ('http://pandas.pydata.org/pandas-docs/stable', None)
96+
}
97+
9198

9299
# Sphinx gallery configuration
93100
sphinx_gallery_conf = {

examples/misc/keyword_plotting.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Plotting with keywords
3+
======================
4+
5+
There are some instances where you have data in a format that lets you
6+
access particular variables with strings. For example, with
7+
:class:`numpy.recarray` or :class:`pandas.DataFrame`.
8+
9+
Matplotlib allows you provide such an object with
10+
the ``data`` keyword argument. If provided, then you may generate plots with
11+
the strings corresponding to these variables.
12+
"""
13+
14+
import numpy as np
15+
import matplotlib.pyplot as plt
16+
np.random.seed(19680801)
17+
18+
data = dict([(label, np.random.randn(50)) for label in ['a', 'b', 'c', 'd']])
19+
data['d'] = np.abs(data['d']) * 100
20+
21+
fig, ax = plt.subplots()
22+
ax.scatter('a', 'b', c='c', s='d', data=data)
23+
ax.set(xlabel='a', ylabel='b')
24+
plt.show()

tutorials/01_introductory/pyplot.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@
9393
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
9494
plt.show()
9595

96+
###############################################################################
97+
# .. _plotting-with-keywords:
98+
#
99+
# Plotting with keyword strings
100+
# =============================
101+
#
102+
# There are some instances where you have data in a format that lets you
103+
# access particular variables with strings. For example, with
104+
# :class:`numpy.recarray` or :class:`pandas.DataFrame`.
105+
106+
# Matplotlib allows you provide such an object with
107+
# the ``data`` keyword argument. If provided, then you may generate plots with
108+
# the strings corresponding to these variables.
109+
110+
data = dict([(label, np.random.randn(50)) for label in ['a', 'b', 'c']])
111+
plt.plot('a', 'b', color='c', data=data)
112+
plt.xlabel('a')
113+
plt.ylabel('b')
114+
plt.show()
115+
96116
###############################################################################
97117
# .. _controlling-line-properties:
98118
#

0 commit comments

Comments
 (0)
0