3
6Ad]õ ã            
   @   sÎ  d Z ddlZddlmZ ddlZddlZddlm	Z	m
Z
mZmZmZmZmZmZmZ ddlZejddgdd	gd
dgdddgddgdœƒG dd„ de
jejƒƒZejjdd� G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZ G d d!„ d!e ƒZ!G d"d#„ d#e ƒZ"G d$d%„ d%eƒZ#G d&d'„ d'e#ƒZ$G d(d)„ d)eƒZ%G d*d+„ d+eƒZ&G d,d-„ d-eƒZ'G d.d/„ d/eƒZ(G d0d1„ d1eƒZ)e
j*eƒZ+xd3D ]Z,ejje,e+iƒ �qœW ejje
j*e#ƒd2� dS )4ay  
Classes for the efficient drawing of large collections of objects that
share most properties, e.g., a large number of line segments or
polygons.

The classes are not meant to be as flexible as their single element
counterparts (e.g., you may not be able to select all line styles) but
they are meant to be fast for common use cases (e.g., a large set of solid
line segments).
é    N)ÚNumberé   )	Ú_pathÚartistÚcbookÚcmÚcolorsÚ	docstringÚlinesÚpathÚ
transformsÚantialiasedsÚaaÚ
edgecolorsÚecÚ
facecolorsÚfcÚ
linestylesÚdashesÚlsÚ
linewidthsÚlw)ÚantialiasedÚ	edgecolorÚ	facecolorÚ	linestyleÚ	linewidthc               @   s„  e Zd ZdZejd]ƒZejƒ Z	ej
d^ƒZdZd_dd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zejdd„ ƒZdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Z d/d0„ Z!d1d2„ Z"d3d4„ Z#d5d6„ Z$d7d8„ Z%d9d:„ Z&d;d<„ Z'd=d>„ Z(e)d?d@„ ƒZ*dAdB„ Z+dCdD„ Z,dEdF„ Z-dGdH„ Z.dIdJ„ Z/dKdL„ Z0dMdN„ Z1dOdP„ Z2dQdR„ Z3dSdT„ Z4dUdV„ Z5dWdX„ Z6dYdZ„ Z7d[d\„ Z8dS )`Ú
Collectiona  
    Base class for Collections.  Must be subclassed to be usable.

    All properties in a collection must be sequences or scalars;
    if scalars, they will be converted to sequences.  The
    property of the ith element of the collection is::

      prop[i % len(props)]

    Exceptions are *capstyle* and *joinstyle* properties, these can
    only be set globally for the whole collection.

    Keyword arguments and default values:

        * *edgecolors*: None
        * *facecolors*: None
        * *linewidths*: None
        * *capstyle*:   None
        * *joinstyle*:  None
        * *antialiaseds*: None
        * *offsets*: None
        * *transOffset*: transforms.IdentityTransform()
        * *offset_position*: 'screen' (default) or 'data'
        * *norm*: None (optional for
          :class:`matplotlib.cm.ScalarMappable`)
        * *cmap*: None (optional for
          :class:`matplotlib.cm.ScalarMappable`)
        * *hatch*: None
        * *zorder*: 1

    *offsets* and *transOffset* are used to translate the patch after
    rendering (default no offsets).  If offset_position is 'screen'
    (default) the offset is applied after the master transform has
    been applied, that is, the offsets are in screen coordinates.  If
    offset_position is 'data', the offset is applied before the master
    transform, i.e., the offsets are in data coordinates.

    If any of *edgecolors*, *facecolors*, *linewidths*, *antialiaseds*
    are None, they default to their :data:`matplotlib.rcParams` patch
    setting, in sequence form.

    The use of :class:`~matplotlib.cm.ScalarMappable` is optional.  If
    the :class:`~matplotlib.cm.ScalarMappable` matrix _A is not None
    (i.e., a call to set_array has been made), at draw time a call to
    scalar mappable will be made to set the face colors.
    r   é   é   FNÚsolidç      @Úscreenr   c             K   s`  t jj| ƒ tjj| |
|ƒ dg| _dg| _dg| _dg| _d| _	t
jtjd ƒ| _| j|ƒ | j|ƒ | j|ƒ | j|ƒ | j|ƒ | j|ƒ | j|ƒ | j|ƒ | j|ƒ | j|ƒ |rÈ| j|ƒ nd| _|rÞ| j|ƒ nd| _tjd	ƒ| _d| _ |dk	�rFtj!|t"ƒ}|j#d
k�r(|ddd…f }|	dk	�r@|| _|	| _$n|| _ d| _%| j&|ƒ d| _'dS )z=
        Create a Collection

        %(Collection)s
        Nr   Tzhatch.colorr   r   )NN)NN)r   r   )r   )(r   ÚArtistÚ__init__r   ÚScalarMappableÚ_us_linestylesÚ_linestylesÚ_us_lwÚ_linewidthsÚ
_is_filledÚmcolorsÚto_rgbaÚmplÚrcParamsÚ_hatch_colorÚset_facecolorÚset_edgecolorÚset_linewidthÚset_linestyleÚset_antialiasedÚset_pickradiusÚset_urlsÚ	set_hatchÚset_offset_positionÚ
set_zorderÚset_capstyleÚ	_capstyleÚset_joinstyleÚ
_joinstyleÚnpÚzerosÚ_offsetsÚ_uniform_offsetsÚ
asanyarrayÚfloatÚshapeÚ_transOffsetÚ_path_effectsÚupdateÚ_paths)Úselfr   r   r   r   ÚcapstyleÚ	joinstyler   ÚoffsetsÚtransOffsetÚnormÚcmapÚ
pickradiusÚhatchÚurlsÚoffset_positionÚzorderÚkwargs© rV   ú�/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/matplotlib-3.1.1-py3.6-linux-x86_64.egg/matplotlib/collections.pyr$   Z   sJ    












zCollection.__init__c             C   s   | j S )N)rH   )rI   rV   rV   rW   Ú	get_paths¥   s    zCollection.get_pathsc             C   s   t ‚d S )N)ÚNotImplementedError)rI   rV   rV   rW   Ú	set_paths¨   s    zCollection.set_pathsc             C   s   | j S )N)Ú_transforms)rI   rV   rV   rW   Úget_transforms«   s    zCollection.get_transformsc             C   s.   | j }t|tjƒ r*t|dƒr*|j| jƒ}|S )NÚ_as_mpl_transform)rE   Ú
isinstancer   Ú	TransformÚhasattrr]   Úaxes)rI   ÚtrV   rV   rW   Úget_offset_transform®   s
    
zCollection.get_offset_transformc                s¸   | j ƒ ‰ | jƒ }| j}| jƒ }ˆ js>‡ fdd„|D ƒ}ˆ jƒ ‰ |jsV|j|ƒ}|jƒ }t|tj	j
ƒrp|jtjƒ}t|ƒrªt|ƒrªtjˆ jƒ || jƒ ||jƒ ƒ}|j|ƒ}n
tjjƒ }|S )Nc                s   g | ]}ˆ j |ƒ‘qS rV   )Útransform_path_non_affine)Ú.0Úp)Ú	transformrV   rW   ú
<listcomp>¼   s    z*Collection.get_datalim.<locals>.<listcomp>)Úget_transformrc   r@   rX   Ú	is_affineÚ
get_affineÚtransform_non_affiner^   r>   ÚmaÚMaskedArrayÚfilledÚnanÚlenÚmpathÚget_path_collection_extentsÚfrozenr\   Úinverse_transformedr   ÚBboxÚnull)rI   Ú	transDatarM   rL   ÚpathsÚresultrV   )rg   rW   Úget_datalimµ   s&    

zCollection.get_datalimc             C   s   | j tjƒ ƒS )N)r{   r   ÚIdentityTransform)rI   ÚrendererrV   rV   rW   Úget_window_extentÏ   s    zCollection.get_window_extentc                s8  | j ƒ ‰ | jƒ }| j}| jƒ }| jƒ rÖg }xj| jƒ D ]^}|j}|d d …df |d d …df  }}| j|ƒ}| j|ƒ}|jt	j
tj||gƒ|jƒƒ q4W |jrÖ| j|d d …df ƒ}| j|d d …df ƒ}tj||gƒ}ˆ jsö‡ fdd„|D ƒ}ˆ jƒ ‰ |j�s|j|ƒ}|jƒ }t|tjjƒ�r,|jtjƒ}ˆ |||fS )Nr   r   c                s   g | ]}ˆ j |ƒ‘qS rV   )rd   )re   r   )rg   rV   rW   rh   ê   s   z.Collection._prepare_points.<locals>.<listcomp>)ri   rc   r@   rX   Ú
have_unitsÚverticesÚconvert_xunitsÚconvert_yunitsÚappendrr   ÚPathr>   Úcolumn_stackÚcodesÚsizerj   rk   rl   r^   rm   rn   ro   rp   )rI   rM   rL   ry   r   r€   ÚxsÚysrV   )rg   rW   Ú_prepare_pointsÔ   s4    "

"

zCollection._prepare_pointsc             C   sÚ  | j ƒ sd S |j| jj| jƒ ƒ | jƒ  | jƒ \}}}}|jƒ }| j|ƒ |j	| j
ƒ ƒ | jrž|j| jƒ y|j| jƒ W n" tk
rœ   tjddd� Y nX | jƒ d k	r¸|j| jƒ Ž  | jƒ rÚddlm} || jƒ |ƒ}| jƒ }| jƒ }	| jƒ }
d}t|ƒdk�rÒt|ƒdk�rÒt|	ƒdk�rÒt|
ƒdk�rÒt| jƒdk�rÒ| jd	gk�rÒt| jƒdk�rÒt| jƒdk�rÒ| jƒ d k�rÒt|ƒ�r˜t j!|d ƒ| }n|}|d j"|ƒ}|j#ƒ \}}|j$|k �rÒ|j%|k �rÒd}| j&�ræ|j'| j&ƒ | j(�rú|j)| j(ƒ |�r~|j*t+|
d ƒƒ |j,| jd ƒ |j-| jd Ž  |j.| jd ƒ |j/| jd ƒ |j0||d |j1ƒ t2j3|ƒ|t+|	d ƒƒ n<|j4||j1ƒ || jƒ ||| jƒ | jƒ | j| j| j| j| j5ƒ |j6ƒ  |j7| jjƒ d| _8d S )
Nz3.1zoYour backend does not support setting the hatch color; such backends will become unsupported in Matplotlib 3.3.)Úmessager   )ÚPathEffectRendererFr   T)NN)9Úget_visibleÚ
open_groupÚ	__class__Ú__name__Úget_gidÚupdate_scalarmappablerŠ   Únew_gcÚ_set_gc_clipÚset_snapÚget_snapÚ_hatchr7   Úset_hatch_colorr/   ÚAttributeErrorr   Úwarn_deprecatedÚget_sketch_paramsÚset_sketch_paramsÚget_path_effectsZmatplotlib.patheffectsrŒ   r\   Úget_facecolorÚget_edgecolorrq   r)   r'   Ú_antialiasedsÚ_urlsÚ	get_hatchr   ÚAffine2DÚget_extentsZget_canvas_width_heightÚwidthÚheightr=   r<   r;   r:   Zset_foregroundÚtupler2   Z
set_dashesr4   Úset_urlZdraw_markersrt   rr   r„   Zdraw_path_collectionÚ_offset_positionÚrestoreÚclose_groupÚstale)rI   r}   rg   rM   rL   ry   ÚgcrŒ   Útransr   r   Zdo_single_path_optimizationZcombined_transformÚextentsr¥   r¦   rV   rV   rW   Údrawù   sz    
 


zCollection.drawc             C   s
   || _ dS )zž
        Set the pick radius used for containment tests.

        Parameters
        ----------
        d : float
            Pick radius, in points.
        N)Ú_pickradius)rI   ZprrV   rV   rW   r5   O  s    	zCollection.set_pickradiusc             C   s   | j S )N)r±   )rI   rV   rV   rW   Úget_pickradiusZ  s    zCollection.get_pickradiusc             C   s¢   | j dk	r| j | |ƒS | jƒ s&di fS t| jtƒrF| jdk	rFt| jƒn| j}| jƒ \}}}}tj	|j
|j||jƒ || jƒ |||dk| jƒ ƒ
}t|ƒdkt|d�fS )z²
        Test whether the mouse event occurred in the collection.

        Returns ``bool, dict(ind=itemlist)``, where every item in itemlist
        contains the event.
        NFTr   )Úind)Ú	_containsr�   r^   Ú_pickerr   rC   r±   rŠ   r   Úpoint_in_path_collectionÚxÚyrt   r\   Úget_offset_positionrq   Údict)rI   Ú
mouseeventrP   rg   rM   rL   ry   r³   rV   rV   rW   Úcontains]  s    



zCollection.containsc             C   s   |dk	r|ndg| _ d| _dS )zP
        Parameters
        ----------
        urls : List[str] or None
        NT)r¡   r¬   )rI   rR   rV   rV   rW   r6   z  s    zCollection.set_urlsc             C   s   | j S )N)r¡   )rI   rV   rV   rW   Úget_urlsƒ  s    zCollection.get_urlsc             C   s   || _ d| _dS )a…  
        Set the hatching pattern

        *hatch* can be one of::

          /   - diagonal hatching
          \   - back diagonal
          |   - vertical
          -   - horizontal
          +   - crossed
          x   - crossed diagonal
          o   - small circle
          O   - large circle
          .   - dots
          *   - stars

        Letters can be combined, in which case all the specified
        hatchings are done.  If same letter repeats, it increases the
        density of hatching of that pattern.

        Hatching is supported in the PostScript, PDF, SVG and Agg
        backends only.

        Unlike other properties such as linewidth and colors, hatching
        can only be specified for the collection as a whole, not separately
        for each member.

        Parameters
        ----------
        hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
        TN)r—   r¬   )rI   rQ   rV   rV   rW   r7   †  s     zCollection.set_hatchc             C   s   | j S )z$Return the current hatching pattern.)r—   )rI   rV   rV   rW   r¢   ©  s    zCollection.get_hatchc             C   sH   t j|tƒ}|jdkr&|ddd…f }| jdkr8|| _n|| _d| _dS )zŠ
        Set the offsets for the collection.

        Parameters
        ----------
        offsets : float or sequence of floats
        r   NT)r   )r>   rB   rC   rD   rA   r@   r¬   )rI   rL   rV   rV   rW   Úset_offsets­  s    

zCollection.set_offsetsc             C   s   | j dkr| jS | j S dS )z&Return the offsets for the collection.N)rA   r@   )rI   rV   rV   rW   Úget_offsets¿  s    
zCollection.get_offsetsc             C   s"   t jddg|d� || _d| _dS )a½  
        Set how offsets are applied.  If *offset_position* is 'screen'
        (default) the offset is applied after the master transform has
        been applied, that is, the offsets are in screen coordinates.
        If offset_position is 'data', the offset is applied before the
        master transform, i.e., the offsets are in data coordinates.

        Parameters
        ----------
        offset_position : {'screen', 'data'}
        r"   Údata)rS   TN)r   Ú_check_in_listr©   r¬   )rI   rS   rV   rV   rW   r8   Ç  s    
zCollection.set_offset_positionc             C   s   | j S )a€  
        Returns how offsets are applied for the collection.  If
        *offset_position* is 'screen', the offset is applied after the
        master transform has been applied, that is, the offsets are in
        screen coordinates.  If offset_position is 'data', the offset
        is applied before the master transform, i.e., the offsets are
        in data coordinates.
        )r©   )rI   rV   rV   rW   r¹   Ø  s    	zCollection.get_offset_positionc             C   sX   |dkr$t jd }|dkr$t jd }tjtj|ƒƒ| _| j| j| jƒ\| _| _	d| _
dS )zÿ
        Set the linewidth(s) for the collection.  *lw* can be a scalar
        or a sequence; if it is a sequence the patches will cycle
        through the sequence

        Parameters
        ----------
        lw : float or sequence of floats
        Nzpatch.linewidthzlines.linewidthT)r-   r.   r>   Ú
atleast_1dÚasarrayr(   Ú_bcast_lwlsr&   r)   r'   r¬   )rI   r   rV   rV   rW   r2   ã  s    


zCollection.set_linewidthc             C   s¤   y^t |tƒr(tjj||ƒ}tj|ƒg}n4ytj|ƒg}W n" tk
rZ   dd„ |D ƒ}Y nX W n" tk
r€   tdj|ƒƒ‚Y nX || _	| j
| j| j	ƒ\| _| _dS )a%  
        Set the linestyle(s) for the collection.

        ===========================   =================
        linestyle                     description
        ===========================   =================
        ``'-'`` or ``'solid'``        solid line
        ``'--'`` or  ``'dashed'``     dashed line
        ``'-.'`` or  ``'dashdot'``    dash-dotted line
        ``':'`` or ``'dotted'``       dotted line
        ===========================   =================

        Alternatively a dash tuple of the following form can be provided::

            (offset, onoffseq),

        where ``onoffseq`` is an even length tuple of on and off ink in points.

        Parameters
        ----------
        ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
            The line style.
        c             S   s   g | ]}t j|ƒ‘qS rV   )ÚmlinesÚ_get_dash_pattern)re   r·   rV   rV   rW   rh     s    z,Collection.set_linestyle.<locals>.<listcomp>z)Do not know how to convert {!r} to dashesN)r^   Ústrr   Ú	ls_mapperÚgetrÅ   rÆ   Ú
ValueErrorÚformatr&   rÄ   r(   r)   r'   )rI   r   r   rV   rV   rW   r3   ù  s    
zCollection.set_linestylec             C   s    |dkr|| _ ntd| ƒ‚dS )zº
        Set the capstyle for the collection (for all its elements).

        Parameters
        ----------
        cs : {'butt', 'round', 'projecting'}
            The capstyle
        ÚbuttÚroundÚ
projectingz!Unrecognized cap style.  Found %sN)rÌ   rÍ   rÎ   )r;   rÊ   )rI   ÚcsrV   rV   rW   r:   &  s    	zCollection.set_capstylec             C   s   | j S )N)r;   )rI   rV   rV   rW   Úget_capstyle4  s    zCollection.get_capstylec             C   s    |dkr|| _ ntd| ƒ‚dS )z¸
        Set the joinstyle for the collection (for all its elements).

        Parameters
        ----------
        js : {'miter', 'round', 'bevel'}
            The joinstyle
        ÚmiterrÍ   Úbevelz"Unrecognized join style.  Found %sN)rÑ   rÍ   rÒ   )r=   rÊ   )rI   ZjsrV   rV   rW   r<   7  s    	zCollection.set_joinstylec             C   s   | j S )N)r=   )rI   rV   rV   rW   Úget_joinstyleE  s    zCollection.get_joinstylec             C   sz   t jd r| |fS t|ƒt| ƒkr^t|ƒ}t| ƒ}tj||ƒ}t|ƒ||  }t| ƒ||  } dd„ t|| ƒD ƒ}| |fS )aÉ  
        Internal helper function to broadcast + scale ls/lw

        In the collection drawing code, the linewidth and linestyle are cycled
        through as circular buffers (via ``v[i % len(v)]``).  Thus, if we are
        going to scale the dash pattern at set time (not draw time) we need to
        do the broadcasting now and expand both lists to be the same length.

        Parameters
        ----------
        linewidths : list
            line widths of collection
        dashes : list
            dash specification (offset, (dash pattern tuple))

        Returns
        -------
        linewidths, dashes : list
             Will be the same length, dashes are scaled by paired linewidth
        z_internal.classic_modec             S   s"   g | ]\\}}}t j|||ƒ‘qS rV   )rÅ   Z_scale_dashes)re   ÚoÚdr   rV   rV   rW   rh   i  s   z*Collection._bcast_lwls.<locals>.<listcomp>)r-   r.   rq   ÚmathÚgcdÚlistÚzip)r   r   Zl_dashesZl_lwr×   rV   rV   rW   rÄ   H  s    
zCollection._bcast_lwlsc             C   s0   |dkrt jd }tjtj|tƒƒ| _d| _dS )z‰
        Set the antialiasing state for rendering.

        Parameters
        ----------
        aa : bool or sequence of bools
        Nzpatch.antialiasedT)r-   r.   r>   rÂ   rÃ   Úboolr    r¬   )rI   r   rV   rV   rW   r4   n  s    
zCollection.set_antialiasedc             C   s   | j |ƒ | j|ƒ dS )a*  
        Set both the edgecolor and the facecolor.

        Parameters
        ----------
        c : color or sequence of rgba tuples

        See Also
        --------
        Collection.set_facecolor, Collection.set_edgecolor
            For setting the edge or face color individually.
        N)r0   r1   )rI   ÚcrV   rV   rW   Ú	set_color{  s    
zCollection.set_colorc             C   s^   |d krt jd }d| _y|jƒ dkr,d| _W n tk
rB   Y nX tj|| jƒ| _d| _	d S )Nzpatch.facecolorTÚnoneF)
r-   r.   r*   Úlowerr™   r+   Úto_rgba_arrayÚ_alphaÚ_facecolorsr¬   )rI   rÛ   rV   rV   rW   Ú_set_facecolor‹  s    

zCollection._set_facecolorc             C   s   || _ | j|ƒ dS )au  
        Set the facecolor(s) of the collection.  *c* can be a
        matplotlib color spec (all patches have same color), or a
        sequence of specs; if it is a sequence the patches will
        cycle through the sequence.

        If *c* is 'none', the patch will not be filled.

        Parameters
        ----------
        c : color or sequence of colors
        N)Ú_original_facecolorrâ   )rI   rÛ   rV   rV   rW   r0   ˜  s    zCollection.set_facecolorc             C   s   | j S )N)rá   )rI   rV   rV   rW   rž   ¨  s    zCollection.get_facecolorc             C   s    t j| jdƒr| jƒ S | jS d S )NÚface)r   Ú
_str_equalÚ_edgecolorsrž   )rI   rV   rV   rW   rŸ   «  s    zCollection.get_edgecolorc             C   sÒ   d}|d kr8t jd s$| j s$| jr0t jd }nd}d}d| _y|jƒ dkrRd| _W n tk
rh   Y nX y|jƒ dkr‚d| _d S W n tk
r˜   Y nX tj	|| j
ƒ| _|rÈt| jƒrÈt| jd ƒ| _d| _d S )NTzpatch.force_edgecolorzpatch.edgecolorrÝ   Frä   r   )r-   r.   r*   Ú_edge_defaultÚ_is_strokedrÞ   r™   ræ   r+   rß   rà   rq   r§   r/   r¬   )rI   rÛ   r˜   rV   rV   rW   Ú_set_edgecolor±  s.    

zCollection._set_edgecolorc             C   s   || _ | j|ƒ dS )a  
        Set the edgecolor(s) of the collection.

        Parameters
        ----------
        c : color or sequence of colors or 'face'
            The collection edgecolor(s).  If a sequence, the patches cycle
            through it.  If 'face', match the facecolor.
        N)Ú_original_edgecolorré   )rI   rÛ   rV   rV   rW   r1   Í  s    
zCollection.set_edgecolorc             C   sf   |dk	r2yt |ƒ W n tk
r0   tdƒ‚Y nX d| jd< tjj| |ƒ | j| jƒ | j| j	ƒ dS )z†
        Set the alpha transparencies of the collection.

        Parameters
        ----------
        alpha : float or None
        Nzalpha must be a float or NoneTÚarray)
rC   Ú	TypeErrorZupdate_dictr   r#   Ú	set_alpharâ   rã   ré   rê   )rI   ÚalpharV   rV   rW   rí   Ú  s    
zCollection.set_alphac             C   s   | j S )N)r)   )rI   rV   rV   rW   Úget_linewidthì  s    zCollection.get_linewidthc             C   s   | j S )N)r'   )rI   rV   rV   rW   Úget_linestyleï  s    zCollection.get_linestylec             C   sl   | j dkrdS | j jdkr"tdƒ‚| jdƒs0dS | jrJ| j| j | jƒ| _n| jrb| j| j | jƒ| _	d| _
dS )z@Update colors from the scalar mappable array, if it is not None.Nr   z&Collections can only map rank 1 arraysrë   T)Ú_AÚndimrÊ   Zcheck_updater*   r,   rà   rá   rè   ræ   r¬   )rI   rV   rV   rW   r’   ò  s    

z Collection.update_scalarmappablec             C   s   | j S )zreturn whether fill is set)r*   )rI   rV   rV   rW   Úget_fill   s    zCollection.get_fillc             C   s€   t jj| |ƒ |j| _|j| _|j| _|j| _|j| _|j| _|j	| _	|j
| _
|j| _|j| _|j| _|j| _|j| _d| _dS )z"copy properties from other to selfTN)r   r#   Úupdate_fromr    rê   ræ   rã   rá   r)   r'   r&   r±   r—   rñ   rN   rO   r¬   )rI   ÚotherrV   rV   rW   rô     s    zCollection.update_from)r   r   )r   r   r   )NNNr    NNNNNNNr!   NNr"   r   )9r�   Ú
__module__Ú__qualname__Ú__doc__r>   r?   r@   r   r|   rE   Úemptyr[   rç   r$   rX   rZ   r\   rc   r{   r~   rŠ   r   Úallow_rasterizationr°   r5   r²   r¼   r6   r½   r7   r¢   r¾   r¿   r8   r¹   r2   r3   r:   rÐ   r<   rÓ   ÚstaticmethodrÄ   r4   rÜ   râ   r0   rž   rŸ   ré   r1   rí   rï   rð   r’   ró   rô   rV   rV   rV   rW   r      sz   5

               
;%V	#-&r   a´      Valid Collection keyword arguments:

        * *edgecolors*: None
        * *facecolors*: None
        * *linewidths*: None
        * *antialiaseds*: None
        * *offsets*: None
        * *transOffset*: transforms.IdentityTransform()
        * *norm*: None (optional for
          :class:`matplotlib.cm.ScalarMappable`)
        * *cmap*: None (optional for
          :class:`matplotlib.cm.ScalarMappable`)

    *offsets* and *transOffset* are used to translate the patch after
    rendering (default no offsets)

    If any of *edgecolors*, *facecolors*, *linewidths*, *antialiaseds*
    are None, they default to their :data:`matplotlib.rcParams` patch
    setting, in sequence form.
)r   c               @   s4   e Zd ZdZdZdd„ Zddd„Zejdd	„ ƒZ	d
S )Ú_CollectionWithSizeszA
    Base class for collections that have an array of sizes.
    g      ð?c             C   s   | j S )zÞ
        Returns the sizes of the elements in the collection.  The
        value represents the 'area' of the element.

        Returns
        -------
        sizes : array
            The 'area' of each element.
        )Ú_sizes)rI   rV   rV   rW   Ú	get_sizes;  s    
z_CollectionWithSizes.get_sizesç      R@c             C   s¦   |dkr"t jg ƒ| _t jd	ƒ| _nzt j|ƒ| _t jt| jƒddfƒ| _t j| jƒ| d | j	 }|| jdd…ddf< || jdd…ddf< d| jdd…ddf< d| _
dS )
aF  
        Set the sizes of each member of the collection.

        Parameters
        ----------
        sizes : ndarray or None
            The size to set for each element of the collection.  The
            value is the 'area' of the element.
        dpi : float
            The dpi of the canvas. Defaults to 72.0.
        Nr   r   g      R@r   g      ð?r   T)r   r   r   )r>   rë   rý   rù   r[   rÃ   r?   rq   ÚsqrtÚ_factorr¬   )rI   ÚsizesÚdpiÚscalerV   rV   rW   Ú	set_sizesG  s    z_CollectionWithSizes.set_sizesc             C   s"   | j | j| jjƒ tj| |ƒ d S )N)r  rý   Úfigurer  r   r°   )rI   r}   rV   rV   rW   r°   _  s    z_CollectionWithSizes.drawN)rÿ   )
r�   rö   r÷   rø   r  rþ   r  r   rú   r°   rV   rV   rV   rW   rü   5  s
   
rü   c               @   sF   e Zd ZdZejddd„ƒZdd„ Zdd„ Zd	d
ddd„ fdd„Z	dS )ÚPathCollectionzŽ
    This is the most basic :class:`Collection` subclass.
    A :class:`PathCollection` is e.g. created by a :meth:`~.Axes.scatter` plot.
    Nc             K   s,   t j| f|Ž | j|ƒ | j|ƒ d| _dS )zs
        *paths* is a sequence of :class:`matplotlib.path.Path`
        instances.

        %(Collection)s
        TN)r   r$   rZ   r  r¬   )rI   ry   r  rU   rV   rV   rW   r$   j  s    	

zPathCollection.__init__c             C   s   || _ d| _d S )NT)rH   r¬   )rI   ry   rV   rV   rW   rZ   x  s    zPathCollection.set_pathsc             C   s   | j S )N)rH   )rI   rV   rV   rW   rX   |  s    zPathCollection.get_pathsr   Úautoc             C   s   | S )NrV   )r·   rV   rV   rW   Ú<lambda>€  s    zPathCollection.<lambda>c             K   sâ  g }g }| j ƒ dk	}|dkr.tjjddd�}nt|tƒrDtjj|ƒ}|jƒ  |dkrŒ|sjtj	dƒ ||fS t
j| j ƒ ƒ}	|jdtjd ƒ}
n4|d	kr°t
j| jƒ ƒ}	|jd
dƒ}ntd|› d�ƒ‚|j||	ƒjƒ ||	ƒjƒ ƒ |dkrød}t|	ƒ|krød}|dk�r|	}||ƒ}nð|dk�r$| j ƒ }n|d	k�r6| jƒ }t|tjjƒ�rL|}nHt
j|ƒ�rftjj|ƒ}n.t|ƒ}tjj||d ddddddddgd�}|j||ƒjƒ ||ƒjƒ ƒ}|||ƒjƒ k|||ƒjƒ k@ }|| }t
j|jƒ |jƒ dƒ}t
j|||ƒ|ƒ}t| jƒ d | jƒ d�}|j|ƒ x¶t ||ƒD ]¨\}}|dk�rR| j!| j"|ƒƒ}n&|d	k�rxt
j#|ƒ}
t
j$|
dƒ�rx�q.t%j&dgdgfd||
| j'ƒ d dœ|—Ž}|j(|ƒ t)|dƒ�rÂ|j*|ƒ ||ƒ}|j(|ƒ �q.W ||fS ) aÉ
  
        Creates legend handles and labels for a PathCollection. This is useful
        for obtaining a legend for a :meth:`~.Axes.scatter` plot. E.g.::

            scatter = plt.scatter([1,2,3], [4,5,6], c=[7,2,3])
            plt.legend(*scatter.legend_elements())

        Also see the :ref:`automatedlegendcreation` example.

        Parameters
        ----------
        prop : string, optional, default *"colors"*
            Can be *"colors"* or *"sizes"*. In case of *"colors"*, the legend
            handles will show the different colors of the collection. In case
            of "sizes", the legend will show the different sizes.
        num : int, None, "auto" (default), array-like, or `~.ticker.Locator`,
            optional
            Target number of elements to create.
            If None, use all unique elements of the mappable array. If an
            integer, target to use *num* elements in the normed range.
            If *"auto"*, try to determine which option better suits the nature
            of the data.
            The number of created elements may slightly deviate from *num* due
            to a `~.ticker.Locator` being used to find useful locations.
            If a list or array, use exactly those elements for the legend.
            Finally, a `~.ticker.Locator` can be provided.
        fmt : string, `~matplotlib.ticker.Formatter`, or None (default)
            The format or formatter to use for the labels. If a string must be
            a valid input for a `~.StrMethodFormatter`. If None (the default),
            use a `~.ScalarFormatter`.
        func : function, default *lambda x: x*
            Function to calculate the labels. Often the size (or color)
            argument to :meth:`~.Axes.scatter` will have been pre-processed
            by the user using a function *s = f(x)* to make the markers
            visible; e.g. *size = np.log10(x)*. Providing the inverse of this
            function here allows that pre-processing to be inverted, so that
            the legend labels have the correct values;
            e.g. *func = np.exp(x, 10)*.
        kwargs : further parameters
            Allowed kwargs are *color* and *size*. E.g. it may be useful to
            set the color of the markers if *prop="sizes"* is used; similarly
            to set the size of the markers if *prop="colors"* is used.
            Any further parameters are passed onto the `.Line2D` instance.
            This may be useful to e.g. specify a different *markeredgecolor* or
            *alpha* for the legend handles.

        Returns
        -------
        tuple (handles, labels)
            with *handles* being a list of `.Line2D`  objects
            and *labels* a matching list of strings.
        NFT)Ú	useOffsetÚuseMathTextr   zfCollection without array used. Make sure to specify the values to be colormapped via the `c` argument.r‡   zlines.markersizer  ÚcolorÚkz?Valid values for `prop` are 'colors' or 'sizes'. You supplied 'z
' instead.r  é	   r   r   g      @r   é   é   é   é
   )ÚnbinsZmin_n_ticksÚstepsé   r   )Úmarkeredgewidthrî   g        Ú )r   r  ÚmsÚmarkerÚset_locs)+Ú	get_arrayr-   ÚtickerÚScalarFormatterr^   rÇ   ZStrMethodFormatterÚcreate_dummy_axisÚwarningsÚwarnr>   ÚuniqueÚpopr.   rþ   rÊ   Z
set_boundsÚminÚmaxrq   ÚLocatorÚiterableÚFixedLocatorÚintÚMaxNLocatorÚtick_valuesÚlinspaceÚinterprº   Úget_linewidthsÚ	get_alpharG   rÙ   rO   rN   r   ÚiscloserÅ   ÚLine2DrX   rƒ   r`   r  )rI   ÚpropÚnumÚfmtÚfuncrU   ZhandlesÚlabelsZhasarrayÚur‡   r  ÚvaluesZlabel_valuesÚarrÚlocÚcondZxarrÚkwÚvalÚlabÚhÚlrV   rV   rW   Úlegend_elements  sz    6












zPathCollection.legend_elements)N)
r�   rö   r÷   rø   r	   Údedent_interpdr$   rZ   rX   r@  rV   rV   rV   rW   r  e  s   r  c               @   s2   e Zd Zejd	dd„ƒZd
dd„ZeZdd„ ZdS )ÚPolyCollectionNTc             K   s.   t j| f|Ž | j|ƒ | j||ƒ d| _dS )aû  
        *verts* is a sequence of ( *verts0*, *verts1*, ...) where
        *verts_i* is a sequence of *xy* tuples of vertices, or an
        equivalent :mod:`numpy` array of shape (*nv*, 2).

        *sizes* is *None* (default) or a sequence of floats that
        scale the corresponding *verts_i*.  The scaling is applied
        before the Artist master transform; if the latter is an identity
        transform, then the overall scaling is such that if
        *verts_i* specify a unit square, then *sizes_i* is the area
        of that square in points^2.
        If len(*sizes*) < *nv*, the additional values will be
        taken cyclically from the array.

        *closed*, when *True*, will explicitly close the polygon.

        %(Collection)s
        TN)r   r$   r  Ú	set_vertsr¬   )rI   Úvertsr  ÚclosedrU   rV   rV   rW   r$      s    
zPolyCollection.__init__c             C   s  t |tjjƒr |jtƒjtjƒ}|ròg | _xÖ|D ]¼}t	|ƒrÚt |tjjƒrdtjj
||dd… gƒ}n tj|ƒ}tj
||dd… gƒ}tj|jd tjjd�}tjj|dd…< tjj|d< tjj|d< | jjtj||ƒƒ q0| jjtj|ƒƒ q0W ndd„ |D ƒ| _d| _dS )	z8This allows one to delay initialization of the vertices.r   r   )ÚdtypeNc             S   s   g | ]}t j|ƒ‘qS rV   )rr   r„   )re   ÚxyrV   rV   rW   rh   /  s    z,PolyCollection.set_verts.<locals>.<listcomp>Téÿÿÿÿ)r^   r>   rm   rn   ÚastyperC   ro   rp   rH   rq   ÚconcatenaterÃ   rù   rD   rr   r„   Ú	code_typeÚLINETOÚMOVETOÚ	CLOSEPOLYrƒ   r¬   )rI   rD  rE  rG  r†   rV   rV   rW   rC    s$    

zPolyCollection.set_vertsc             C   sp   t |ƒt |ƒkrtdƒ‚g | _xFt||ƒD ]8\}}t |ƒrP| jjtj||ƒƒ q*| jjtj|ƒƒ q*W d| _dS )z7This allows one to initialize vertices with path codes.zB'codes' must be a 1D list or array with the same length of 'verts'TN)rq   rÊ   rH   rÙ   rƒ   rr   r„   r¬   )rI   rD  r†   rG  ZcdsrV   rV   rW   Úset_verts_and_codes4  s    z"PolyCollection.set_verts_and_codes)NT)T)	r�   rö   r÷   r	   rA  r$   rC  rZ   rO  rV   rV   rV   rW   rB  ÿ  s
   
rB  c               @   s*   e Zd ZdZejdd„ ƒZedd„ ƒZdS )ÚBrokenBarHCollectionz]
    A collection of horizontal bars spanning *yrange* with a sequence of
    *xranges*.
    c                s8   |\‰}ˆ| ‰ ‡ ‡fdd„|D ƒ}t j| |f|Ž dS )z�
        *xranges*
            sequence of (*xmin*, *xwidth*)

        *yrange*
            *ymin*, *ywidth*

        %(Collection)s
        c                s:   g | ]2\}}|ˆf|ˆ f|| ˆ f|| ˆf|ˆfg‘qS rV   rV   )re   ÚxminZxwidth)ÚymaxÚyminrV   rW   rh   T  s   z1BrokenBarHCollection.__init__.<locals>.<listcomp>N)rB  r$   )rI   ÚxrangesÚyrangerU   ZywidthrD  rV   )rR  rS  rW   r$   G  s
    zBrokenBarHCollection.__init__c       
      K   sj   g }xJt j|ƒD ]<\}}| ||… }t|ƒs.q|j|d |d |d  fƒ qW t|||| gf|Ž}	|	S )a(  
        Create a BrokenBarHCollection to plot horizontal bars from
        over the regions in *x* where *where* is True.  The bars range
        on the y-axis from *ymin* to *ymax*

        A :class:`BrokenBarHCollection` is returned.  *kwargs* are
        passed on to the collection.
        r   r   rH  )r   Úcontiguous_regionsrq   rƒ   rP  )
r·   rS  rR  ÚwhererU   rT  Úind0Úind1ZxsliceZ
collectionrV   rV   rW   Ú
span_where[  s    
"zBrokenBarHCollection.span_whereN)	r�   rö   r÷   rø   r	   rA  r$   rû   rZ  rV   rV   rV   rW   rP  B  s   rP  c               @   sP   e Zd ZdZejjZej	d Z
ejddd„ƒZdd„ Zd	d
„ Zejdd„ ƒZdS )ÚRegularPolyCollectionz6Draw a collection of regular polygons with *numsides*.r   r   r   c             K   sD   t j| f|Ž | j|ƒ || _| j|ƒg| _|| _| jtj	ƒ ƒ dS )aX  
        *numsides*
            the number of sides of the polygon

        *rotation*
            the rotation of the polygon in radians

        *sizes*
            gives the area of the circle circumscribing the
            regular polygon in points^2

        %(Collection)s

        Example: see :doc:`/gallery/event_handling/lasso_demo` for a
        complete example::

            offsets = np.random.rand(20,2)
            facecolors = [cm.jet(x) for x in np.random.rand(20)]
            black = (0,0,0,1)

            collection = RegularPolyCollection(
                numsides=5, # a pentagon
                rotation=0, sizes=(50,),
                facecolors=facecolors,
                edgecolors=(black,),
                linewidths=(1,),
                offsets=offsets,
                transOffset=ax.transData,
                )
        N)
r   r$   r  Ú	_numsidesÚ_path_generatorrH   Ú	_rotationÚset_transformr   r|   )rI   ÚnumsidesZrotationr  rU   rV   rV   rW   r$   w  s    $
zRegularPolyCollection.__init__c             C   s   | j S )N)r\  )rI   rV   rV   rW   Úget_numsides¢  s    z"RegularPolyCollection.get_numsidesc             C   s   | j S )N)r^  )rI   rV   rV   rW   Úget_rotation¥  s    z"RegularPolyCollection.get_rotationc                s8   ˆ j ˆ jˆ jjƒ ‡ fdd„ˆ jD ƒˆ _tjˆ |ƒ d S )Nc                s$   g | ]}t j|ƒjˆ j ƒjƒ ‘qS rV   )r   r£   Úrotater^  Ú
get_matrix)re   r·   )rI   rV   rW   rh   ¬  s   z.RegularPolyCollection.draw.<locals>.<listcomp>)r  rý   r  r  r[   r   r°   )rI   r}   rV   )rI   rW   r°   ¨  s    
zRegularPolyCollection.drawNrH  g      à¿©r   )r   re  )r�   rö   r÷   rø   rr   r„   Úunit_regular_polygonr]  r>   Úpir  r	   rA  r$   ra  rb  r   rú   r°   rV   rV   rV   rW   r[  q  s   
 'r[  c               @   s   e Zd ZdZejjZdS )ÚStarPolygonCollectionz:Draw a collection of regular stars with *numsides* points.N)r�   rö   r÷   rø   rr   r„   Úunit_regular_starr]  rV   rV   rV   rW   rh  ²  s   rh  c               @   s   e Zd ZdZejjZdS )ÚAsteriskPolygonCollectionz>Draw a collection of regular asterisks with *numsides* points.N)r�   rö   r÷   rø   rr   r„   Úunit_regular_asteriskr]  rV   rV   rV   rW   rj  ·  s   rj  c               @   sR   e Zd ZdZdZddd	„Zd
d„ ZeZeZdd„ Z	dd„ Z
dd„ Zdd„ ZeZdS )ÚLineCollectiona  
    All parameters must be sequences or scalars; if scalars, they will
    be converted to sequences.  The property of the ith line
    segment is::

       prop[i % len(props)]

    i.e., the properties cycle if the ``len`` of props is less than the
    number of segments.
    TNr    r  r   rÝ   c             K   s|   |dkrt jd }|dkr&t jd f}|dkr:t jd f}tj|ƒ}tj| f|||||||||	|
|dœ|—Ž | j|ƒ dS )aé	  
        Parameters
        ----------
        segments
            A sequence of (*line0*, *line1*, *line2*), where::

                linen = (x0, y0), (x1, y1), ... (xm, ym)

            or the equivalent numpy array with two columns. Each line
            can be a different length.

        colors : sequence, optional
            A sequence of RGBA tuples (e.g., arbitrary color
            strings, etc, not allowed).

        antialiaseds : sequence, optional
            A sequence of ones or zeros.

        linestyles : string, tuple, optional
            Either one of [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ], or
            a dash tuple. The dash tuple is::

                (offset, onoffseq)

            where ``onoffseq`` is an even length tuple of on and off ink
            in points.

        norm : Normalize, optional
            `~.colors.Normalize` instance.

        cmap : string or Colormap, optional
            Colormap name or `~.colors.Colormap` instance.

        pickradius : float, optional
            The tolerance in points for mouse clicks picking a line.
            Default is 5 pt.

        zorder : int, optional
           zorder of the LineCollection. Default is 2.

        facecolors : optional
           The facecolors of the LineCollection. Default is 'none'.
           Setting to a value other than 'none' will lead to a filled
           polygon being drawn between points on each line.

        Notes
        -----
        If *linewidths*, *colors*, or *antialiaseds* is None, they
        default to their rcParams setting, in sequence form.

        If *offsets* and *transOffset* are not None, then
        *offsets* are transformed by *transOffset* and applied after
        the segments have been transformed to display coordinates.

        If *offsets* is not None but *transOffset* is None, then the
        *offsets* are added to the segments before any transformation.
        In this case, a single offset can be specified as::

            offsets=(xo,yo)

        and this value will be added cumulatively to each successive
        segment, so as to produce a set of successively offset curves.

        The use of :class:`~matplotlib.cm.ScalarMappable` is optional.
        If the :class:`~matplotlib.cm.ScalarMappable` array
        :attr:`~matplotlib.cm.ScalarMappable._A` is not None (i.e., a call to
        :meth:`~matplotlib.cm.ScalarMappable.set_array` has been made), at
        draw time a call to scalar mappable will be made to set the colors.
        Nzlines.colorzlines.linewidthzlines.antialiased)r   r   r   r   r   rL   rM   rN   rO   rP   rT   )r-   r.   r+   rß   r   r$   Úset_segments)rI   Úsegmentsr   r   r   r   rL   rM   rN   rO   rP   rT   r   rU   rV   rV   rW   r$   Ê  s,    S

zLineCollection.__init__c             C   sp   |d krd S g }x0|D ](}t |tjjƒs4tj|tƒ}|j|ƒ qW | jd k	rV| j|ƒ}dd„ |D ƒ| _	d| _
d S )Nc             S   s   g | ]}t j|ƒ‘qS rV   )rr   r„   )re   Z_segrV   rV   rW   rh   D  s    z/LineCollection.set_segments.<locals>.<listcomp>T)r^   r>   rm   rn   rÃ   rC   rƒ   rA   Ú_add_offsetsrH   r¬   )rI   rn  Z	_segmentsÚsegrV   rV   rW   rm  7  s    


zLineCollection.set_segmentsc             C   s>   g }x4| j D ]*}dd„ |jƒ D ƒ}tj|ƒ}|j|ƒ qW |S )z¯
        Returns
        -------
        segments : list
            List of segments in the LineCollection. Each list item contains an
            array of vertices.
        c             S   s   g | ]\}}|‘qS rV   rV   )re   ZvertexÚ_rV   rV   rW   rh   U  s    z/LineCollection.get_segments.<locals>.<listcomp>)rH   Úiter_segmentsr>   rÃ   rƒ   )rI   rn  r   r€   rV   rV   rW   Úget_segmentsJ  s    
zLineCollection.get_segmentsc             C   s‚   | j }t|ƒ}|jd }|dkrHx\t|ƒD ]}|| ||  ||< q*W n6x4t|ƒD ](}|| }|| |||d …  ||< qRW |S )Nr   r   )rA   rq   rD   Úrange)rI   ZsegsrL   ZNsegsZNoffsÚiÚiorV   rV   rW   ro  [  s    
 zLineCollection._add_offsetsc             C   s   | j |ƒ d| _dS )a@  
        Set the color(s) of the LineCollection.

        Parameters
        ----------
        c : color or list of colors
            Matplotlib color argument (all patches have same color), or a
            sequence or rgba tuples; if it is a sequence the patches will
            cycle through the sequence.
        TN)r1   r¬   )rI   rÛ   rV   rV   rW   rÜ   h  s    
zLineCollection.set_colorc             C   s   | j S )N)ræ   )rI   rV   rV   rW   Ú	get_colorv  s    zLineCollection.get_color)NNNr    NNNNr  r   rÝ   )r�   rö   r÷   rø   rç   r$   rm  rC  rZ   rs  ro  rÜ   rw  Ú
get_colorsrV   rV   rV   rW   rl  ¼  s*   
          
brl  c                   s¤   e Zd ZdZdZd%dd„Zd	d
„ Zdd„ Zdd„ Ze Z	Z
dd„ Zdd„ Zdd„ Zd&dd„Zdd„ Zdd„ Zdd„ Zdd„ Z‡ fdd „Z‡ fd!d"„Zd#d$„ Z‡  ZS )'ÚEventCollectiona	  
    A collection of discrete events.

    The events are given by a 1-dimensional array, usually the position of
    something along an axis, such as time or length.  They do not have an
    amplitude and are displayed as vertical or horizontal parallel bars.
    TNr   r   r    c	                s   ||d  ||d  f‰ |dks,t |ƒdkr2g }
n t|dƒrP|jdkrPtdƒ‚n‚|dksp|jƒ dksp|jƒ dkr’|jƒ  ‡ fd	d
„|D ƒ}
d| _n@|jƒ dkrÀ|jƒ  ‡ fdd
„|D ƒ}
d| _ntjddg|d� t	j
| |
f||||dœ|	—Ž || _|| _dS )a   
        Parameters
        ----------
        positions : 1D array-like object
            Each value is an event.

        orientation : {None, 'horizontal', 'vertical'}, optional
            The orientation of the **collection** (the event bars are along
            the orthogonal direction). Defaults to 'horizontal' if not
            specified or None.

        lineoffset : scalar, optional, default: 0
            The offset of the center of the markers from the origin, in the
            direction orthogonal to *orientation*.

        linelength : scalar, optional, default: 1
            The total height of the marker (i.e. the marker stretches from
            ``lineoffset - linelength/2`` to ``lineoffset + linelength/2``).

        linewidth : scalar or None, optional, default: None
            If it is None, defaults to its rcParams setting, in sequence form.

        color : color, sequence of colors or None, optional, default: None
            If it is None, defaults to its rcParams setting, in sequence form.

        linestyle : str or tuple, optional, default: 'solid'
            Valid strings are ['solid', 'dashed', 'dashdot', 'dotted',
            '-', '--', '-.', ':']. Dash tuples should be of the form::

                (offset, onoffseq),

            where *onoffseq* is an even length tuple of on and off ink
            in points.

        antialiased : {None, 1, 2}, optional
            If it is None, defaults to its rcParams setting, in sequence form.

        **kwargs : optional
            Other keyword arguments are line collection properties.  See
            :class:`~matplotlib.collections.LineCollection` for a list of
            the valid properties.

        Examples
        --------

        .. plot:: gallery/lines_bars_and_markers/eventcollection_demo.py
        g       @Nr   rò   r   z:positions cannot be an array with more than one dimension.rÝ   Ú
horizontalc                s   g | ]‰ ‡ fd d„ˆD ƒ‘qS )c                s   g | ]}ˆ |f‘qS rV   rV   )re   Úcoord2)Úcoord1rV   rW   rh   Ì  s    z7EventCollection.__init__.<locals>.<listcomp>.<listcomp>rV   )re   )Úsegment)r|  rW   rh   Ì  s   z,EventCollection.__init__.<locals>.<listcomp>TÚverticalc                s   g | ]‰ ‡ fd d„ˆD ƒ‘qS )c                s   g | ]}|ˆ f‘qS rV   rV   )re   r{  )r|  rV   rW   rh   Ñ  s    z7EventCollection.__init__.<locals>.<listcomp>.<listcomp>rV   )re   )r}  )r|  rW   rh   Ñ  s   F)Úorientation)r   r   r   r   )rq   r`   rò   rÊ   rÞ   ÚsortÚ_is_horizontalr   rÁ   rl  r$   Ú_linelengthÚ_lineoffset)rI   Ú	positionsr  Ú
lineoffsetÚ
linelengthr   r  r   r   rU   rn  rV   )r}  rW   r$   ‡  s8    ;




zEventCollection.__init__c                s.   | j ƒ }| jƒ rdnd‰ ‡ fdd„| j ƒ D ƒS )zW
        return an array containing the floating-point values of the positions
        r   r   c                s   g | ]}|d ˆ f ‘qS )r   rV   )re   r}  )ÚposrV   rW   rh   é  s    z1EventCollection.get_positions.<locals>.<listcomp>)rs  Úis_horizontal)rI   rn  rV   )r‡  rW   Úget_positionsã  s    zEventCollection.get_positionsc                s¢   |dkst |dƒr,t|ƒdkr,| jg ƒ dS | jƒ }| jƒ }||d  ||d  f‰ tj|ƒ}|jƒ  | jƒ r‚‡ fdd„|D ƒ}n‡ fdd„|D ƒ}| j|ƒ dS )zH
        set the positions of the events to the specified value
        Nrq   r   g       @c                s   g | ]‰ ‡ fd d„ˆD ƒ‘qS )c                s   g | ]}ˆ |f‘qS rV   rV   )re   r{  )r|  rV   rW   rh   û  s    z<EventCollection.set_positions.<locals>.<listcomp>.<listcomp>rV   )re   )r}  )r|  rW   rh   û  s   z1EventCollection.set_positions.<locals>.<listcomp>c                s   g | ]‰ ‡ fd d„ˆD ƒ‘qS )c                s   g | ]}|ˆ f‘qS rV   rV   )re   r{  )r|  rV   rW   rh   þ  s    z<EventCollection.set_positions.<locals>.<listcomp>.<listcomp>rV   )re   )r}  )r|  rW   rh   þ  s   )	r`   rq   rm  Úget_lineoffsetÚget_linelengthr>   rB   r€  rˆ  )rI   r„  r…  r†  rn  rV   )r}  rW   Úset_positionsë  s     





zEventCollection.set_positionsc             C   sL   |dkst |dƒr"t|ƒdkr"dS | jƒ }tj|tj|ƒgƒ}| j|ƒ dS )zC
        add one or more events at the specified positions
        Nrq   r   )r`   rq   r‰  r>   ÚhstackrB   rŒ  )rI   Úpositionr„  rV   rV   rW   Úadd_positions  s    zEventCollection.add_positionsc             C   s   | j S )zN
        True if the eventcollection is horizontal, False if vertical
        )r�  )rI   rV   rV   rW   rˆ    s    zEventCollection.is_horizontalc             C   s   | j ƒ rdS dS )zf
        get the orientation of the event line, may be:
        [ 'horizontal' | 'vertical' ]
        rz  r~  )rˆ  )rI   rV   rV   rW   Úget_orientation  s    zEventCollection.get_orientationc             C   sL   | j ƒ }x"t|ƒD ]\}}tj|ƒ||< qW | j|ƒ | jƒ  | _d| _dS )zu
        switch the orientation of the event line, either from vertical to
        horizontal or vice versus
        TN)rs  Ú	enumerater>   Úfliplrrm  rˆ  r�  r¬   )rI   rn  ru  r}  rV   rV   rW   Úswitch_orientation  s    
z"EventCollection.switch_orientationc             C   sf   |dks |j ƒ dks |j ƒ dkr&d}n$|j ƒ dkr8d}ntjddg|d� || jƒ krZdS | jƒ  dS )zž
        set the orientation of the event line
        [ 'horizontal' | 'vertical' | None ]
        defaults to 'horizontal' if not specified or None
        NrÝ   rz  Tr~  F)r  )rÞ   r   rÁ   rˆ  r“  )rI   r  rˆ  rV   rV   rW   Úset_orientation'  s    
zEventCollection.set_orientationc             C   s   | j S )zE
        get the length of the lines used to mark each event
        )r‚  )rI   rV   rV   rW   r‹  9  s    zEventCollection.get_linelengthc             C   sz   || j ƒ krdS | jƒ }| jƒ }| jƒ r,dnd}x4|D ],}||d  |d|f< ||d  |d|f< q6W | j|ƒ || _dS )zE
        set the length of the lines used to mark each event
        Nr   r   g       @)r‹  rŠ  rs  rˆ  rm  r‚  )rI   r†  r…  rn  r‡  r}  rV   rV   rW   Úset_linelength?  s    

zEventCollection.set_linelengthc             C   s   | j S )zE
        get the offset of the lines used to mark each event
        )rƒ  )rI   rV   rV   rW   rŠ  N  s    zEventCollection.get_lineoffsetc             C   sz   || j ƒ krdS | jƒ }| jƒ }| jƒ r,dnd}x4|D ],}||d  |d|f< ||d  |d|f< q6W | j|ƒ || _dS )zE
        set the offset of the lines used to mark each event
        Nr   r   g       @)rŠ  r‹  rs  rˆ  rm  rƒ  )rI   r…  r†  rn  r‡  r}  rV   rV   rW   Úset_lineoffsetT  s    

zEventCollection.set_lineoffsetc                s   t t| ƒjƒ d S )z3Get the width of the lines used to mark each event.r   )Úsuperry  rï   )rI   )r�   rV   rW   rï   c  s    zEventCollection.get_linewidthc                s   t t| ƒjƒ S )N)r—  ry  rï   )rI   )r�   rV   rW   r-  g  s    zEventCollection.get_linewidthsc             C   s   | j ƒ d S )zD
        get the color of the lines used to mark each event
        r   )rx  )rI   rV   rV   rW   rw  j  s    zEventCollection.get_color)Nr   r   NNr    N)N)r�   rö   r÷   rø   rç   r$   r‰  rŒ  r�  Zextend_positionsZappend_positionsrˆ  r�  r“  r”  r‹  r•  rŠ  r–  rï   r-  rw  Ú__classcell__rV   rV   )r�   rW   ry  |  s0         
T

ry  c               @   s(   e Zd ZdZejd Zejdd„ ƒZ	dS )	ÚCircleCollectionz-A collection of circles, drawn using splines.r   r   c             K   s8   t j| f|Ž | j|ƒ | jtjƒ ƒ tjjƒ g| _	dS )zf
        *sizes*
            Gives the area of the circle in points^2

        %(Collection)s
        N)
r   r$   r  r_  r   r|   rr   r„   Úunit_circlerH   )rI   r  rU   rV   rV   rW   r$   v  s    
zCircleCollection.__init__NrH  g      à¿)
r�   rö   r÷   rø   r>   rg  r  r	   rA  r$   rV   rV   rV   rW   r™  q  s   
r™  c               @   s6   e Zd ZdZejd
dd„ƒZdd„ Zej	dd„ ƒZ
d	S )ÚEllipseCollectionz.A collection of ellipses, drawn using splines.Úpointsc             K   sx   t j| f|Ž dtj|ƒjƒ  | _dtj|ƒjƒ  | _tj|ƒjƒ | _|| _	| j
tjƒ ƒ tjdƒ| _tjjƒ g| _dS )a@  
        Parameters
        ----------
        widths : array-like
            The lengths of the first axes (e.g., major axis lengths).

        heights : array-like
            The lengths of second axes.

        angles : array-like
            The angles of the first axes, degrees CCW from the x-axis.

        units : {'points', 'inches', 'dots', 'width', 'height', 'x', 'y', 'xy'}

            The units in which majors and minors are given; 'width' and
            'height' refer to the dimensions of the axes, while 'x'
            and 'y' refer to the *offsets* data units. 'xy' differs
            from all others in that the angle as plotted varies with
            the aspect ratio, and equals the specified angle only when
            the aspect ratio is unity.  Hence it behaves the same as
            the :class:`~matplotlib.patches.Ellipse` with
            ``axes.transData`` as its transform.

        Other Parameters
        ----------------
        **kwargs
            Additional kwargs inherited from the base :class:`Collection`.

        %(Collection)s
        g      à?r   r   N)r   r   r   )r   r$   r>   rÃ   ÚravelÚ_widthsÚ_heightsÚdeg2radÚ_anglesÚ_unitsr_  r   r|   rù   r[   rr   r„   rš  rH   )rI   ÚwidthsÚheightsÚanglesÚunitsrU   rV   rV   rW   r$   ‡  s     zEllipseCollection.__init__c       
      C   sÆ  | j }| j}| jdkrd}n¦| jdkr8|jj|jj }nŠ| jdkrT|jj|jj }nn| jdkrf|j}n\| jdkr||jd }nF| jdkr�|jj}n2| jd	kr¤|jj}n| jd
kr´d}ntd| j ƒ‚t	j
t| jƒddfƒ| _| j| }| j| }t	j| jƒ}t	j| jƒ}|| | jdd…ddf< ||  | jdd…ddf< || | jdd…ddf< || | jdd…ddf< d| jdd…ddf< tj}| jdk�rÂ|jjƒ jƒ jƒ }	d|	dd…dd…f< | j||	ƒƒ dS )z0Calculate transforms immediately before drawing.rG  r   r·   r¸   Úinchesrœ  g      R@r¥   r¦   Údotsg      ð?zunrecognized units: %sr   Nr   r   )ra   r  r¢  Úbboxr¥   ZviewLimr¦   r  rÊ   r>   r?   rq   rž  r[   rŸ  Úsinr¡  Úcosr   r£   rx   rk   rd  Úcopyr_  )
rI   ÚaxÚfigZscr£  r¤  Z	sin_angleZ	cos_angleÚ_affineÚmrV   rV   rW   Ú_set_transforms°  sD    











z!EllipseCollection._set_transformsc             C   s   | j ƒ  tj| |ƒ d S )N)r±  r   r°   )rI   r}   rV   rV   rW   r°   Ú  s    zEllipseCollection.drawN)rœ  )r�   rö   r÷   rø   r	   rA  r$   r±  r   rú   r°   rV   rV   rV   rW   r›  „  s
   (*r›  c               @   s"   e Zd ZdZddd„Zdd„ ZdS )	ÚPatchCollectionzþ
    A generic collection of patches.

    This makes it easier to assign a color map to a heterogeneous
    collection of patches.

    This also may improve plotting speed, since PatchCollection will
    draw faster than a large number of patches.
    Fc                s†   |rjdd„ ‰ ‡ fdd„|D ƒ|d< dd„ |D ƒ|d< dd„ |D ƒ|d	< d
d„ |D ƒ|d< dd„ |D ƒ|d< t j| f|Ž | j|ƒ dS )a€  
        *patches*
            a sequence of Patch objects.  This list may include
            a heterogeneous assortment of different patch types.

        *match_original*
            If True, use the colors and linewidths of the original
            patches.  If False, new colors may be assigned by
            providing the standard collection arguments, facecolor,
            edgecolor, linewidths, norm or cmap.

        If any of *edgecolors*, *facecolors*, *linewidths*,
        *antialiaseds* are None, they default to their
        :data:`matplotlib.rcParams` patch setting, in sequence form.

        The use of :class:`~matplotlib.cm.ScalarMappable` is optional.
        If the :class:`~matplotlib.cm.ScalarMappable` matrix _A is not
        None (i.e., a call to set_array has been made), at draw time a
        call to scalar mappable will be made to set the face colors.
        c             S   s   | j ƒ r| jƒ S ddddgS )Nr   )ró   rž   )ÚpatchrV   rV   rW   Údetermine_facecolor  s    z5PatchCollection.__init__.<locals>.determine_facecolorc                s   g | ]}ˆ |ƒ‘qS rV   rV   )re   rf   )r´  rV   rW   rh     s    z,PatchCollection.__init__.<locals>.<listcomp>r   c             S   s   g | ]}|j ƒ ‘qS rV   )rŸ   )re   rf   rV   rV   rW   rh     s    r   c             S   s   g | ]}|j ƒ ‘qS rV   )rï   )re   rf   rV   rV   rW   rh   	  s    r   c             S   s   g | ]}|j ƒ ‘qS rV   )rð   )re   rf   rV   rV   rW   rh   
  s    r   c             S   s   g | ]}|j ƒ ‘qS rV   )Zget_antialiased)re   rf   rV   rV   rW   rh     s    r   N)r   r$   rZ   )rI   ÚpatchesZmatch_originalrU   rV   )r´  rW   r$   ë  s    zPatchCollection.__init__c             C   s   dd„ |D ƒ}|| _ d S )Nc             S   s   g | ]}|j ƒ j|jƒ ƒ‘qS rV   )ri   Útransform_pathÚget_path)re   rf   rV   rV   rW   rh     s   z-PatchCollection.set_paths.<locals>.<listcomp>)rH   )rI   rµ  ry   rV   rV   rW   rZ     s    zPatchCollection.set_pathsN)F)r�   rö   r÷   rø   r$   rZ   rV   rV   rV   rW   r²  à  s   	
&r²  c               @   sB   e Zd ZdZdd„ Zdd„ Zdd„ Zedd	„ ƒZe	j
d
d„ ƒZdS )ÚTriMeshz™
    Class for the efficient drawing of a triangular mesh using Gouraud shading.

    A triangular mesh is a `~matplotlib.tri.Triangulation` object.
    c             K   s^   t j| f|Ž || _d| _d| _tjjƒ | _t	j
|jjddƒ|jjddƒfƒ}| jj|ƒ d S )NÚgouraudTr   rH  rH  )r   r$   Ú_triangulationÚ_shadingr*   r   rv   ÚunitÚ_bboxr>   r�  r·   Úreshaper¸   Úupdate_from_data_xy)rI   ZtriangulationrU   rG  rV   rV   rW   r$     s    zTriMesh.__init__c             C   s   | j d kr| jƒ  | j S )N)rH   rZ   )rI   rV   rV   rW   rX   +  s    
zTriMesh.get_pathsc             C   s   | j | jƒ| _d S )N)Úconvert_mesh_to_pathsrº  rH   )rI   rV   rV   rW   rZ   0  s    zTriMesh.set_pathsc             C   s4   | j ƒ }tj| j| | j| fdd�}dd„ |D ƒS )zÀ
        Converts a given mesh into a sequence of `~.Path` objects.

        This function is primarily of use to implementers of backends that do
        not directly support meshes.
        r   )Úaxisc             S   s   g | ]}t j|ƒ‘qS rV   )rr   r„   )re   r·   rV   rV   rW   rh   =  s    z1TriMesh.convert_mesh_to_paths.<locals>.<listcomp>rH  )Úget_masked_trianglesr>   Ústackr·   r¸   )ÚtriÚ	trianglesrD  rV   rV   rW   rÀ  3  s    zTriMesh.convert_mesh_to_pathsc             C   s²   | j ƒ sd S |j| jjƒ | jƒ }| j}|jƒ }tj|j	| |j
| fdd�}| jƒ  | j| }|jƒ }| j|ƒ |j| jƒ d ƒ |j||||jƒ ƒ |jƒ  |j| jjƒ d S )Nr   )rÁ  r   rH  )r�   rŽ   r�   r�   ri   rº  rÂ  r>   rÃ  r·   r¸   r’   rá   r“   r”   r2   rï   Údraw_gouraud_trianglesrt   rª   r«   )rI   r}   rg   rÄ  rÅ  rD  r   r­   rV   rV   rW   r°   ?  s    

zTriMesh.drawN)r�   rö   r÷   rø   r$   rX   rZ   rû   rÀ  r   rú   r°   rV   rV   rV   rW   r¸    s   r¸  c               @   sT   e Zd ZdZddd„Zdd„ Zdd	„ Zd
d„ Zedd„ ƒZ	dd„ Z
ejdd„ ƒZdS )ÚQuadMeshaÄ  
    Class for the efficient drawing of a quadrilateral mesh.

    A quadrilateral mesh consists of a grid of vertices. The
    dimensions of this array are (*meshWidth* + 1, *meshHeight* +
    1). Each vertex in the mesh has a different set of "mesh
    coordinates" representing its position in the topology of the
    mesh. For any values (*m*, *n*) such that 0 <= *m* <= *meshWidth*
    and 0 <= *n* <= *meshHeight*, the vertices at mesh coordinates
    (*m*, *n*), (*m*, *n* + 1), (*m* + 1, *n* + 1), and (*m* + 1, *n*)
    form one of the quadrilaterals in the mesh. There are thus
    (*meshWidth* * *meshHeight*) quadrilaterals in the mesh.  The mesh
    need not be regular and the polygons need not be convex.

    A quadrilateral mesh is represented by a (2 x ((*meshWidth* + 1) *
    (*meshHeight* + 1))) numpy array *coordinates*, where each row is
    the *x* and *y* coordinates of one of the vertices.  To define the
    function that maps from a data point to its corresponding color,
    use the :meth:`set_cmap` method.  Each of these arrays is indexed in
    row-major order by the mesh coordinates of the vertex (or the mesh
    coordinates of the lower left vertex, in the case of the
    colors).

    For example, the first entry in *coordinates* is the
    coordinates of the vertex at mesh coordinates (0, 0), then the one
    at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and
    so on.

    *shading* may be 'flat', or 'gouraud'
    TÚflatc             K   sz   t j| f|Ž || _|| _tj|tƒj|d |d dfƒ| _|| _	|| _
tjjƒ | _| jj|j|d |d  dfƒƒ d S )Nr   r   )r   r$   Ú
_meshWidthÚ_meshHeightr>   rÃ   rC   r¾  Ú_coordinatesÚ_antialiasedr»  r   rv   r¼  r½  r¿  )rI   Ú	meshWidthÚ
meshHeightÚcoordinatesr   ÚshadingrU   rV   rV   rW   r$   v  s    
zQuadMesh.__init__c             C   s   | j d kr| jƒ  | j S )N)rH   rZ   )rI   rV   rV   rW   rX   …  s    
zQuadMesh.get_pathsc             C   s    | j | j| j| jƒ| _d| _d S )NT)rÀ  rÉ  rÊ  rË  rH   r¬   )rI   rV   rV   rW   rZ   Š  s    zQuadMesh.set_pathsc             C   s   | j ƒ | j| jƒS )N)ri   Útransform_bboxr½  )rI   rx   rV   rV   rW   r{   �  s    zQuadMesh.get_datalimc          	   C   s¤   t |tjjƒr|j}n|}tj|dd…dd	…f |dd
…dd…f |dd…dd…f |dd…dd…f |dd…dd…f fdd�}|j| | ddfƒ}dd„ |D ƒS )zÄ
        Converts a given mesh into a sequence of `~.Path` objects.

        This function is primarily of use to implementers of backends that do
        not directly support quadmeshes.
        Nr   r   )rÁ  r  c             S   s   g | ]}t j|ƒ‘qS rV   )rr   r„   )re   r·   rV   rV   rW   rh   ¦  s    z2QuadMesh.convert_mesh_to_paths.<locals>.<listcomp>rH  rH  rH  rH  rH  rH  )r^   r>   rm   rn   rÀ   rJ  r¾  )rÍ  rÎ  rÏ  rÛ   rœ  rV   rV   rW   rÀ  ’  s    zQuadMesh.convert_mesh_to_pathsc             C   s‚  t |tjjƒr|j}n|}|dd…dd	…f }|dd
…dd…f }|dd…dd…f }|dd…dd…f }|| | | d }	tj|||	|||	|||	|||	fdd�}
|
j|| d ddfƒ}
| jƒ j|d |d dfƒ}|dd…dd…f }|dd…dd…f }|dd…dd…f }|dd…dd…f }|| | | d }tj||||||||||||fdd�}|j|| d ddfƒ}|
|fS )z³
        Converts a given mesh into a sequence of triangles, each point
        with its own color.  This is useful for experiments using
        `draw_gouraud_triangle`.
        Nr   g      @r   )rÁ  é   r   rH  rH  rH  rH  rH  rH  rH  rH  )r^   r>   rm   rn   rÀ   rJ  r¾  rž   )rI   rÍ  rÎ  rÏ  rf   Zp_aZp_bZp_cZp_dZp_centerrÅ  rÛ   Zc_aZc_bÚc_cÚc_dZc_centerr   rV   rV   rW   Úconvert_mesh_to_triangles¨  s:    z"QuadMesh.convert_mesh_to_trianglesc             C   sŠ  | j ƒ sd S |j| jj| jƒ ƒ | jƒ }| jƒ }| j}| jƒ r†t	| jƒr†| j
| jd d …df ƒ}| j| jd d …df ƒ}tj||gƒ}| jƒ  |jsÂ| jjdƒ}|j|ƒ}|j| jjƒ}tjƒ }n| j}|jsà|j|ƒ}|jƒ }|jƒ }| j|ƒ |j| jƒ d ƒ | jdk�r<| j| j| j|ƒ\}	}
|j ||	|
|j!ƒ ƒ n.|j"||j!ƒ | j| j|||| j#ƒ | j$| j%ƒ ƒ
 |j&ƒ  |j'| jjƒ d| _(d S )Nr   r   r   r¹  FrH  )rH  r   ))r�   rŽ   r�   r�   r‘   ri   rc   r@   r   rq   r�   r‚   r>   r…   r’   rj   rË  r¾  rg   rD   r   r|   rl   rk   r“   r”   r2   rï   r»  rÕ  rÉ  rÊ  rÆ  rt   Zdraw_quad_meshrž   rÌ  Zget_edgecolorsrª   r«   r¬   )rI   r}   rg   rM   rL   rˆ   r‰   rÏ  r­   rÅ  r   rV   rV   rW   r°   Ò  sH    




zQuadMesh.drawN)TrÈ  )r�   rö   r÷   rø   r$   rX   rZ   r{   rû   rÀ  rÕ  r   rú   r°   rV   rV   rV   rW   rÇ  W  s   
*rÇ  )rl  )
rÇ  r¸  rB  rP  r[  r  rh  r²  r™  r   )-rø   rÖ   Únumbersr   Únumpyr>   Ú
matplotlibr-   r  r   r   r   r   r   r+   r	   r
   rÅ   r   rr   r   r  Ú_define_aliasesr#   r%   r   ÚinterpdrG   rü   r  rB  rP  r[  rh  rj  rl  ry  r™  r›  r²  r¸  rÇ  ÚkwdocZpatchstrr  rV   rV   rV   rW   Ú<module>
   s\   ,      0 C/A A v\7@ ,
  