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

Skip to content
Closed
Show file tree
Hide file tree
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
Stackplot now supports the same keyword aargs as matplotlib.Axes.fill…
…_between().

This is a measure to make boilerplate.py not produce a pyplot.py file
with syntax errors. It's also a sensible course of action considering
new stackplot features will almost certainly require keyword arguments
anyway.
  • Loading branch information
dmcdougall committed Jun 19, 2012
commit 38a903f3a3841e070fd26040784fdac4fb015285
4 changes: 2 additions & 2 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6409,8 +6409,8 @@ def quiver(self, *args, **kw):
return q
quiver.__doc__ = mquiver.Quiver.quiver_doc

def stackplot(self, x, *args):
return mstack.stackplot(self, x, *args)
def stackplot(self, x, *args, **kwargs):
return mstack.stackplot(self, x, *args, **kwargs)
stackplot.__doc__ = mstack.stackplot.__doc__

def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
Expand Down
14 changes: 8 additions & 6 deletions lib/matplotlib/stackplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__all__ = ['stackplot']


def stackplot(axes, x, *args):
def stackplot(axes, x, *args, **kwargs):
"""Draws a stacked area plot.

Parameters
Expand All @@ -23,12 +23,14 @@ def stackplot(axes, x, *args):
calls is legal:

stackplot(x, y) # where y is MxN
staclplot(x, y1, y2, y3, y4) # where y1, y2, y3, y4, are all 1xN
staclplot(x, y1, y2, y3, y4) # where y1, y2, y3, y4, are all 1xNm
*kwargs* : All keyword arguments are those supported by
:func:`~matplotlib.Axes.fill_between`

Returns
-------
*r* : A list of `matplotlib.collections.PolyCollection`, one for each
element in the stacked area plot.
*r* : A list of :class:`~matplotlib.collections.PolyCollection`, one for
each element in the stacked area plot.
"""

if len(args) == 1:
Expand All @@ -42,9 +44,9 @@ def stackplot(axes, x, *args):
r = []

# Color between x = 0 and the first array.
r.append(axes.fill_between(x, 0, y_stack[0,:], facecolor=axes._get_lines.color_cycle.next()))
r.append(axes.fill_between(x, 0, y_stack[0,:], facecolor=axes._get_lines.color_cycle.next(), **kwargs))

# Color between array i-1 and array i
for i in xrange(len(y)-1):
r.append(axes.fill_between(x, y_stack[i-1,:], y_stack[i,:], facecolor=axes._get_lines.color_cycle.next()))
r.append(axes.fill_between(x, y_stack[i-1,:], y_stack[i,:], facecolor=axes._get_lines.color_cycle.next(), **kwargs))
return r