ó
 m[c           @` sf   d  Z  d d l m Z m Z m Z m Z d d l Z d d l m Z d d l	 Z
 d g Z d   Z d S(   uâ   
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    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   xrangeu	   stackplotc         O` si  t  j |  } t | j d g    } | j d d  } | d k	 rX |  j d |  n  | j d d  } t  j | d d d t  j | j t  j	  } | d k rŽ d	 }	 nĖ| d
 k rė t  j
 | d  d }	 | |	 d d d  f 7} n| d k rQ| j d }
 | |
 d t  j |
  d d  d f j
 d  }	 |	 |
 }	 | |	 7} n'| d k rX| j \ }
 } t  j
 | d  } t  j |  } | d k } 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   } |  j | |	 | d d d  f d | d t | d  | } d g | j j (| g } x t t |  d  D]m } |  j j   } | j |  j | | | d d  f | | d d d  f d | d t | d  |  qôW| S(   uŧ  
    Draws a stacked area plot.

    Parameters
    ----------
    x : 1d array of dimension N

    y : 2d array (dimension MxN), or sequence of 1d arrays (each 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

    baseline : ['zero' | 'sym' | 'wiggle' | 'weighted_wiggle']
        Method used to calculate the baseline:

        - ``'zero'``: Constant zero baseline, i.e. a simple stacked plot.
        - ``'sym'``:  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://leebyron.com/streamgraph/.

    labels : Length N sequence of strings
        Labels to assign to each data series.

    colors : Length N sequence of colors
        A list or tuple of colors. These will be cycled through and used to
        colour the stacked areas.

    **kwargs :
        All other keyword arguments are passed to `Axes.fill_between()`.


    Returns
    -------
    list : list of `.PolyCollection`
        A list of `.PolyCollection` instances, one for each element in the
        stacked area plot.
    u   labelsu   colorst   coloru   baselineu   zerot   axisi    t   dtypeg        u   symg      ā?Nu   wiggleu   weighted_wiggleg      ð?i   u#   Baseline method %s not recognised. u5   Expected 'zero', 'sym', 'wiggle' or 'weighted_wiggle't	   facecolort   label(   t   npt	   row_stackt   itert   popt   Nonet   set_prop_cyclet   cumsumt   promote_typesR   t   float32t   sumt   shapet   aranget
   zeros_liket   hstackt   difft
   ValueErrort
   _get_linest   get_next_colort   fill_betweent   nextt   sticky_edgest   yR   t   lent   append(   t   axest   xt   argst   kwargsR   t   labelst   colorst   baselinet   stackt
   first_linet   mt   nt   totalt	   inv_totalt   maskt   increaset
   below_sizet   move_upt   centert   errstrR   t   collt   rt   i(    (    s3   lib/python2.7/site-packages/matplotlib/stackplot.pyt	   stackplot   s^    --	44



"		<(   t   __doc__t
   __future__R    R   R   R   t   sixt	   six.movesR   t   numpyR
   t   __all__R8   (    (    (    s3   lib/python2.7/site-packages/matplotlib/stackplot.pyt   <module>   s   "	