ó
±éRc           @   s(   d  Z  d d l Z d g Z d „  Z d S(   sâ   
Stacked area plot for 1D arrays inspired by Douglas Y'barbo's stackoverflow
answer:
http://stackoverflow.com/questions/2225995/how-can-i-create-stacked-line-graph-with-matplotlib

(http://stackoverflow.com/users/66549/doug)

iÿÿÿÿNt	   stackplotc      	   O   s*  t  | ƒ d k r$ t j | Œ  } n$ t  | ƒ d k rH t j | ƒ } n  | j d d
 ƒ } | d
 k	 rv |  j | ƒ n  | j d d ƒ } t j | d d ƒ} g  } | d k r¸ d }	 n±| d k rø t j | d ƒ d	 }	 | |	 d
 d
 d
 … f 7} nq| d k r`| j	 d }
 | |
 d	 t j
 d |
 ƒ d
 d
 … d
 f j d ƒ }	 |	 |
 :}	 | |	 7} n	| d k rI| j	 \ }
 } t j | ƒ } t j | d ƒ } t j | d
 d
 … d d … f t j | ƒ f ƒ } | | } | d	 | 7} | | } d	 | d
 d
 … d f <| d	 | } t j | j d ƒ ƒ } | d	 | }	 | |	 7} n  d | } | d 7} t | ƒ ‚ | j |  j | |	 | d d
 d
 … f d |  j j j ƒ  | �ƒ xy t t  | ƒ d ƒ D]a } |  j j j ƒ  } | j |  j | | | d
 d
 … f | | d d
 d
 … f d | | �ƒ qÁW| S(   s?  Draws a stacked area plot.

    *x* : 1d array of dimension N

    *y* : 2d array of dimension MxN, OR any number 1d arrays each of dimension
          1xN. The data is assumed to be unstacked. Each of the following
          calls is legal::

            stackplot(x, y)               # where y is MxN
            stackplot(x, y1, y2, y3, y4)  # where y1, y2, y3, y4, are all 1xNm

    Keyword arguments:

    *baseline* : ['zero', 'sym', 'wiggle', 'weighted_wiggle']
                Method used to calculate the baseline. 'zero' is just a
                simple stacked plot. 'sym' is symmetric around zero and
                is sometimes called `ThemeRiver`.  'wiggle' minimizes the
                sum of the squared slopes. 'weighted_wiggle' does the
                same but weights to account for size of each layer.
                It is also called `Streamgraph`-layout. More details
                can be found at http://www.leebyron.com/else/streamgraph/.


    *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 *r* : A list of
    :class:`~matplotlib.collections.PolyCollection`, one for each
    element in the stacked area plot.

    Note that :class:`~matplotlib.legend.Legend` does not support
    :class:`~matplotlib.collections.PolyCollection` objects.  To create a
    legend on a stackplot, use a proxy artist:
    http://matplotlib.org/users/legend_guide.html#using-proxy-artist
    i   t   colorst   baselinet   zerot   axisi    g        t   symg      à?Nt   wigglet   weighted_wiggles#   Baseline method %s not recognised. s5   Expected 'zero', 'sym', 'wiggle' or 'weighted_wiggle't	   facecolor(   t   lent   npt
   atleast_2dt	   row_stackt   popt   Nonet   set_color_cyclet   cumsumt   sumt   shapet   aranget   zerost   hstackt   difft
   ValueErrort   appendt   fill_betweent
   _get_linest   color_cyclet   nextt   xrange(   t   axest   xt   argst   kwargst   yR   R   t   stackt   rt
   first_linet   mt   nt   centert   totalt   increaset
   below_sizet   move_upt   errstrt   it   color(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/stackplot.pyR       sZ    '	74



(
<(   t   __doc__t   numpyR
   t   __all__R    (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/stackplot.pyt   <module>   s   	