8000 DOC: Add a whatsnew entry for labeled data improvements · astrofrog/matplotlib@9846b9c · GitHub
[go: up one dir, main page]

Skip to content

Commit 9846b9c

Browse files
committed
DOC: Add a whatsnew entry for labeled data improvements
1 parent 55ed86e commit 9846b9c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Working with labeled data like pandas DataFrames
2+
------------------------------------------------
3+
Plot methods which take arrays as inputs can now also work with labeled data
4+
and unpack such data.
5+
6+
This means that the following two examples produce the same plot::
7+
8+
Example ::
9+
df = pandas.DataFrame({"var1":[1,2,3,4,5,6], "var2":[1,2,3,4,5,6]})
10+
plt.plot(df["var1"], df["var2"])
11+
12+
13+
Example ::
14+
plt.plot("var1", "var2", data=df)
15+
16+
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+
20+
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.
28+
29+
* ``plot()`` now uses the index of a ``Series`` instead of
30+
``np.arange(len(y))``, if no ``x`` argument is supplied.

0 commit comments

Comments
 (0)
0