19
19
20
20
21
21
def stackplot (axes , x , * args , ** kwargs ):
22
- """Draws a stacked area plot.
22
+ """
23
+ Draws a stacked area plot.
23
24
24
- *x* : 1d array of dimension N
25
+ Parameters
26
+ ----------
27
+ x : 1d array of dimension N
25
28
26
- *y* : 2d array of dimension MxN, OR any number 1d arrays each of dimension
27
- 1xN. The data is assumed to be unstacked. Each of the following
28
- calls is legal::
29
+ y : 2d array of dimension MxN, OR sequence of 1d arrays each of dimension 1xN
30
+ The data is assumed to be unstacked. Each of the following
31
+ calls is legal::
29
32
30
33
stackplot(x, y) # where y is MxN
31
34
stackplot(x, y1, y2, y3, y4) # where y1, y2, y3, y4, are all 1xNm
32
35
33
- Keyword arguments:
36
+ baseline : string
37
+ One of ``['zero', 'sym', 'wiggle', 'weighted_wiggle']``.
38
+
39
+ Method used to calculate the baseline. ``'zero'`` is just a
40
+ simple stacked plot.
41
+ ``'sym'`` is symmetric around zero and is sometimes called
42
+ 'ThemeRiver'.
43
+ ``'wiggle'`` minimizes the sum of the squared slopes.
44
+ ``'weighted_wiggle'`` does the same but weights to account for size of
45
+ each layer. It is also called 'Streamgraph'-layout. More details
46
+ can be found at http://leebyron.com/streamgraph/.
47
+
34
48
35
- *baseline* : ['zero', 'sym', 'wiggle', 'weighted_wiggle']
36
- Method used to calculate the baseline. 'zero' is just a
37
- simple stacked plot. 'sym' is symmetric around zero and
38
- is sometimes called `ThemeRiver`. 'wiggle' minimizes the
39
- sum of the squared slopes. 'weighted_wiggle' does the
40
- same but weights to account for size of each layer.
41
- It is also called `Streamgraph`-layout. More details
42
- can be found at http://leebyron.com/streamgraph/.
49
+ labels : Length N sequence of strings
50
+ Labels to assign to each data series.
43
51
44
52
45
- *labels* : A list or tuple of labels to assign to each data series.
53
+ colors : Length N sequence of colors
54
+ A list or tuple of colors. These will be cycled through and used to
55
+ colour the stacked areas.
46
56
57
+ **kwargs :
58
+ All other keyword arguments are passed to
59
+ `Axes.fill_between`
47
60
48
- *colors* : A list or tuple of colors. These will be cycled through and
49
- used to colour the stacked areas.
50
- All other keyword arguments are passed to
51
- :func:`~matplotlib.Axes.fill_between`
52
61
53
- Returns *r* : A list of
54
- :class:`~matplotlib.collections.PolyCollection`, one for each
55
- element in the stacked area plot.
62
+ Returns
63
+ -------
64
+ r : list
65
+ A list of `PolyCollection`, one for each element in the stacked area
66
+ plot.
56
67
"""
57
68
58
69
y = np .row_stack (args )
@@ -116,6 +127,6 @@ def stackplot(axes, x, *args, **kwargs):
116
127
color = axes ._get_lines .get_next_color ()
117
128
r .append (axes .fill_between (x , stack [i , :], stack [i + 1 , :],
118
129
facecolor = color ,
119
- label = six .next (labels , None ),
130
+ label = six .next (labels , None ),
120
131
** kwargs ))
121
132
return r
0 commit comments