Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added support for custom colour cycle.
New keyword argument 'colors' can be passed to allow custom colouring of
the stacked areas in a stacked area plot.
  • Loading branch information
dmcdougall committed Jun 19, 2012
commit a66ca21b447a39c6806f21ca73c8d0d4a87de847
10 changes: 9 additions & 1 deletion lib/matplotlib/stackplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def stackplot(axes, x, *args, **kwargs):

stackplot(x, y) # where y is MxN
staclplot(x, y1, y2, y3, y4) # where y1, y2, y3, y4, are all 1xNm
*kwargs* : All keyword arguments are those supported by

Keyword arguments:
*colors* : A list or tuple of colors. These will be cycled through and
used to colour the stacked areas.
All other keyword arguments are passed to
:func:`~matplotlib.Axes.fill_between`

Returns
Expand All @@ -38,6 +42,10 @@ def stackplot(axes, x, *args, **kwargs):
elif len(args) > 1:
y = np.row_stack(args)

colors = kwargs.pop('colors', None)
if colors is not None:
axes.set_color_cycle(colors)

# Assume data passed has not been 'stacked', so stack it here.
y_stack = np.cumsum(y, axis=0)

Expand Down