8000 Update lib/matplotlib/stackplot.py · thedatacurious/matplotlib@8eb6289 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8eb6289

Browse files
Update lib/matplotlib/stackplot.py
1 parent a9dc9ac commit 8eb6289

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

lib/matplotlib/stackplot.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,53 @@ def stackplot(axes, x, *args,
2323
2424
Parameters
2525
----------
26-
x : (N,) array-like
26+
x : array-like
2727
28-
y : (M, N) array-like
29-
The data is assumed to be unstacked. Each of the following
30-
calls is legal::
28+
y : multiple array-like, 2D array-like or pandas.DataFrame
3129
32-
stackplot(x, y) # where y has shape (M, N)
33-
stackplot(x, y1, y2, y3) # where y1, y2, y3, y4 have length N
30+
- multiple array-like: the data is unstacked
31+
32+
.. code-block:: none
33+
34+
# year_1, year_2, year_3
35+
y1 = [value_1_A, value_2_A, value_3_A] # category_A
36+
y2 = [value_1_B, value_2_B, value_3_B] # category_B
37+
y3 = [value_1_C, value_2_C, value_3_C] # category_C
38+
39+
x = [*range(3)]
40+
41+
Example call:
42+
43+
.. code-block:: python
44+
45+
stackplot(x, y1, y2, y3)
46+
47+
- 2D array-like: Each row represents a category, each column represents an x-axis dimension associated with the categories. A list of 1D array-like can also be passed; each list item must have the same length
48+
49+
Example call:
50+
51+
.. code-block:: python
52+
53+
y = [y1, y2, y3]
54+
x = [*range(3)]
55+
56+
stackplot(x, y)
57+
58+
- a `pandas.DataFrame`: The index is used for the categories, each column represents an x-axis dimension associated with the categories.
59+
60+
Example call:
61+
62+
.. code-block:: python
63+
64+
y = pd.DataFrame(
65+
np.random.random((3, 3)),
66+
index=["category_A", "category_B", "category_C"],
67+
columns=[*range(3)]
68+
)
69+
70+
x = df.columns
71+
72+
stackplot(x, y)
3473
3574
baseline : {'zero', 'sym', 'wiggle', 'weighted_wiggle'}
3675
Method used to calculate the baseline:

0 commit comments

Comments
 (0)
0