|
7 | 7 | access particular variables with strings. For example, with |
8 | 8 | :class:`numpy.recarray` or :class:`pandas.DataFrame`. |
9 | 9 |
|
10 | | -Matplotlib allows you provide such an object with |
11 | | -the ``data`` keyword argument. If provided, then you may generate plots with |
12 | | -the strings corresponding to these variables. |
| 10 | +Matplotlib allows you provide such an object with the ``data`` keyword |
| 11 | +argument. If provided, then you may generate plots with the strings |
| 12 | +corresponding to these variables. |
13 | 13 | """ |
14 | 14 |
|
15 | 15 | import numpy as np |
16 | 16 | import matplotlib.pyplot as plt |
17 | 17 | np.random.seed(19680801) |
18 | 18 |
|
19 | | -data = dict([('a', np.arange(50)), |
20 | | - ('c', np.random.randint(0, 50, 50)), |
21 | | - ('d', np.random.randn(50))]) |
| 19 | +data = {'a': np.arange(50), |
| 20 | + 'c': np.random.randint(0, 50, 50), |
| 21 | + 'd': np.random.randn(50)} |
22 | 22 | data['b'] = data['a'] + 10 * np.random.randn(50) |
23 | 23 | data['d'] = np.abs(data['d']) * 100 |
24 | 24 |
|
25 | 25 | fig, ax = plt.subplots() |
26 | 26 | ax.scatter('a', 'b', c='c', s='d', data=data) |
27 | | -ax.set(xlabel='a', ylabel='b') |
| 27 | +ax.set(xlabel='entry a', ylabel='entry b') |
28 | 28 | plt.show() |
0 commit comments