B
    ]”t\# ã               @   sÖ  d Z ddlZddlmZ ddl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e ej¡ Ze dgdgd	g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 d-d.„ d.eƒZ,e -e¡Z.xd/D ]Z/ej e/e.i¡ q¤W ejje -e&¡d0 dS )1ax  
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 segemnts)
é    N)ÚNumberé   )	Ú_pathÚartistÚcbookÚcmÚcolorsÚ	docstringÚlinesÚpathÚ
transformsg      ð?ÚantialiasedsÚ
edgecolorsÚ
facecolorsÚ
linestylesÚdashesÚ
linewidthsÚlw)ÚantialiasedZ	edgecolorZ	facecolorÚ	linestyleÚ	linewidthc               @   s„  e Zd ZdZe d¡Ze ¡ Z	e 
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.d/„ Z!d0d1„ Z"d2d3„ Z#d4d5„ Z$d6d7„ Z%d8d9„ Z&d:d;„ Z'd<d=„ Z(e)d>d?„ ƒZ*d@dA„ Z+dBdC„ Z,dDdE„ Z-dFdG„ Z.dHdI„ Z/dJdK„ Z0dLdM„ Z1dNdO„ Z2dPdQ„ Z3dRdS„ Z4dTdU„ Z5dVdW„ Z6dXdY„ Z7dZd[„ 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   é   )r   é   r   FNÚsolidç      @Úscreenr   c             K   s`  t j | ¡ tj | |
|¡ dg| _dg| _dg| _dg| _d| _	t
 tjd ¡| _|  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |rÈ|  |¡ nd| _|rÞ|  |¡ nd| _t d¡| _d| _ |dk	rFt !|t"¡}|j#dkr(|ddd…f }|	dk	r@|| _|	| _$n|| _ d| _%|  &|¡ d| _'dS )z=
        Create a Collection

        %(Collection)s
        )NNr   Tzhatch.colorN)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_positionZ
set_zorderÚset_capstyleÚ	_capstyleÚset_joinstyleÚ
_joinstyleÚnpÚzerosÚ_offsetsÚ_uniform_offsetsÚ
asanyarrayÚfloatÚshapeÚ_transOffsetZ_path_effectsÚupdateÚ_paths)Úselfr   r   r   r   ZcapstyleZ	joinstyler   ÚoffsetsÚtransOffsetÚnormÚcmapÚ
pickradiusÚhatchÚurlsÚoffset_positionÚzorderÚkwargs© rL   ú5lib/python3.7/site-packages/matplotlib/collections.pyr   ^   sJ    












zCollection.__init__c             C   s   | j S )N)r@   )rA   rL   rL   rM   Ú	get_paths©   s    zCollection.get_pathsc             C   s   t ‚d S )N)ÚNotImplementedError)rA   rL   rL   rM   Ú	set_paths¬   s    zCollection.set_pathsc             C   s   | j S )N)Ú_transforms)rA   rL   rL   rM   Úget_transforms¯   s    zCollection.get_transformsc             C   s,   | j }t|tjƒs(t|dƒr(| | j¡}|S )NÚ_as_mpl_transform)r>   Ú
isinstancer   Z	TransformÚhasattrrS   Úaxes)rA   ÚtrL   rL   rM   Úget_offset_transform²   s
    
zCollection.get_offset_transformc                s¸   |   ¡ ‰ |  ¡ }| j}|  ¡ }ˆ js>‡ fdd„|D ƒ}ˆ  ¡ ‰ |jsV| |¡}| ¡ }t|tj	j
ƒrp| tj¡}t|ƒrªt|ƒrªt ˆ  ¡ ||  ¡ || ¡ ¡}| |¡}n
tj ¡ }|S )Nc                s   g | ]}ˆ   |¡‘qS rL   )Útransform_path_non_affine)Ú.0Úp)Ú	transformrL   rM   ú
<listcomp>À   s    z*Collection.get_datalim.<locals>.<listcomp>)Úget_transformrX   r9   rN   Ú	is_affineÚ
get_affineÚtransform_non_affinerT   r7   ÚmaÚMaskedArrayÚfilledÚnanÚlenÚmpathZget_path_collection_extentsÚfrozenrR   Zinverse_transformedr   ÚBboxZnull)rA   Ú	transDatarC   rB   ÚpathsÚresultrL   )r\   rM   Úget_datalim¹   s&    

zCollection.get_datalimc             C   s   |   t ¡ ¡S )N)rm   r   ÚIdentityTransform)rA   ÚrendererrL   rL   rM   Úget_window_extentÓ   s    zCollection.get_window_extentc          	      s<  |   ¡ ‰ |  ¡ }| j}|  ¡ }|  ¡ rÚg }xj|  ¡ D ]^}|j}|dd…df |dd…df  }}|  |¡}|  |¡}| t	 
t ||g¡|j¡¡ q4W |jdkrÚ|  |dd…df ¡}|  |dd…df ¡}t ||g¡}ˆ jsú‡ fdd„|D ƒ}ˆ  ¡ ‰ |js| |¡}| ¡ }t|tjjƒr0| tj¡}ˆ |||fS )z&Point prep for drawing and hit testingNr   r   c                s   g | ]}ˆ   |¡‘qS rL   )rY   )rZ   r   )r\   rL   rM   r]   ï   s   z.Collection._prepare_points.<locals>.<listcomp>)r^   rX   r9   rN   Ú
have_unitsÚverticesÚconvert_xunitsÚconvert_yunitsÚappendrg   ÚPathr7   Úcolumn_stackÚcodesÚsizer_   r`   ra   rT   rb   rc   rd   re   )rA   rC   rB   rk   r   rr   ÚxsÚysrL   )r\   rM   Ú_prepare_pointsØ   s4    "

"


zCollection._prepare_pointsc             C   sÖ  |   ¡ sd S | | jj|  ¡ ¡ |  ¡  |  ¡ \}}}}| ¡ }|  |¡ | 	|  
¡ ¡ | jrš| | j¡ y| | j¡ W n tk
r˜   t d¡ Y nX |  ¡ d k	r´|j|  ¡ Ž  |  ¡ rÖddlm} ||  ¡ |ƒ}|  ¡ }|  ¡ }	|  ¡ }
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Î|  ¡ d krÎt|ƒr”t  !|d ¡| }n|}|d  "|¡}| #¡ \}}|j$|k rÎ|j%|k rÎd}| j&râ| '| j&¡ | j(rö| )| j(¡ |rz| *t+|
d ƒ¡ | ,| jd ¡ |j-| jd Ž  | .| jd ¡ | /| jd ¡ | 0||d | 1¡ t2 3|¡|t+|	d ƒ¡ n<| 4|| 1¡ ||  ¡ |||  ¡ |  ¡ | j| j| j| j| j5¡ | 6¡  | 7| jj¡ d| _8d S )Nz6Your backend does not support setting the hatch color.r   )ÚPathEffectRendererFr   )NNT)9Úget_visibleÚ
open_groupÚ	__class__Ú__name__Úget_gidÚupdate_scalarmappabler|   Únew_gcÚ_set_gc_clipZset_snapZget_snapÚ_hatchr1   Úset_hatch_colorr)   ÚAttributeErrorÚwarningsÚwarnZget_sketch_paramsZset_sketch_paramsZget_path_effectsZmatplotlib.patheffectsr}   rR   Úget_facecolorÚget_edgecolorrf   r#   r!   Ú_antialiasedsÚ_urlsÚ	get_hatchr   ÚAffine2DZget_extentsZget_canvas_width_heightÚwidthÚheightr6   r5   r4   r3   Zset_foregroundÚtupler,   Z
set_dashesr.   Zset_urlZdraw_markersrh   rg   rv   Zdraw_path_collectionÚ_offset_positionÚrestoreÚclose_groupÚstale)rA   ro   r\   rC   rB   rk   Úgcr}   Ztransr   r   Zdo_single_path_optimizationZcombined_transformZextentsr‘   r’   rL   rL   rM   Údrawþ   sx    
 


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)rA   ZprrL   rL   rM   r/   R  s    zCollection.set_pickradiusc             C   s   | j S )N)rš   )rA   rL   rL   rM   Úget_pickradius\  s    zCollection.get_pickradiusc             C   s¢   t | jƒr|  | |¡S |  ¡ s&di fS t| jtƒrF| jdk	rFt| jƒn| j}|  ¡ \}}}}t	 
|j|j|| ¡ ||  ¡ |||dk|  ¡ ¡
}t|ƒdkt|dfS )zº
        Test whether the mouse event occurred in the collection.

        Returns True | False, ``dict(ind=itemlist)``, where every
        item in itemlist contains the event.
        FTr   )Úind)ÚcallableZ	_containsr~   rT   Z_pickerr   r<   rš   r|   r   Zpoint_in_path_collectionÚxÚyrh   rR   Úget_offset_positionrf   Údict)rA   Z
mouseeventrF   r\   rC   rB   rk   rœ   rL   rL   rM   Ú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—   )rA   rH   rL   rL   rM   r0   |  s    zCollection.set_urlsc             C   s   | j S )N)rŽ   )rA   rL   rL   rM   Ú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—   )rA   rG   rL   rL   rM   r1   ˆ  s     zCollection.set_hatchc             C   s   | j S )z$Return the current hatching pattern.)r†   )rA   rL   rL   rM   r   «  s    zCollection.get_hatchc             C   sH   t  |t¡}|jdkr&|ddd…f }| jdkr8|| _n|| _d| _dS )z¼
        Set the offsets for the collection.  *offsets* can be a scalar
        or a sequence.

        Parameters
        ----------
        offsets : float or sequence of floats
        )r   NT)r7   r;   r<   r=   r:   r9   r—   )rA   rB   rL   rL   rM   Ú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)r:   r9   )rA   rL   rL   rM   Úget_offsetsÂ  s    
zCollection.get_offsetsc             C   s    |dkrt 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   Údataz*offset_position must be 'screen' or 'data'TN)Ú
ValueErrorr”   r—   )rA   rI   rL   rL   rM   r2   Ê  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”   )rA   rL   rL   rM   r    Û  s    	zCollection.get_offset_positionc             C   sX   |dkr$t jd }|dkr$t jd }t t |¡¡| _|  | 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(   r7   Ú
atleast_1dÚasarrayr"   Ú_bcast_lwlsr    r#   r!   r—   )rA   r   rL   rL   rM   r,   æ  s    


zCollection.set_linewidthc             C   s¤   y^t |tƒr(tj ||¡}t |¡g}n4yt |¡g}W n" tk
rZ   dd„ |D ƒ}Y nX W n" tk
r€   td |¡ƒ‚Y nX || _	|  
| 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  |¡‘qS rL   )ÚmlinesÚ_get_dash_pattern)rZ   rž   rL   rL   rM   r]     s    z,Collection.set_linestyle.<locals>.<listcomp>z)Do not know how to convert {!r} to dashesN)rT   Ústrr   Z	ls_mapperÚgetr«   r¬   r§   Úformatr    rª   r"   r#   r!   )rA   Zlsr   rL   rL   rM   r-   ü  s    
zCollection.set_linestylec             C   s    |dkr|| _ ntd| ƒ‚dS )zô
        Set the capstyle for the collection. The capstyle can
        only be set globally for all elements in the collection

        Parameters
        ----------
        cs : {'butt', 'round', 'projecting'}
            The capstyle
        )ZbuttÚroundZ
projectingz!Unrecognized cap style.  Found %sN)r4   r§   )rA   ZcsrL   rL   rM   r3   )  s    
zCollection.set_capstylec             C   s   | j S )N)r4   )rA   rL   rL   rM   Úget_capstyle8  s    zCollection.get_capstylec             C   s    |dkr|| _ ntd| ƒ‚dS )zô
        Set the joinstyle for the collection. The joinstyle can only be
        set globally for all elements in the collection.

        Parameters
        ----------
        js : {'miter', 'round', 'bevel'}
            The joinstyle
        )Zmiterr°   Zbevelz"Unrecognized join style.  Found %sN)r6   r§   )rA   ZjsrL   rL   rM   r5   ;  s    
zCollection.set_joinstylec             C   s   | j S )N)r6   )rA   rL   rL   rM   Úget_joinstyleJ  s    zCollection.get_joinstylec             C   sz   t jd r| |fS t|ƒt| ƒkr^t|ƒ}t| ƒ}t ||¡}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  |||¡‘qS rL   )r«   Z_scale_dashes)rZ   ÚoÚdr   rL   rL   rM   r]   p  s   z*Collection._bcast_lwls.<locals>.<listcomp>)r'   r(   rf   ÚmathÚgcdÚlistÚzip)r   r   Zl_dashesZl_lwr¶   rL   rL   rM   rª   M  s    
zCollection._bcast_lwlsc             C   s0   |dkrt jd }t t |t¡¡| _d| _dS )z‰
        Set the antialiasing state for rendering.

        Parameters
        ----------
        aa : bool or sequence of bools
        Nzpatch.antialiasedT)r'   r(   r7   r¨   r©   Úboolr   r—   )rA   ZaarL   rL   rM   r.   u  s    
zCollection.set_antialiasedc             C   s   |   |¡ |  |¡ dS )a.  
        Set both the edgecolor and the facecolor.

        .. seealso::

            :meth:`set_facecolor`, :meth:`set_edgecolor`
               For setting the edge or face color individually.

        Parameters
        ----------
        c : matplotlib color arg or sequence of rgba tuples
        N)r*   r+   )rA   ÚcrL   rL   rM   Ú	set_color‚  s    
zCollection.set_colorc             C   s^   |d krt jd }d| _y| ¡ dkr,d| _W n tk
rB   Y nX t || j¡| _d| _	d S )Nzpatch.facecolorTÚnoneF)
r'   r(   r$   Úlowerrˆ   r%   Úto_rgba_arrayÚ_alphaÚ_facecolorsr—   )rA   rº   rL   rL   rM   Ú_set_facecolor’  s    

zCollection._set_facecolorc             C   s   || _ |  |¡ 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Á   )rA   rº   rL   rL   rM   r*   Ÿ  s    zCollection.set_facecolorc             C   s   | j S )N)rÀ   )rA   rL   rL   rM   r‹   ¯  s    zCollection.get_facecolorc             C   s    t  | jd¡r|  ¡ S | jS d S )NÚface)r   Z
_str_equalÚ_edgecolorsZget_facecolors)rA   rL   rL   rM   rŒ   ²  s    zCollection.get_edgecolorc             C   sÐ   d}|d kr6t jd s"| jr"| jr.t jd }nd}d}d| _y| ¡ dkrPd| _W n tk
rf   Y nX y| ¡ dkr€d| _d S W n tk
r–   Y nX t 	|| 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¿   rf   r“   r)   r—   )rA   rº   r‡   rL   rL   rM   Ú_set_edgecolor¸  s.    

zCollection._set_edgecolorc             C   s   || _ |  |¡ dS )aØ  
        Set the edgecolor(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 'face', the edge color will always be the same as
        the face color.  If it is 'none', the patch boundary will not
        be drawn.

        Parameters
        ----------
        c : color or sequence of colors
        N)Ú_original_edgecolorrÇ   )rA   rº   rL   rL   rM   r+   Ô  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	¡ dS )z±
        Set the alpha tranparencies of the collection.  *alpha* must be
        a float or *None*.

        Parameters
        ----------
        alpha : float or None
        Nzalpha must be a float or NoneTÚarray)
r<   Ú	TypeErrorZupdate_dictr   r   Ú	set_alpharÁ   rÂ   rÇ   rÈ   )rA   ZalpharL   rL   rM   rË   æ  s    	
zCollection.set_alphac             C   s   | j S )N)r#   )rA   rL   rL   rM   Úget_linewidthù  s    zCollection.get_linewidthc             C   s   | j S )N)r!   )rA   rL   rL   rM   Úget_linestyleü  s    zCollection.get_linestylec             C   sl   | j dkrdS | j jdkr"tdƒ‚|  d¡s0dS | jrJ|  | j | j¡| _n| jrb|  | j | j¡| _	d| _
dS )zb
        If the scalar mappable array is not none, update colors
        from scalar data
        Nr   z&Collections can only map rank 1 arraysrÉ   T)Ú_AÚndimr§   Zcheck_updater$   r&   r¿   rÀ   rÆ   rÄ   r—   )rA   rL   rL   rM   rƒ   ÿ  s    

z Collection.update_scalarmappablec             C   s   | j S )zreturn whether fill is set)r$   )rA   rL   rL   rM   Úget_fill  s    zCollection.get_fillc             C   s€   t 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Î   rD   rE   r—   )rA   ÚotherrL   rL   rM   rÑ     s    zCollection.update_from)NNNr   NNNNNNNr   NNr   r   )9r   Ú
__module__Ú__qualname__Ú__doc__r7   r8   r9   r   rn   r>   ÚemptyrQ   rÅ   r   rN   rP   rR   rX   rm   rp   r|   r   Úallow_rasterizationr™   r/   r›   r¢   r0   r£   r1   r   r¤   r¥   r2   r    r,   r-   r3   r±   r5   r²   Ústaticmethodrª   r.   r»   rÁ   r*   r‹   rŒ   rÇ   r+   rË   rÌ   rÍ   rƒ   rÐ   rÑ   rL   rL   rL   rM   r      sz   6

               
;&T
	#-(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)rA   rL   rL   rM   Ú	get_sizesK  s    
z_CollectionWithSizes.get_sizesç      R@c             C   s¦   |dkr"t  g ¡| _t  d¡| _nzt  |¡| _t  t| jƒddf¡| _t  | 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 )
aG  
        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.
        N)r   r   r   r   g      R@r   r   g      ð?r   T)r7   rÉ   rÚ   rÖ   rQ   r©   r8   rf   ÚsqrtÚ_factorr—   )rA   ÚsizesÚdpiZscalerL   rL   rM   Ú	set_sizesW  s    z_CollectionWithSizes.set_sizesc             C   s"   |   | j| jj¡ t | |¡ d S )N)rá   rÚ   Úfigurerà   r   r™   )rA   ro   rL   rL   rM   r™   p  s    z_CollectionWithSizes.drawN)rÜ   )
r   rÓ   rÔ   rÕ   rÞ   rÛ   rá   r   r×   r™   rL   rL   rL   rM   rÙ   E  s
   
rÙ   c               @   s0   e Zd ZdZejd	dd„ƒZdd„ Zdd„ ZdS )
ÚPathCollectionz>
    This is the most basic :class:`Collection` subclass.
    Nc             K   s,   t j| f|Ž |  |¡ |  |¡ d| _dS )zs
        *paths* is a sequence of :class:`matplotlib.path.Path`
        instances.

        %(Collection)s
        TN)r   r   rP   rá   r—   )rA   rk   rß   rK   rL   rL   rM   r   z  s    	

zPathCollection.__init__c             C   s   || _ d| _d S )NT)r@   r—   )rA   rk   rL   rL   rM   rP   ˆ  s    zPathCollection.set_pathsc             C   s   | j S )N)r@   )rA   rL   rL   rM   rN   Œ  s    zPathCollection.get_paths)N)	r   rÓ   rÔ   rÕ   r	   Údedent_interpdr   rP   rN   rL   rL   rL   rM   rã   v  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|Ž |  |¡ |  ||¡ 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—   )rA   Úvertsrß   ÚclosedrK   rL   rL   rM   r   ‘  s    
zPolyCollection.__init__c             C   s  t |tjjƒr | t¡ tj¡}|ròg | _xÖ|D ]¼}t	|ƒrÚt |tjjƒrdtj 
||dd… g¡}n t |¡}t 
||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 t ||¡¡ q0| j t |¡¡ q0W ndd„ |D ƒ| _d| _dS )	z8This allows one to delay initialization of the vertices.r   r   )ZdtypeNéÿÿÿÿc             S   s   g | ]}t  |¡‘qS rL   )rg   rv   )rZ   ÚxyrL   rL   rM   r]   À  s    z,PolyCollection.set_verts.<locals>.<listcomp>T)rT   r7   rb   rc   Zastyper<   rd   re   r@   rf   Úconcatenater©   rÖ   r=   rg   rv   Z	code_typeZLINETOZMOVETOZ	CLOSEPOLYru   r—   )rA   rç   rè   rê   rx   rL   rL   rM   ræ   ª  s$    

zPolyCollection.set_vertsc             C   sp   t |ƒt |ƒkrtdƒ‚g | _xFt||ƒD ]8\}}t |ƒrP| j t ||¡¡ q*| j t |¡¡ 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)rf   r§   r@   r¸   ru   rg   rv   r—   )rA   rç   rx   rê   ZcdsrL   rL   rM   Úset_verts_and_codesÅ  s    z"PolyCollection.set_verts_and_codes)NT)T)	r   rÓ   rÔ   r	   rä   r   ræ   rP   rì   rL   rL   rL   rM   rå     s
   
rå   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 rL   rL   )rZ   ZxminZxwidth)ÚymaxÚyminrL   rM   r]   å  s   z1BrokenBarHCollection.__init__.<locals>.<listcomp>N)rå   r   )rA   ÚxrangesZyrangerK   Zywidthrç   rL   )rî   rï   rM   r   Ø  s
    zBrokenBarHCollection.__init__c       
      K   sj   g }xJt  |¡D ]<\}}| ||… }t|ƒs.q| |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é   )r   Zcontiguous_regionsrf   ru   rí   )
rž   rï   rî   ÚwhererK   rð   Zind0Zind1ZxsliceZ
collectionrL   rL   rM   Ú
span_whereì  s    
"zBrokenBarHCollection.span_whereN)	r   rÓ   rÔ   rÕ   r	   rä   r   rØ   rò   rL   rL   rL   rM   rí   Ó  s   rí   c               @   sJ   e Zd ZdZejjZe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   c             K   sD   t j| f|Ž |  |¡ || _|  |¡g| _|| _|  t 	¡ ¡ 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_generatorr@   Ú	_rotationÚset_transformr   rn   )rA   ZnumsidesZrotationrß   rK   rL   rL   rM   r     s    $
zRegularPolyCollection.__init__c             C   s   | j S )N)rõ   )rA   rL   rL   rM   Úget_numsides3  s    z"RegularPolyCollection.get_numsidesc             C   s   | j S )N)r÷   )rA   rL   rL   rM   Úget_rotation6  s    z"RegularPolyCollection.get_rotationc                s8   ˆ   ˆ jˆ jj¡ ‡ fdd„ˆ jD ƒˆ _t ˆ |¡ d S )Nc                s$   g | ]}t  |¡ ˆ j ¡ ¡ ‘qS rL   )r   r   Úrotater÷   Ú
get_matrix)rZ   rž   )rA   rL   rM   r]   =  s   z.RegularPolyCollection.draw.<locals>.<listcomp>)rá   rÚ   râ   rà   rQ   r   r™   )rA   ro   rL   )rA   rM   r™   9  s    
zRegularPolyCollection.drawN)r   rô   )r   rÓ   rÔ   rÕ   rg   rv   Zunit_regular_polygonrö   ÚCIRCLE_AREA_FACTORrÞ   r	   rä   r   rù   rú   r   r×   r™   rL   rL   rL   rM   ró     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Õ   rg   rv   Zunit_regular_starrö   rL   rL   rL   rM   rþ   C  s   rþ   c               @   s   e Zd ZdZejjZdS )ÚAsteriskPolygonCollectionzC
    Draw a collection of regular asterisks with *numsides* points.N)r   rÓ   rÔ   rÕ   rg   rv   Zunit_regular_asteriskrö   rL   rL   rL   rM   rÿ   J  s   rÿ   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¼   c             K   s|   |dkrt jd }|dkr&t jd f}|dkr:t jd f}t |¡}tj| f|||||||||	|
|dœ|—Ž |  |¡ 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   rB   rC   rD   rE   rF   rJ   )r'   r(   r%   r¾   r   r   Úset_segments)rA   Úsegmentsr   r   r   r   rB   rC   rD   rE   rF   rJ   r   rK   rL   rL   rM   r   _  s,    S

zLineCollection.__init__c             C   sp   |d krd S g }x0|D ](}t |tjjƒs4t |t¡}| |¡ qW | jd k	rV|  |¡}dd„ |D ƒ| _	d| _
d S )Nc             S   s   g | ]}t  |¡‘qS rL   )rg   rv   )rZ   Z_segrL   rL   rM   r]   Ù  s    z/LineCollection.set_segments.<locals>.<listcomp>T)rT   r7   rb   rc   r©   r<   ru   r:   Ú_add_offsetsr@   r—   )rA   r  Z	_segmentsZsegrL   rL   rM   r  Ì  s    


zLineCollection.set_segmentsc             C   s>   g }x4| j D ]*}dd„ | ¡ D ƒ}t |¡}| |¡ 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 rL   rL   )rZ   ZvertexÚ_rL   rL   rM   r]   ê  s    z/LineCollection.get_segments.<locals>.<listcomp>)r@   Ziter_segmentsr7   r©   ru   )rA   r  r   rr   rL   rL   rM   Úget_segmentsß  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   )r:   rf   r=   Úrange)rA   ZsegsrB   ZNsegsZNoffsÚiÚiorL   rL   rM   r  ð  s    
 zLineCollection._add_offsetsc             C   s   |   |¡ d| _dS )a(  
        Set the color(s) of the LineCollection.

        Parameters
        ----------
        c :
            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)r+   r—   )rA   rº   rL   rL   rM   r»   ý  s    
zLineCollection.set_colorc             C   s   | j S )N)rÄ   )rA   rL   rL   rM   Ú	get_color  s    zLineCollection.get_color)NNNr   NNNNr  r   r¼   )r   rÓ   rÔ   rÕ   rÅ   r   r  ræ   rP   r  r  r»   r
  Ú
get_colorsrL   rL   rL   rM   r   Q  s*   
          
br   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ƒ‚nx|dksp| ¡ dksp| ¡ dkr’| ¡  ‡ fd	d
„|D ƒ}
d| _n6| ¡ dkrÀ| ¡  ‡ fdd
„|D ƒ}
d| _nt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 rL   rL   )rZ   Úcoord2)Úcoord1rL   rM   r]   a  s    z7EventCollection.__init__.<locals>.<listcomp>.<listcomp>rL   )rZ   )Úsegment)r  rM   r]   a  s   z,EventCollection.__init__.<locals>.<listcomp>TÚverticalc                s   g | ]‰ ‡ fd d„ˆD ƒ‘qS )c                s   g | ]}|ˆ f‘qS rL   rL   )rZ   r  )r  rL   rM   r]   f  s    z7EventCollection.__init__.<locals>.<listcomp>.<listcomp>rL   )rZ   )r  )r  rM   r]   f  s   Fz.orientation must be 'horizontal' or 'vertical')r   r   r   r   )rf   rU   rÏ   r§   r½   ÚsortÚ_is_horizontalr   r   Ú_linelengthÚ_lineoffset)rA   Ú	positionsÚorientationÚ
lineoffsetÚ
linelengthr   Zcolorr   r   rK   r  rL   )r  rM   r     s6    ;



zEventCollection.__init__c             C   s@   |   ¡ }|  ¡ rdnd}g }x|D ]}| |d|f ¡ q"W |S )zW
        return an array containing the floating-point values of the positions
        r   r   )r  Úis_horizontalru   )rA   r  Úposr  r  rL   rL   rM   Úget_positionsw  s    
zEventCollection.get_positionsc                s¢   |dkst |dƒr,t|ƒdkr,|  g ¡ dS |  ¡ }|  ¡ }||d  ||d  f‰ t |¡}| ¡  |  ¡ r‚‡ fdd„|D ƒ}n‡ fdd„|D ƒ}|  |¡ dS )zH
        set the positions of the events to the specified value
        Nrf   r   g       @c                s   g | ]‰ ‡ fd d„ˆD ƒ‘qS )c                s   g | ]}ˆ |f‘qS rL   rL   )rZ   r  )r  rL   rM   r]   ’  s    z<EventCollection.set_positions.<locals>.<listcomp>.<listcomp>rL   )rZ   )r  )r  rM   r]   ’  s   z1EventCollection.set_positions.<locals>.<listcomp>c                s   g | ]‰ ‡ fd d„ˆD ƒ‘qS )c                s   g | ]}|ˆ f‘qS rL   rL   )rZ   r  )r  rL   rM   r]   •  s    z<EventCollection.set_positions.<locals>.<listcomp>.<listcomp>rL   )rZ   )r  )r  rM   r]   •  s   )	rU   rf   r  Úget_lineoffsetÚget_linelengthr7   r;   r  r  )rA   r  r  r  r  rL   )r  rM   Úset_positions‚  s     





zEventCollection.set_positionsc             C   sL   |dkst |dƒr"t|ƒdkr"dS |  ¡ }t |t |¡g¡}|  |¡ dS )zC
        add one or more events at the specified positions
        Nrf   r   )rU   rf   r  r7   Úhstackr;   r  )rA   Zpositionr  rL   rL   rM   Úadd_positions™  s    zEventCollection.add_positionsc             C   s   | j S )zN
        True if the eventcollection is horizontal, False if vertical
        )r  )rA   rL   rL   rM   r  ¥  s    zEventCollection.is_horizontalc             C   s   |   ¡ rdS dS )zf
        get the orientation of the event line, may be:
        [ 'horizontal' | 'vertical' ]
        r  r  )r  )rA   rL   rL   rM   Úget_orientation«  s    zEventCollection.get_orientationc             C   sL   |   ¡ }x"t|ƒD ]\}}t |¡||< qW |  |¡ |  ¡  | _d| _dS )zu
        switch the orientation of the event line, either from vertical to
        horizontal or vice versus
        TN)r  Ú	enumerater7   Zfliplrr  r  r  r—   )rA   r  r  r  rL   rL   rM   Úswitch_orientation²  s    
z"EventCollection.switch_orientationc             C   s\   |dks |  ¡ dks |  ¡ dkr&d}n|  ¡ dkr8d}ntdƒ‚||  ¡ krPdS |  ¡  dS )zž
        set the orientation of the event line
        [ 'horizontal' | 'vertical' | None ]
        defaults to 'horizontal' if not specified or None
        Nr¼   r  Tr  Fz.orientation must be 'horizontal' or 'vertical')r½   r§   r  r$  )rA   r  r  rL   rL   rM   Úset_orientation¾  s    zEventCollection.set_orientationc             C   s   | j S )zE
        get the length of the lines used to mark each event
        )r  )rA   rL   rL   rM   r  Ð  s    zEventCollection.get_linelengthc             C   sz   ||   ¡ krdS |  ¡ }|  ¡ }|  ¡ r,dnd}x4|D ],}||d  |d|f< ||d  |d|f< q6W |  |¡ || _dS )zE
        set the length of the lines used to mark each event
        Nr   r   g       @)r  r  r  r  r  r  )rA   r  r  r  r  r  rL   rL   rM   Úset_linelengthÖ  s    

zEventCollection.set_linelengthc             C   s   | j S )zE
        get the offset of the lines used to mark each event
        )r  )rA   rL   rL   rM   r  å  s    zEventCollection.get_lineoffsetc             C   sz   ||   ¡ krdS |  ¡ }|  ¡ }|  ¡ r,dnd}x4|D ],}||d  |d|f< ||d  |d|f< q6W |  |¡ || _dS )zE
        set the offset of the lines used to mark each event
        Nr   r   g       @)r  r  r  r  r  r  )rA   r  r  r  r  r  rL   rL   rM   Úset_lineoffsetë  s    

zEventCollection.set_lineoffsetc                s   t t| ƒ ¡ d S )z3Get the width of the lines used to mark each event.r   )Úsuperr  rÌ   )rA   )r€   rL   rM   rÌ   ú  s    zEventCollection.get_linewidthc                s   t t| ƒ ¡ S )N)r(  r  rÌ   )rA   )r€   rL   rM   Úget_linewidthsþ  s    zEventCollection.get_linewidthsc             C   s   |   ¡ d S )zD
        get the color of the lines used to mark each event
        r   )r  )rA   rL   rL   rM   r
    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)  r
  Ú__classcell__rL   rL   )r€   rM   r    s0         
S

r  c               @   s"   e Zd ZdZeZejdd„ ƒZdS )ÚCircleCollectionz7
    A collection of circles, drawn using splines.
    c             K   s8   t j| f|Ž |  |¡ |  t ¡ ¡ tj ¡ g| _	dS )zf
        *sizes*
            Gives the area of the circle in points^2

        %(Collection)s
        N)
r   r   rá   rø   r   rn   rg   rv   Úunit_circler@   )rA   rß   rK   rL   rL   rM   r     s    
zCircleCollection.__init__N)	r   rÓ   rÔ   rÕ   rý   rÞ   r	   rä   r   rL   rL   rL   rM   r+    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 )ÚEllipseCollectionz8
    A collection of ellipses, drawn using splines.
    Úpointsc             K   sx   t j| f|Ž dt |¡ ¡  | _dt |¡ ¡  | _t |¡ ¡ | _|| _	|  
t ¡ ¡ t d¡| _t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   r   N)r   r   r7   r©   ZravelÚ_widthsÚ_heightsZdeg2radÚ_anglesÚ_unitsrø   r   rn   rÖ   rQ   rg   rv   r,  r@   )rA   ÚwidthsÚheightsZanglesZunitsrK   rL   rL   rM   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	 
t| jƒddf¡| _| j| }| j| }t	 | j¡}t	 | 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 ¡  ¡  ¡ }	d|	dd…dd…f< |  ||	ƒ¡ dS )zB
        Calculate transforms immediately before drawing.
        rê   r   rž   rŸ   Zinchesr.  g      R@r‘   r’   Zdotsg      ð?zunrecognized units: %sr   Nr   r   )rV   râ   r2  Zbboxr‘   ZviewLimr’   rà   r§   r7   r8   rf   r/  rQ   r0  Zsinr1  Zcosr   r   rj   r`   rü   Úcopyrø   )
rA   ZaxZfigZscr3  r4  Z	sin_angleZ	cos_angleZ_affineÚmrL   rL   rM   Ú_set_transformsI  sD    











z!EllipseCollection._set_transformsc             C   s   |   ¡  t | |¡ d S )N)r7  r   r™   )rA   ro   rL   rL   rM   r™   t  s    zEllipseCollection.drawN)r.  )r   rÓ   rÔ   rÕ   r	   rä   r   r7  r   r×   r™   rL   rL   rL   rM   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|Ž |  |¡ 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   |   ¡ r|  ¡ S ddddgS )Nr   )rÐ   r‹   )ZpatchrL   rL   rM   Údetermine_facecolorœ  s    z5PatchCollection.__init__.<locals>.determine_facecolorc                s   g | ]}ˆ |ƒ‘qS rL   rL   )rZ   r[   )r9  rL   rM   r]   ¡  s    z,PatchCollection.__init__.<locals>.<listcomp>r   c             S   s   g | ]}|  ¡ ‘qS rL   )rŒ   )rZ   r[   rL   rL   rM   r]   ¢  s    r   c             S   s   g | ]}|  ¡ ‘qS rL   )rÌ   )rZ   r[   rL   rL   rM   r]   £  s    r   c             S   s   g | ]}|  ¡ ‘qS rL   )rÍ   )rZ   r[   rL   rL   rM   r]   ¤  s    r   c             S   s   g | ]}|  ¡ ‘qS rL   )Zget_antialiased)rZ   r[   rL   rL   rM   r]   ¥  s    r   N)r   r   rP   )rA   ÚpatchesZmatch_originalrK   rL   )r9  rM   r   …  s    zPatchCollection.__init__c             C   s   dd„ |D ƒ}|| _ d S )Nc             S   s   g | ]}|  ¡  | ¡ ¡‘qS rL   )r^   Ztransform_pathZget_path)rZ   r[   rL   rL   rM   r]   ¬  s   z-PatchCollection.set_paths.<locals>.<listcomp>)r@   )rA   r:  rk   rL   rL   rM   rP   «  s    zPatchCollection.set_pathsN)F)r   rÓ   rÔ   rÕ   r   rP   rL   rL   rL   rM   r8  z  s   	
&r8  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 :class:`~matplotlib.tri.Triangulation`
    object.
    c             K   s^   t j| f|Ž || _d| _d| _tj ¡ | _t	 
|j dd¡|j dd¡f¡}| j |¡ d S )NÚgouraudTré   r   )r   r   Ú_triangulationÚ_shadingr$   r   ri   ÚunitÚ_bboxr7   r   rž   ÚreshaperŸ   Úupdate_from_data_xy)rA   ZtriangulationrK   rê   rL   rL   rM   r   ¹  s    zTriMesh.__init__c             C   s   | j d kr|  ¡  | j S )N)r@   rP   )rA   rL   rL   rM   rN   Ç  s    
zTriMesh.get_pathsc             C   s   |   | j¡| _d S )N)Úconvert_mesh_to_pathsr=  r@   )rA   rL   rL   rM   rP   Ì  s    zTriMesh.set_pathsc             C   s4   |   ¡ }tj| j| | j| fdd}dd„ |D ƒS )zú
        Converts a given mesh into a sequence of
        :class:`matplotlib.path.Path` objects for easier rendering by
        backends that do not directly support meshes.

        This function is primarily of use to backend implementers.
        ré   )Úaxisc             S   s   g | ]}t  |¡‘qS rL   )rg   rv   )rZ   rž   rL   rL   rM   r]   Ú  s    z1TriMesh.convert_mesh_to_paths.<locals>.<listcomp>)Úget_masked_trianglesr7   Ústackrž   rŸ   )ÚtriÚ	trianglesrç   rL   rL   rM   rC  Ï  s    	zTriMesh.convert_mesh_to_pathsc             C   s²   |   ¡ sd S | | jj¡ |  ¡ }| j}| ¡ }tj|j	| |j
| fdd}|  ¡  | j| }| ¡ }|  |¡ | |  ¡ d ¡ | |||| ¡ ¡ | ¡  | | jj¡ d S )Nré   )rD  r   )r~   r   r€   r   r^   r=  rE  r7   rF  rž   rŸ   rƒ   rÀ   r„   r…   r,   rÌ   Údraw_gouraud_trianglesrh   r•   r–   )rA   ro   r\   rG  rH  rç   r   r˜   rL   rL   rM   r™   Ü  s    

zTriMesh.drawN)r   rÓ   rÔ   rÕ   r   rN   rP   rØ   rC  r   r×   r™   rL   rL   rL   rM   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 |t¡ |d |d df¡| _|| _	|| _
tj ¡ | _| j | |d |d  df¡¡ d S )Nr   r   )r   r   Ú
_meshWidthÚ_meshHeightr7   r©   r<   rA  Ú_coordinatesÚ_antialiasedr>  r   ri   r?  r@  rB  )rA   Ú	meshWidthÚ
meshHeightÚcoordinatesr   ZshadingrK   rL   rL   rM   r     s    
zQuadMesh.__init__c             C   s   | j d kr|  ¡  | j S )N)r@   rP   )rA   rL   rL   rM   rN   "  s    
zQuadMesh.get_pathsc             C   s    |   | j| j| j¡| _d| _d S )NT)rC  rL  rM  rN  r@   r—   )rA   rL   rL   rM   rP   '  s    zQuadMesh.set_pathsc             C   s   |   ¡ |  | j¡S )N)r^   Ztransform_bboxr@  )rA   rj   rL   rL   rM   rm   ,  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}| | | ddf¡}dd„ |D ƒS )	zþ
        Converts a given mesh into a sequence of
        :class:`matplotlib.path.Path` objects for easier rendering by
        backends that do not directly support quadmeshes.

        This function is primarily of use to backend implementers.
        Nré   r   r   )rD  r  c             S   s   g | ]}t  |¡‘qS rL   )rg   rv   )rZ   rž   rL   rL   rM   r]   D  s    z2QuadMesh.convert_mesh_to_paths.<locals>.<listcomp>)rT   r7   rb   rc   r¦   rë   rA  )rP  rQ  rR  rº   r.  rL   rL   rM   rC  /  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}
|
 || d ddf¡}
|  ¡  |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}| || 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_qouraud_triangle`.
        Nré   r   g      @r   )rD  é   r   )rT   r7   rb   rc   r¦   rë   rA  r‹   )rA   rP  rQ  rR  r[   Zp_aZp_bZp_cZp_dZp_centerrH  rº   Zc_aZc_bZc_cZc_dZc_centerr   rL   rL   rM   Úconvert_mesh_to_trianglesF  s:    z"QuadMesh.convert_mesh_to_trianglesc             C   sŠ  |   ¡ sd S | | jj|  ¡ ¡ |  ¡ }|  ¡ }| j}|  ¡ r†t	| jƒr†|  
| jd d …df ¡}|  | jd d …df ¡}t ||g¡}|  ¡  |jsÂ| j d¡}| |¡}| | jj¡}t ¡ }n| j}|jsà| |¡}| ¡ }| ¡ }|  |¡ | |  ¡ d ¡ | jdkr<|  | j| j|¡\}	}
|  ||	|
| !¡ ¡ n.| "|| !¡ | j| j||||  #¡ | j$|  %¡ ¡
 | &¡  | '| jj¡ d| _(d S )Nr   r   )ré   r   r<  F))r~   r   r€   r   r‚   r^   rX   r9   rq   rf   rs   rt   r7   rw   rƒ   r_   rN  rA  r\   r=   r   rn   ra   r`   r„   r…   r,   rÌ   r>  rT  rL  rM  rI  rh   Zdraw_quad_meshr‹   rO  Zget_edgecolorsr•   r–   r—   )rA   ro   r\   rC   rB   rz   r{   rR  r˜   rH  r   rL   rL   rM   r™   p  sH    




zQuadMesh.drawN)TrK  )r   rÓ   rÔ   rÕ   r   rN   rP   rm   rØ   rC  rT  r   r×   r™   rL   rL   rL   rM   rJ  ô  s   
*rJ  )
rJ  r;  rå   rí   ró   rã   rþ   r8  r+  r   )r   )0rÕ   rµ   Znumbersr   r‰   Znumpyr7   Z
matplotlibr'   Ú r   r   r   r   r   r%   r	   r
   r«   r   rg   r   rÝ   Zpirý   Z_define_aliasesr   r   r   Zinterpdr?   rÙ   rã   rå   rí   ró   rþ   rÿ   r   r  r+  r-  r8  r;  rJ  ZkwdocZpatchstrÚkrL   rL   rL   rM   Ú<module>
   sV   ,      1C/A A x^7C -

