@@ -3,28 +3,34 @@ Working with labeled data like pandas DataFrames
3
3
Plot methods which take arrays as inputs can now also work with labeled data
4
4
and unpack such data.
5
5
6
- This means that the following two examples produce the same plot::
6
+ This means that the following two examples produce the same plot:
7
7
8
8
Example ::
9
+
9
10
df = pandas.DataFrame({"var1":[1,2,3,4,5,6], "var2":[1,2,3,4,5,6]})
10
11
plt.plot(df["var1"], df["var2"])
11
12
12
13
13
14
Example ::
15
+
14
16
plt.plot("var1", "var2", data=df)
15
17
16
18
This works for most plotting methods, which expect arrays/sequences as
17
- inputs and ``data `` can be anything which supports ``__get_item__ ``
18
- (``dict ``, ``pandas.DataFrame ``,...).
19
+ inputs. ``data `` can be anything which supports ``__getitem__ ``
20
+ (``dict ``, ``pandas.DataFrame ``, ``h5py ``, ...) to access ``array `` like
21
+ values with string keys.
19
22
20
23
In addition to this, some other changes were made, which makes working with
21
- ``pandas.DataFrames `` easier:
22
-
23
- * For plotting methods which understand a ``label `` keyword argument but the
24
- user does not supply such an argument, this is now implicitly set by either
25
- looking up ``.name `` of the right input or by using the label supplied to
26
- lookup the input in ``data ``. In the above examples, this results in an
27
- implicit ``label="var2" `` for both cases.
24
+ labeled data (ex ``pandas.Series ``) easier:
25
+
26
+ * For plotting methods with ``label `` keyword argument, one of the
27
+ data inputs is designated as the label source. If the user does not
28
+ supply a ``label `` that value object will be introspected for a
29
+ label, currently by looking for a ``name `` attribute. If the value
30
+ object does not have a ``name `` attribute but was specified by as a
31
+ key into the ``data `` kwarg, then the key is used. In the above
32
+ examples, this results in an implicit ``label="var2" `` for both
33
+ cases.
28
34
29
35
* ``plot() `` now uses the index of a ``Series `` instead of
30
36
``np.arange(len(y)) ``, if no ``x `` argument is supplied.
0 commit comments