o
    îÇhmy ã                	   @   sÎ  d Z ddlZddlZddlZddlmZ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mZmZ ddlmZmZ e  ddgd	d
gddgg d¢ddgdgdœ¡G dd„ dej!ƒƒ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/G d.d/„ d/ƒZ0G d0d1„ d1e0e"ƒZ1G d2d3„ d3e0e%ƒZ2d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ÚRealé   )Ú_apiÚ_pathÚartistÚcbookÚ	colorizerÚcolorsÚ
_docstringÚhatchÚlinesÚpathÚ
transforms)Ú	JoinStyleÚCapStyleÚantialiasedsÚaaÚ
edgecolorsÚecÚ
facecolorsÚfc)Ú
linestylesÚdashesÚlsÚ
linewidthsÚlwÚtransOffset)ÚantialiasedÚ	edgecolorÚ	facecolorÚ	linestyleÚ	linewidthÚoffset_transformc                       s   e Zd ZdZe d¡ZdZej	dddddddddddddddddœ‡ fd	d
„
ƒZ
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdid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#ej	d9d:„ ƒZ$ej	d;d<„ ƒZ%ej	d=d>„ ƒZ&ej	d?d@„ ƒZ'e(dAdB„ ƒZ)dCdD„ Z*dEdF„ Z+dGdH„ Z,dIdJ„ Z-dKdL„ Z.dMdN„ Z/dOdP„ Z0dQdR„ Z1dSdT„ Z2dUdV„ Z3dWdX„ Z4dYdZ„ Z5d[d\„ Z6ej7j8je6_d]d^„ Z9d_d`„ Z:dadb„ Z;dcdd„ Z<dedf„ Z=dgdh„ Z>‡  Z?S )jÚ
CollectionaÅ  
    Base class for Collections. Must be subclassed to be usable.

    A Collection represents a sequence of `.Patch`\es that can be drawn
    more efficiently together than individually. For example, when a single
    path is being drawn repeatedly at different offsets, the renderer can
    typically execute a ``draw_marker()`` call much more efficiently than a
    series of repeated calls to ``draw_path()`` with the offsets put in
    one-by-one.

    Most properties of a collection can be configured per-element. Therefore,
    Collections have "plural" versions of many of the properties of a `.Patch`
    (e.g. `.Collection.get_paths` instead of `.Patch.get_path`). Exceptions are
    the *zorder*, *hatch*, *pickradius*, *capstyle* and *joinstyle* properties,
    which can only be set globally for the whole collection.

    Besides these exceptions, all properties can be specified as single values
    (applying to all elements) or sequences of values. The property of the
    ``i``\th element of the collection is::

      prop[i % len(prop)]

    Each Collection can optionally be used as its own `.ScalarMappable` by
    passing the *norm* and *cmap* parameters to its constructor. If the
    Collection's `.ScalarMappable` matrix ``_A`` has been set (via a call
    to `.Collection.set_array`), then at draw time this internal scalar
    mappable will be used to set the ``facecolors`` and ``edgecolors``,
    ignoring those that were manually passed in.
    ©r   é   r&   FNÚsolidg      @r   )r   r   r   r   ÚcapstyleÚ	joinstyler   Úoffsetsr#   ÚnormÚcmapr	   Ú
pickradiusr   ÚurlsÚzorderc                   sF  t ƒ  |  ||
|¡¡ dg| _dg| _dg| _dg| _d| _d| _d| _	d| _
t tjd ¡| _tjd | _|  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |rk|  |¡ nd| _|rv|  |¡ nd| _|durt |t ¡}|j!dkr|ddd…f }|| _"|	| _#d| _$|  %|¡ d| _&dS )aË  
        Parameters
        ----------
        edgecolors : :mpltype:`color` or list of colors, default: :rc:`patch.edgecolor`
            Edge color for each patch making up the collection. The special
            value 'face' can be passed to make the edgecolor match the
            facecolor.
        facecolors : :mpltype:`color` or list of colors, default: :rc:`patch.facecolor`
            Face color for each patch making up the collection.
        linewidths : float or list of floats, default: :rc:`patch.linewidth`
            Line width for each patch making up the collection.
        linestyles : str or tuple or list thereof, 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 lengths
            in points. For examples, see
            :doc:`/gallery/lines_bars_and_markers/linestyles`.
        capstyle : `.CapStyle`-like, default: 'butt'
            Style to use for capping lines for all paths in the collection.
            Allowed values are %(CapStyle)s.
        joinstyle : `.JoinStyle`-like, default: 'round'
            Style to use for joining lines for all paths in the collection.
            Allowed values are %(JoinStyle)s.
        antialiaseds : bool or list of bool, default: :rc:`patch.antialiased`
            Whether each patch in the collection should be drawn with
            antialiasing.
        offsets : (float, float) or list thereof, default: (0, 0)
            A vector by which to translate each patch after rendering (default
            is no translation). The translation is performed in screen (pixel)
            coordinates (i.e. after the Artist's transform is applied).
        offset_transform : `~.Transform`, default: `.IdentityTransform`
            A single transform which will be applied to each *offsets* vector
            before it is used.
        cmap, norm
            Data normalization and colormapping parameters. See
            `.ScalarMappable` for a detailed description.
        hatch : str, optional
            Hatching pattern to use in filled paths, if any. Valid strings are
            ['/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See
            :doc:`/gallery/shapes_and_collections/hatch_style_reference` for
            the meaning of each hatch type.
        pickradius : float, default: 5.0
            If ``pickradius <= 0``, then `.Collection.contains` will return
            ``True`` whenever the test point is inside of one of the polygons
            formed by the control points of a Path in the Collection. On the
            other hand, if it is greater than 0, then we instead check if the
            test point is contained in a stroke of width ``2*pickradius``
            following any of the Paths in the Collection.
        urls : list of str, default: None
            A URL for each patch to link to once drawn. Currently only works
            for the SVG backend. See :doc:`/gallery/misc/hyperlinks_sgskip` for
            examples.
        zorder : float, default: 1
            The drawing order, shared by all Patches in the Collection. See
            :doc:`/gallery/misc/zorder_demo` for all defaults and examples.
        **kwargs
            Remaining keyword arguments will be used to set properties as
            ``Collection.set_{key}(val)`` for each key-value pair in *kwargs*.
        ©r   Nr   Nzhatch.colorzhatch.linewidth©é   )'ÚsuperÚ__init__Ú_get_colorizerÚ_us_linestylesÚ_linestylesÚ_us_lwÚ_linewidthsÚ	_gapcolorÚ_face_is_mappedÚ_edge_is_mappedÚ_mapped_colorsÚmcolorsÚto_rgbaÚmplÚrcParamsÚ_hatch_colorÚ_hatch_linewidthÚset_facecolorÚset_edgecolorÚset_linewidthÚset_linestyleÚset_antialiasedÚset_pickradiusÚset_urlsÚ	set_hatchÚ
set_zorderÚset_capstyleÚ	_capstyleÚset_joinstyleÚ
_joinstyleÚnpÚ
asanyarrayÚfloatÚshapeÚ_offsetsÚ_offset_transformÚ_path_effectsÚ_internal_updateÚ_paths)Úselfr   r   r   r   r(   r)   r   r*   r#   r+   r,   r	   r-   r   r.   r/   Úkwargs©Ú	__class__© új/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/matplotlib/collections.pyr4   N   sF   S











zCollection.__init__c                 C   ó   | j S ©N©rY   ©rZ   r^   r^   r_   Ú	get_pathsÔ   ó   zCollection.get_pathsc                 C   s   || _ d| _d S ©NT©rY   Ústale)rZ   Úpathsr^   r^   r_   Ú	set_paths×   s   
zCollection.set_pathsc                 C   r`   ra   )Ú_transformsrc   r^   r^   r_   Úget_transformsÛ   re   zCollection.get_transformsc                 C   sJ   | j du rt ¡ | _ | j S t| j tjƒs"t| j dƒr"| j  | j¡| _ | j S )z<Return the `.Transform` instance used by this artist offset.NÚ_as_mpl_transform)rV   r   ÚIdentityTransformÚ
isinstanceÚ	TransformÚhasattrrm   Úaxesrc   r^   r^   r_   Úget_offset_transformÞ   s   

ü
ÿÿzCollection.get_offset_transformc                 C   ó
   || _ dS )z
        Set the artist offset transform.

        Parameters
        ----------
        offset_transform : `.Transform`
        N)rV   )rZ   r#   r^   r^   r_   Úset_offset_transformè   s   
zCollection.set_offset_transformc                    s  |   ¡ ‰ |  ¡ }t|tjƒs| |¡stj ¡ S |  ¡ }t	|ƒs%tj ¡ S ˆ j
s1‡ fdd„|D ƒ}|  ¡ }tˆ  |¡ƒr_t|tjjƒrI| tj¡}t ˆ  ¡ | ||  ¡ | |¡| ¡  ¡ ¡S | jd ur‚||  |¡}tj |¡}|j ¡ s‚tj ¡ }| |¡ |S tj ¡ S )Nc                    ó   g | ]}ˆ   |¡‘qS r^   ©Útransform_path_non_affine©Ú.0Úp©Ú	transformr^   r_   Ú
<listcomp>  ó    z*Collection.get_datalim.<locals>.<listcomp>)Úget_transformrs   ro   r   rn   Úcontains_branchÚBboxÚnullrd   ÚlenÚ	is_affineÚget_offsetsÚanyÚcontains_branch_seperatelyrQ   ÚmaÚMaskedArrayÚfilledÚnanÚmpathÚget_path_collection_extentsÚ
get_affinerl   Útransform_non_affineÚfrozenrU   r}   Úmasked_invalidÚmaskÚallÚupdate_from_data_xy)rZ   Ú	transDataÚ
offset_trfri   r*   Úbboxr^   r|   r_   Úget_datalimò   s:   ÿ


ü




zCollection.get_datalimc                 C   s   |   t ¡ ¡S ra   )r™   r   rn   ©rZ   Úrendererr^   r^   r_   Úget_window_extent7  s   zCollection.get_window_extentc              	      s.  |   ¡ ‰ |  ¡ }|  ¡ }|  ¡ }|  ¡ rhg }|  ¡ D ]/}|j}|d d …df |d d …df }}|  |¡}|  |¡}| t	 
t ||g¡|j¡¡ q|  |d d …df ¡}|  |d d …df ¡}tj ||g¡}ˆ jsx‡ fdd„|D ƒ}ˆ  ¡ ‰ |js„| |¡}| ¡ }t|tjjƒr‘| tj¡}ˆ |||fS )Nr   r   c                    rv   r^   rw   )rz   r   r|   r^   r_   r~   Q  s    ÿz.Collection._prepare_points.<locals>.<listcomp>)r€   rs   r†   rd   Ú
have_unitsÚverticesÚconvert_xunitsÚconvert_yunitsÚappendr   ÚPathrQ   Úcolumn_stackÚcodesr‰   r…   r   r   ro   rŠ   r‹   rŒ   )rZ   r—   r*   ri   r   rž   ÚxsÚysr^   r|   r_   Ú_prepare_points<  s4   "

 
ÿ
zCollection._prepare_pointsc                 C   s  |   ¡ sd S | | jj|  ¡ ¡ |  ¡  |  ¡ \}}}}| ¡ }|  |¡ | 	|  
¡ ¡ | jrA| | j¡ | | j¡ | | j¡ |  ¡ d urN|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Ùtdd„ | jD ƒƒrÙt| jƒdkrÙt| jƒdkrÙ|  ¡ d u rÙt|ƒr¸t  !|d ¡| }n|}|d  "|¡}|j#| j$ddj%j#k rÙ|j&| j$ddj%j&k rÙd}| j'râ| (| j'¡ | j)rë| *| j)¡ |r-| +t,|
d ƒ¡ | -| jd ¡ |j.| jd Ž  | /| jd ¡ | 0| jd ¡ | 1||d | 2¡ t3 4|¡|t,|	d ƒ¡ nF| j5d urV|  6¡ \}}| 7|| 2¡ ||  ¡ ||t8 9d	¡g| j5| j|| j| jd
¡ | 7|| 2¡ ||  ¡ |||  ¡ |  ¡ | j| j| j| jd
¡ | :¡  | ;| jj¡ d| _<d S )Nr   )ÚPathEffectRendererFr   c                 s   s    | ]	}|d  du V  qdS )r   Nr^   )rz   r   r^   r^   r_   Ú	<genexpr>‡  ó   € z"Collection.draw.<locals>.<genexpr>T©ÚrootÚnoneÚscreen)=Úget_visibleÚ
open_groupr]   Ú__name__Úget_gidÚupdate_scalarmappabler§   Únew_gcÚ_set_gc_clipÚset_snapÚget_snapÚ_hatchrK   Úset_hatch_colorrB   Úset_hatch_linewidthrC   Úget_sketch_paramsÚset_sketch_paramsÚget_path_effectsÚmatplotlib.patheffectsr¨   rl   Úget_facecolorÚget_edgecolorr„   r9   r”   r7   Ú_antialiasedsÚ_urlsÚ	get_hatchr   ÚAffine2DÚget_extentsÚwidthÚ
get_figurer˜   ÚheightrP   rO   rN   rM   Úset_foregroundÚtuplerF   Ú
set_dashesrH   Úset_urlÚdraw_markersr‘   r   r¢   r:   Ú_get_inverse_paths_linestylesÚdraw_path_collectionr>   r?   ÚrestoreÚclose_grouprh   )rZ   r›   r}   r—   r*   ri   Úgcr¨   Útransr   r   Údo_single_path_optimizationÚcombined_transformÚextentsÚipathsÚilinestylesr^   r^   r_   Údraw`  sŒ   
ÿþ

ú

ú
zCollection.drawc                 C   s"   t |tƒstd|›ƒ‚|| _dS )z§
        Set the pick radius used for containment tests.

        Parameters
        ----------
        pickradius : float
            Pick radius, in points.
        z-pickradius must be a real-valued number, not N)ro   r   Ú
ValueErrorÚ_pickradius)rZ   r-   r^   r^   r_   rI   º  s
   
	ÿ
zCollection.set_pickradiusc                 C   r`   ra   )rÛ   rc   r^   r^   r_   Úget_pickradiusÈ  re   zCollection.get_pickradiusc                 C   s    |   |¡s	|  ¡ sdi fS t| jtƒr| jdurt| jƒn| j}| jr(| j ¡  |  	¡ \}}}}t
 |j|j|| ¡ ||  ¡ |||dk¡	}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.
        FTr   )Úind)Ú_different_canvasr¯   ro   Ú_pickerr   rS   rÛ   rr   Ú_unstale_viewLimr§   r   Úpoint_in_path_collectionÚxÚyr‘   rl   r„   Údict)rZ   Ú
mouseeventr-   r}   r—   r*   ri   rÝ   r^   r^   r_   ÚcontainsË  s"   
ÿ

þü


ýzCollection.containsc                 C   s   |dur|ndg| _ d| _dS )zß
        Parameters
        ----------
        urls : list of str or None

        Notes
        -----
        URLs are currently only implemented by the SVG backend. They are
        ignored by all other backends.
        NT)rÂ   rh   )rZ   r.   r^   r^   r_   rJ   ç  s   
zCollection.set_urlsc                 C   r`   )zÑ
        Return a list of URLs, one for each element of the collection.

        The list contains *None* for elements without a URL. See
        :doc:`/gallery/misc/hyperlinks_sgskip` for an example.
        )rÂ   rc   r^   r^   r_   Úget_urlsõ  s   zCollection.get_urlsc                 C   s   t  |¡ || _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.

        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)ÚmhatchÚ_validate_hatch_patternr¸   rh   )rZ   r   r^   r^   r_   rK   þ  s   

zCollection.set_hatchc                 C   r`   )z$Return the current hatching pattern.)r¸   rc   r^   r^   r_   rÃ      ó   zCollection.get_hatchc                 C   rt   )zSet the hatch linewidth.N©rC   ©rZ   r   r^   r^   r_   rº   $  ó   
zCollection.set_hatch_linewidthc                 C   r`   )zReturn the hatch linewidth.rë   rc   r^   r^   r_   Úget_hatch_linewidth(  rê   zCollection.get_hatch_linewidthc              	   C   sŒ   t  |¡}|jdkr|ddd…f }t|t jjƒrt jjnt j}|t  |  |dd…df ¡t¡t  |  	|dd…df ¡t¡fƒ| _
d| _dS )zˆ
        Set the offsets for the collection.

        Parameters
        ----------
        offsets : (N, 2) or (2,) array-like
        r1   Nr   r   T)rQ   rR   rT   ro   r‰   rŠ   r£   rŸ   rS   r    rU   rh   )rZ   r*   Úcstackr^   r^   r_   Úset_offsets,  s   

ÿÿÿ
zCollection.set_offsetsc                 C   s   | j du r
t d¡S | j S )z&Return the offsets for the collection.N©r   r2   )rU   rQ   Úzerosrc   r^   r^   r_   r†   >  s   zCollection.get_offsetsc                 C   ó
   t jd S )Nzpatch.linewidth©r@   rA   rc   r^   r^   r_   Ú_get_default_linewidthC  rí   z!Collection._get_default_linewidthc                 C   s>   |du r|   ¡ }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 list of floats
        NT)	rõ   rQ   Ú
atleast_1dr8   Ú_bcast_lwlsr6   r9   r7   rh   rì   r^   r^   r_   rF   G  s   
ÿ
zCollection.set_linewidthc                 C   sˆ   zt  |¡g}W n* ty2   z	dd„ |D ƒ}W n ty/ } zd|›d}t|ƒ|‚d}~ww Y nw || _|  | 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 : str or tuple or list thereof
            Valid values for individual linestyles include {'-', '--', '-.',
            ':', '', (offset, on-off-seq)}. See `.Line2D.set_linestyle` for a
            complete description.
        c                 S   ó   g | ]}t  |¡‘qS r^   )ÚmlinesÚ_get_dash_pattern©rz   râ   r^   r^   r_   r~   y  r   z,Collection.set_linestyle.<locals>.<listcomp>zDo not know how to convert z
 to dashesN)rù   rú   rÚ   r6   r÷   r8   r9   r7   )rZ   r   r   ÚerrÚemsgr^   r^   r_   rG   [  s    
€þÿþÿzCollection.set_linestylec                 C   ó   t |ƒ| _dS )z 
        Set the `.CapStyle` for the collection (for all its elements).

        Parameters
        ----------
        cs : `.CapStyle` or %(CapStyle)s
        N)r   rN   )rZ   Úcsr^   r^   r_   rM   …  ó   	zCollection.set_capstylec                 C   ó   | j r| j jS dS )z
        Return the cap style for the collection (for all its elements).

        Returns
        -------
        %(CapStyle)s or None
        N)rN   Únamerc   r^   r^   r_   Úget_capstyle  ó   	zCollection.get_capstylec                 C   rþ   )z£
        Set the `.JoinStyle` for the collection (for all its elements).

        Parameters
        ----------
        js : `.JoinStyle` or %(JoinStyle)s
        N)r   rP   )rZ   Újsr^   r^   r_   rO   ›  r   zCollection.set_joinstylec                 C   r  )z‘
        Return the join style for the collection (for all its elements).

        Returns
        -------
        %(JoinStyle)s or None
        N)rP   r  rc   r^   r^   r_   Úget_joinstyle¦  r  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 r^   )rù   Ú_scale_dashes)rz   ÚoÚdr   r^   r^   r_   r~   Ò  s    
ÿz*Collection._bcast_lwls.<locals>.<listcomp>)r@   rA   r„   ÚmathÚgcdÚlistÚzip)r   r   Úl_dashesÚl_lwr  r^   r^   r_   r÷   ±  s   
ÿzCollection._bcast_lwlsc                 C   r`   )zs
        Get the antialiasing state for rendering.

        Returns
        -------
        array of bools
        )rÁ   rc   r^   r^   r_   Úget_antialiased×  ó   zCollection.get_antialiasedc                 C   s.   |du r|   ¡ }t t |t¡¡| _d| _dS )z…
        Set the antialiasing state for rendering.

        Parameters
        ----------
        aa : bool or list of bools
        NT)Ú_get_default_antialiasedrQ   rö   ÚasarrayÚboolrÁ   rh   )rZ   r   r^   r^   r_   rH   á  s   
zCollection.set_antialiasedc                 C   ró   )Nzpatch.antialiasedrô   rc   r^   r^   r_   r  î  rí   z#Collection._get_default_antialiasedc                 C   s   |   |¡ |  |¡ dS )a1  
        Set both the edgecolor and the facecolor.

        Parameters
        ----------
        c : :mpltype:`color` or list of RGBA tuples

        See Also
        --------
        Collection.set_facecolor, Collection.set_edgecolor
            For setting the edge or face color individually.
        N)rD   rE   ©rZ   Úcr^   r^   r_   Ú	set_colorò  s   
zCollection.set_colorc                 C   ró   )Nzpatch.facecolorrô   rc   r^   r^   r_   Ú_get_default_facecolor  rí   z!Collection._get_default_facecolorc                 C   s*   |d u r|   ¡ }t || j¡| _d| _d S rf   )r  r>   Úto_rgba_arrayÚ_alphaÚ_facecolorsrh   r  r^   r^   r_   Ú_set_facecolor  s   
zCollection._set_facecolorc                 C   ó2   t |tƒr| ¡ dv r| ¡ }|| _|  |¡ dS )an  
        Set the facecolor(s) of the collection. *c* can be a color (all patches
        have same color), or a sequence of colors; if it is a sequence the
        patches will cycle through the sequence.

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

        Parameters
        ----------
        c : :mpltype:`color` or list of :mpltype:`color`
        ©r­   ÚfaceN)ro   ÚstrÚlowerÚ_original_facecolorr  r  r^   r^   r_   rD     s   zCollection.set_facecolorc                 C   r`   ra   )r  rc   r^   r^   r_   r¿     re   zCollection.get_facecolorc                 C   s   t  | jd¡r|  ¡ S | jS )Nr  )r   Ú
_str_equalÚ_edgecolorsr¿   rc   r^   r^   r_   rÀ   !  s   zCollection.get_edgecolorc                 C   ró   )Nzpatch.edgecolorrô   rc   r^   r^   r_   Ú_get_default_edgecolor'  rí   z!Collection._get_default_edgecolorc                 C   s   d}|d u rt jd s| jst | jd¡r|  ¡ }nd}d}t |d¡r,d| _d| _	d S t
 || j¡| _|rCt| jƒrCt| jd ƒ| _d| _	d S )NTzpatch.force_edgecolorr­   Fr  r   )r@   rA   Ú_edge_defaultr   r#  r"  r%  Ú_str_lower_equalr$  rh   r>   r  r  r„   rÊ   rB   )rZ   r  r¹   r^   r^   r_   Ú_set_edgecolor+  s$   
ÿþ

zCollection._set_edgecolorc                 C   r  )a'  
        Set the edgecolor(s) of the collection.

        Parameters
        ----------
        c : :mpltype:`color` or list of :mpltype:`color` or 'face'
            The collection edgecolor(s).  If a sequence, the patches cycle
            through it.  If 'face', match the facecolor.
        r  N)ro   r   r!  Ú_original_edgecolorr(  r  r^   r^   r_   rE   >  s   zCollection.set_edgecolorc                 C   s*   t j | |¡ |  | j¡ |  | j¡ dS )a„  
        Set the transparency of the collection.

        Parameters
        ----------
        alpha : float or array of float or None
            If not None, *alpha* values must be between 0 and 1, inclusive.
            If an array is provided, its length must match the number of
            elements in the collection.  Masked values and nans are not
            supported.
        N)r   ÚArtistÚ_set_alpha_for_arrayr  r"  r(  r)  ©rZ   Úalphar^   r^   r_   Ú	set_alphaP  s   zCollection.set_alphac                 C   r`   ra   )r9   rc   r^   r^   r_   Úget_linewidthb  re   zCollection.get_linewidthc                 C   r`   ra   )r7   rc   r^   r^   r_   Úget_linestylee  re   zCollection.get_linestylec                 C   s”   | j }| j}d| _ d| _| jdur.t | jd¡s&d| _t | jd¡r%d| _ n| jdu r.d| _ | jp3| j }|du pE|du pE| j |kpE| j|k}|pI|S )aF  
        Determine whether edges and/or faces are color-mapped.

        This is a helper for update_scalarmappable.
        It sets Boolean flags '_edge_is_mapped' and '_face_is_mapped'.

        Returns
        -------
        mapping_change : bool
            True if either flag is True, or if a flag has changed.
        FNr­   Tr  )r<   r;   Ú_Ar   r#  r"  r)  )rZ   Úedge0Úface0ÚmappedÚchangedr^   r^   r_   Ú_set_mappable_flagsh  s&   
€
ÿþzCollection._set_mappable_flagsc                 C   sÔ   |   ¡ sdS | jdurI| jjdkrt| tƒstdƒ‚t | j¡r@| jj	| jj	kr7td| jj
› d| jj
› dƒ‚| j | jj
¡| _|  | j| j¡| _| jrQ| j| _n|  | j¡ | jr_| j| _n|  | j¡ d| _dS )zÂ
        Update colors from the scalar mappable array, if any.

        Assign colors to edges and faces based on the array and/or
        colors that were directly set, as appropriate.
        Nr   z&Collections can only map rank 1 arrayszData array shape, z) is incompatible with alpha array shape, z†. This can occur with the deprecated behavior of the "flat" shading option, in which a row and/or column of the data array is dropped.T)r6  r1  Úndimro   Ú	_MeshDatarÚ   rQ   Úiterabler  ÚsizerT   Úreshaper?   r=   r;   r  r  r"  r<   r$  r(  r)  rh   rc   r^   r^   r_   r³   Š  s*   
þÿ	


z Collection.update_scalarmappablec                 C   s   t  | jd¡ S )zReturn whether face is colored.r­   )r   r'  r"  rc   r^   r^   r_   Ú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| _|j| _|j| _d| _dS )z#Copy properties from other to self.TN)r   r*  Úupdate_fromrÁ   r=   r<   r)  r$  r;   r"  r  r9   r7   r6   rÛ   r¸   r1  r+   r,   rh   )rZ   Úotherr^   r^   r_   r=  ´  s$   
zCollection.update_fromra   )@r±   Ú
__module__Ú__qualname__Ú__doc__rQ   Úemptyrk   r&  r   Úinterpdr4   rd   rj   rl   rs   ru   r™   rœ   r§   r   Úallow_rasterizationrÙ   rI   rÜ   ræ   rJ   rç   rK   rÃ   rº   rî   rð   r†   rõ   rF   rG   rM   r  rO   r  Ústaticmethodr÷   r  rH   r  r  r  r  rD   r¿   rÀ   r%  r(  rE   r.  r*  r+  r/  r0  r6  r³   r<  r=  Ú__classcell__r^   r^   r\   r_   r$      sš    	
#ð 


E$
Y	"*








%
"&r$   c                       s<   e Zd ZdZdZdd„ Zd
dd„Zej‡ fdd	„ƒZ	‡  Z
S )Ú_CollectionWithSizeszA
    Base class for collections that have an array of sizes.
    ç      ð?c                 C   r`   )z¦
        Return the sizes ('areas') of the elements in the collection.

        Returns
        -------
        array
            The 'area' of each element.
        )Ú_sizesrc   r^   r^   r_   Ú	get_sizesÓ  s   	z_CollectionWithSizes.get_sizesç      R@c                 C   s¦   |du rt  g ¡| _t  d¡| _n=t  |¡| _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 )
aI  
        Set the sizes of each member of the collection.

        Parameters
        ----------
        sizes : `numpy.ndarray` or None
            The size to set for each element of the collection.  The
            value is the 'area' of the element.
        dpi : float, default: 72
            The dpi of the canvas.
        Nr%   r&   rK  r   r   rH  r2   T)rQ   ÚarrayrI  rB  rk   r  rò   r„   ÚsqrtÚ_factorrh   )rZ   ÚsizesÚdpiÚscaler^   r^   r_   Ú	set_sizesÞ  s   
z_CollectionWithSizes.set_sizesc                    s(   |   | j| jddj¡ tƒ  |¡ d S )NTr«   )rR  rI  rÇ   rP  r3   rÙ   rš   r\   r^   r_   rÙ   ö  s   z_CollectionWithSizes.draw)rK  )r±   r?  r@  rA  rN  rJ  rR  r   rD  rÙ   rF  r^   r^   r\   r_   rG  Í  s    
rG  c                       s@   e Zd ZdZd‡ fdd„	Zdd„ Zdddd	d
„ fdd„Z‡  ZS )ÚPathCollectionzO
    A collection of `~.path.Path`\s, as created by e.g. `~.Axes.scatter`.
    Nc                    s0   t ƒ jdi |¤Ž |  |¡ |  |¡ d| _dS )a›  
        Parameters
        ----------
        paths : list of `.path.Path`
            The paths that will make up the `.Collection`.
        sizes : array-like
            The factor by which to scale each drawn `~.path.Path`. One unit
            squared in the Path's data space is scaled to be ``sizes**2``
            points when rendered.
        **kwargs
            Forwarded to `.Collection`.
        TNr^   )r3   r4   rj   rR  rh   )rZ   ri   rO  r[   r\   r^   r_   r4     s   


zPathCollection.__init__c                 C   r`   ra   rb   rc   r^   r^   r_   rd     re   zPathCollection.get_pathsr
   Úautoc                 C   s   | S ra   r^   )râ   r^   r^   r_   Ú<lambda>  s    zPathCollection.<lambda>c                 K   sî  g }g }|   ¡ du}|du rtjjddd}nt|tƒr"tj |¡}| ¡  |dkrF|s5t 	d¡ ||fS t
 |   ¡ ¡}	| dtjd ¡}
n|d	krXt
 |  ¡ ¡}	| d
d¡}ntd|› dƒ‚||	ƒ}|j | ¡ | ¡ ¡ |j | ¡ | ¡ ¡ |dkrˆd}t|	ƒ|krˆd}|du r“|	}||ƒ}ny|dkrœ|   ¡ }n|d	kr¤|  ¡ }t|tjjƒr®|}nt
 |¡rºtj |¡}nt|ƒ}tjj||d g d¢d}| ||ƒ ¡ ||ƒ ¡ ¡}|||ƒ ¡ k|||ƒ ¡ k@ }|| }t
 | ¡ | ¡ d¡}||ƒ}t
 |¡}t
 ||| || ¡}|  ¡ d |   ¡ dœ|¥}t!||ƒD ]T\}}|dkr0|  "|  #|¡¡}n|d	krCt
 $|¡}
t
 %|
d¡rCqt&j'dgdgfd||
|  (¡ d dœ|¤Ž}| )|¡ t*|dƒrh| +|¡ ||ƒ}| )|¡ q||fS )a  
        Create legend handles and labels for a PathCollection.

        Each legend handle is a `.Line2D` representing the Path that was drawn,
        and each label is a string that represents the Path.

        This is useful for obtaining a legend for a `~.Axes.scatter` plot;
        e.g.::

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

        creates three legend elements, one for each color with the numerical
        values passed to *c* as the labels.

        Also see the :ref:`automatedlegendcreation` example.

        Parameters
        ----------
        prop : {"colors", "sizes"}, default: "colors"
            If "colors", the legend handles will show the different colors of
            the collection. If "sizes", the legend will show the different
            sizes. To set both, use *kwargs* to directly edit the `.Line2D`
            properties.
        num : int, None, "auto" (default), array-like, or `~.ticker.Locator`
            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 : str, `~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 `~.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 = lambda
            x: 10**x``.
        **kwargs
            Allowed keyword arguments 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
        -------
        handles : list of `.Line2D`
            Visual representation of each element of the legend.
        labels : list of str
            The string labels for elements of the legend.
        NFT)Ú	useOffsetÚuseMathTextr
   zfCollection without array used. Make sure to specify the values to be colormapped via the `c` argument.r:  zlines.markersizerO  ÚcolorÚkz?Valid values for `prop` are 'colors' or 'sizes'. You supplied 'z
' instead.rT  é	   r   )r   r2   g      @r&   é   é   é   é
   )ÚnbinsÚmin_n_ticksÚstepsé   r   )Úmarkeredgewidthr-  g        Ú )r   rX  ÚmsÚmarkerÚset_locs),Ú	get_arrayr@   ÚtickerÚScalarFormatterro   r   ÚStrMethodFormatterÚcreate_dummy_axisÚwarningsÚwarnrQ   ÚuniqueÚpoprA   rJ  rÚ   ÚaxisÚset_view_intervalÚminÚmaxÚset_data_intervalr„   ÚLocatorr9  ÚFixedLocatorÚintÚMaxNLocatorÚtick_valuesÚlinspaceÚargsortÚinterpÚget_linewidthsÚ	get_alphar  r,   r+   rM  Úiscloserù   ÚLine2Drd   r¡   rq   rg  )rZ   ÚpropÚnumÚfmtÚfuncr[   ÚhandlesÚlabelsÚhasarrayÚur:  rX  ÚfuÚvaluesÚlabel_valuesÚarrÚlocÚcondÚyarrÚxarrÚixÚkwÚvalÚlabÚhÚlr^   r^   r_   Úlegend_elements  s”   ?


ÿ


ÿÿ

ÿþ



ÿÿ

zPathCollection.legend_elementsra   )r±   r?  r@  rA  r4   rd   r˜  rF  r^   r^   r\   r_   rS  ü  s    ÿrS  c                       s:   e Zd Zd
ddœ‡ fdd„Zddd„ZeZdd	„ Z‡  ZS )ÚPolyCollectionNT)Úclosedc                   s2   t ƒ jdi |¤Ž |  |¡ |  ||¡ d| _dS )aA  
        Parameters
        ----------
        verts : list of array-like
            The sequence of polygons [*verts0*, *verts1*, ...] where each
            element *verts_i* defines the vertices of polygon *i* as a 2D
            array-like of shape (M, 2).
        sizes : array-like, default: None
            Squared scaling factors for the polygons. The coordinates of each
            polygon *verts_i* are multiplied by the square-root of the
            corresponding entry in *sizes* (i.e., *sizes* specify the scaling
            of areas). The scaling is applied before the Artist master
            transform.
        closed : bool, default: True
            Whether the polygon should be closed by adding a CLOSEPOLY
            connection at the end.
        **kwargs
            Forwarded to `.Collection`.
        TNr^   )r3   r4   rR  Ú	set_vertsrh   )rZ   ÚvertsrO  rš  r[   r\   r^   r_   r4   ¦  s   

zPolyCollection.__init__c                    s  d| _ t|tjjƒr| t¡ tj¡}|sdd„ |D ƒ| _	dS t|tj
ƒrit|jƒdkritj||dd…dd…f fdd}tj|jd tjjd‰ tjjˆ dd…< tjjˆ d	< tjjˆ d
< ‡ fdd„|D ƒ| _	dS g | _	|D ]}t|ƒr| j	 tj |¡¡ qn| j	 t |¡¡ qndS )aÈ  
        Set the vertices of the polygons.

        Parameters
        ----------
        verts : list of array-like
            The sequence of polygons [*verts0*, *verts1*, ...] where each
            element *verts_i* defines the vertices of polygon *i* as a 2D
            array-like of shape (M, 2).
        closed : bool, default: True
            Whether the polygon should be closed by adding a CLOSEPOLY
            connection at the end.
        Tc                 S   rø   r^   ©r   r¢   ©rz   Úxyr^   r^   r_   r~   Ó  r   z,PolyCollection.set_verts.<locals>.<listcomp>Nr&   r   ©rq  ©Údtyper   éÿÿÿÿc                    s   g | ]}t  |ˆ ¡‘qS r^   r  rž  ©r¤   r^   r_   r~   ß  ó    )rh   ro   rQ   r‰   rŠ   ÚastyperS   r‹   rŒ   rY   Úndarrayr„   rT   ÚconcatenaterB  r   r¢   Ú	code_typeÚLINETOÚMOVETOÚ	CLOSEPOLYr¡   Ú_create_closed)rZ   rœ  rš  Ú	verts_padrŸ  r^   r¤  r_   r›  ¿  s(   "üzPolyCollection.set_vertsc                 C   s8   t |ƒt |ƒkrtdƒ‚dd„ t||ƒD ƒ| _d| _dS )z$Initialize vertices with path codes.zB'codes' must be a 1D list or array with the same length of 'verts'c                 S   s.   g | ]\}}t |ƒrt ||¡nt |¡‘qS r^   )r„   r   r¢   )rz   rŸ  Úcdsr^   r^   r_   r~   ð  s    "ÿz6PolyCollection.set_verts_and_codes.<locals>.<listcomp>TN)r„   rÚ   r  rY   rh   )rZ   rœ  r¤   r^   r^   r_   Úset_verts_and_codesë  s   ÿ
z"PolyCollection.set_verts_and_codesra   )T)r±   r?  r@  r4   r›  rj   r°  rF  r^   r^   r\   r_   r™  ¤  s
    
*r™  c                       sœ   e Zd ZdZddddœ‡ fdd„
Zedd„ ƒZed	d
„ ƒZddœdd„Z	dd„ Z
dd„ Zdd„ Zedd„ ƒZdd„ Zedd„ ƒZedd„ ƒZdd„ Z‡  ZS )ÚFillBetweenPolyCollectionzK
    `.PolyCollection` that fills the area between two x- or y-curves.
    NF)ÚwhereÚinterpolateÚstepc          
         s:   || _ || _|| _|  ||||¡}	tƒ j|	fi |¤Ž dS )aY
  
        Parameters
        ----------
        t_direction : {{'x', 'y'}}
            The axes on which the variable lies.

            - 'x': the curves are ``(t, f1)`` and ``(t, f2)``.
            - 'y': the curves are ``(f1, t)`` and ``(f2, t)``.

        t : array-like
            The ``t_direction`` coordinates of the nodes defining the curves.

        f1 : array-like or float
            The other coordinates of the nodes defining the first curve.

        f2 : array-like or float
            The other coordinates of the nodes defining the second curve.

        where : array-like of bool, optional
            Define *where* to exclude some {dir} regions from being filled.
            The filled regions are defined by the coordinates ``t[where]``.
            More precisely, fill between ``t[i]`` and ``t[i+1]`` if
            ``where[i] and where[i+1]``.  Note that this definition implies
            that an isolated *True* value between two *False* values in *where*
            will not result in filling.  Both sides of the *True* position
            remain unfilled due to the adjacent *False* values.

        interpolate : bool, default: False
            This option is only relevant if *where* is used and the two curves
            are crossing each other.

            Semantically, *where* is often used for *f1* > *f2* or
            similar.  By default, the nodes of the polygon defining the filled
            region will only be placed at the positions in the *t* array.
            Such a polygon cannot describe the above semantics close to the
            intersection.  The t-sections containing the intersection are
            simply clipped.

            Setting *interpolate* to *True* will calculate the actual
            intersection point and extend the filled region up to this point.

        step : {{'pre', 'post', 'mid'}}, optional
            Define *step* if the filling should be a step function,
            i.e. constant in between *t*.  The value determines where the
            step will occur:

            - 'pre': The f value is continued constantly to the left from
              every *t* position, i.e. the interval ``(t[i-1], t[i]]`` has the
              value ``f[i]``.
            - 'post': The y value is continued constantly to the right from
              every *x* position, i.e. the interval ``[t[i], t[i+1])`` has the
              value ``f[i]``.
            - 'mid': Steps occur half-way between the *t* positions.

        **kwargs
            Forwarded to `.PolyCollection`.

        See Also
        --------
        .Axes.fill_between, .Axes.fill_betweenx
        N)Út_directionÚ_interpolateÚ_stepÚ_make_vertsr3   r4   )
rZ   rµ  ÚtÚf1Úf2r²  r³  r´  r[   rœ  r\   r^   r_   r4   ù  s
   @z"FillBetweenPolyCollection.__init__c                 C   s*   | dkrdS | dkrdS d| ›}t |ƒ‚)z/The direction that is other than `t_direction`.râ   rã   z$t_direction must be 'x' or 'y', got )rÚ   )rµ  Úmsgr^   r^   r_   Ú_f_dir_from_t?  s   
z'FillBetweenPolyCollection._f_dir_from_tc                 C   s   |   | j¡S )z4The direction that is other than `self.t_direction`.)r½  rµ  rc   r^   r^   r_   Ú_f_directionJ  s   z&FillBetweenPolyCollection._f_direction)r²  c                C   s<   | j  | j| j|||¡\}}}|  ||||¡}|  |¡ dS )a-  
        Set new values for the two bounding curves.

        Parameters
        ----------
        t : array-like
            The ``self.t_direction`` coordinates of the nodes defining the curves.

        f1 : array-like or float
            The other coordinates of the nodes defining the first curve.

        f2 : array-like or float
            The other coordinates of the nodes defining the second curve.

        where : array-like of bool, optional
            Define *where* to exclude some {dir} regions from being filled.
            The filled regions are defined by the coordinates ``t[where]``.
            More precisely, fill between ``t[i]`` and ``t[i+1]`` if
            ``where[i] and where[i+1]``.  Note that this definition implies
            that an isolated *True* value between two *False* values in *where*
            will not result in filling.  Both sides of the *True* position
            remain unfilled due to the adjacent *False* values.

        See Also
        --------
        .PolyCollection.set_verts, .Line2D.set_data
        N)rr   Ú_fill_between_process_unitsrµ  r¾  r¸  r›  )rZ   r¹  rº  r»  r²  rœ  r^   r^   r_   Úset_dataO  s
   
ÿz"FillBetweenPolyCollection.set_datac                 C   s8   t j ¡ }| |  ¡ |  t | j| jj	gg¡¡¡ |S )z7Calculate the data limits and return them as a `.Bbox`.)
r   r‚   rƒ   r•   r€   r}   rQ   r¨  Ú_bboxÚminpos)rZ   r–   Údatalimr^   r^   r_   r™   q  s
   
ÿz%FillBetweenPolyCollection.get_datalimc              	      sš   ˆ  ˆjˆjˆˆ ˆ¡ ˆ ˆˆ ˆˆ¡‰tjt ˆ¡ˆ ˆdd\‰‰ ‰tj 	¡ ˆ_
ˆj
 ˆ t ‡‡fdd„ˆ ˆfD ƒ¡¡¡ ‡ ‡‡‡fdd„t ˆ¡D ƒS )zH
        Make verts that can be forwarded to `.PolyCollection`.
        T)Úsubokc                    s&   g | ]}t jˆ ˆ |ˆ fd d‘qS )r£  r   )rQ   Ústack)rz   Úf)r¹  r²  r^   r_   r~   ‚  s    ÿz9FillBetweenPolyCollection._make_verts.<locals>.<listcomp>c              	      s"   g | ]\}}ˆ  ˆˆ ˆ||¡‘qS r^   )Ú_make_verts_for_region)rz   Úidx0Úidx1)rº  r»  rZ   r¹  r^   r_   r~   …  s    ÿÿ)Ú_validate_shapesrµ  r¾  Ú_get_data_maskrQ   Úbroadcast_arraysrö   r   r‚   rƒ   rÁ  r•   Ú_fix_pts_xy_orderr¨  r   Úcontiguous_regions)rZ   r¹  rº  r»  r²  r^   )rº  r»  rZ   r¹  r²  r_   r¸  x  s   ÿþz%FillBetweenPolyCollection._make_vertsc              	   C   sh   |du rd}nt j|td}|j|jkr"d |j| j|j¡}t|ƒ‚|t t j	t
t jj|||gƒ¡ @ S )zõ
        Return a bool array, with True at all points that should eventually be rendered.

        The array is True at a point if none of the data inputs
        *t*, *f1*, *f2* is masked and if the input *where* is true at that point.
        NTr¡  z-where size ({}) does not match {!r} size ({}))rQ   r  r  r:  Úformatrµ  rÚ   Ú	functoolsÚreduceÚ
logical_orÚmapr‰   Úgetmaskarray)rZ   r¹  rº  r»  r²  r¼  r^   r^   r_   rË  Š  s   ÿÿz(FillBetweenPolyCollection._get_data_maskc           	      C   sŒ   dd„ t | ||fdƒD ƒ}t ||||gƒD ].\}}|jdkr%t|›dƒ‚|jdkrC|jdkrC|j|jkrCd | |j||j¡}t|ƒ‚qdS )zFValidate that t, f1 and f2 are 1-dimensional and have the same length.c                 s   s    | ]	\}}|| V  qd S ra   r^   )rz   r	  Úsr^   r^   r_   r©   Ÿ  rª   z=FillBetweenPolyCollection._validate_shapes.<locals>.<genexpr>)rd  Ú1Ú2r   z is not 1-dimensionalz4{!r} has size {}, but {!r} has an unequal size of {}N)r  r7  rÚ   r:  rÏ  )	Út_dirÚf_dirr¹  rº  r»  Únamesr  rL  r¼  r^   r^   r_   rÊ  œ  s   
 ÿ€úz*FillBetweenPolyCollection._validate_shapesc              	   C   sê   |||… }|||… }|||… }| j dur(tjd| j   }	|	|||ƒ\}}}| jr<|  ||||¡}
|  ||||¡}n|d |d f}
|d |d f}t t |
g¡tj||fddt |g¡tj||fddddd… f¡}|  	|¡S )z‘
        Make ``verts`` for a contiguous region between ``idx0`` and ``idx1``, taking
        into account ``step`` and ``interpolate``.
        Nzsteps-r   r£  r   )
r·  r   ÚSTEP_LOOKUP_MAPr¶  Ú_get_interpolating_pointsrQ   r¨  r  rÅ  rÍ  )rZ   r¹  rº  r»  rÈ  rÉ  Út_sliceÚf1_sliceÚf2_sliceÚ	step_funcÚstartÚendÚptsr^   r^   r_   rÇ  ¨  s$   


ü
z0FillBetweenPolyCollection._make_verts_for_regionc                 C   s¾   t |d dƒ}|||d … }|||d … |||d …  }|||d … }t|ƒdkrMtj |d ¡r=|| || fS tj |d ¡rM|| || fS |  d||¡}	|  |	||¡}
|	|
fS )zCalculate interpolating points.r   r   r2   )rt  r„   rQ   r‰   Ú	is_maskedÚ_get_diff_root)Úclsr¹  rº  r»  ÚidxÚim1Út_valuesÚdiff_valuesÚ	f1_valuesÚdiff_root_tÚdiff_root_fr^   r^   r_   rÜ  Å  s    z3FillBetweenPolyCollection._get_interpolating_pointsc                 C   s   |  ¡ }t | || || ¡S )zCalculate diff root.)r|  rQ   r}  )râ   ÚxpÚfpÚorderr^   r^   r_   rå  ×  s   z(FillBetweenPolyCollection._get_diff_rootc                 C   s$   | j dkr|dd…ddd…f S |S )zÐ
        Fix pts calculation results with `self.t_direction`.

        In the workflow, it is assumed that `self.t_direction` is 'x'. If this
        is not true, we need to exchange the coordinates.
        rã   Nr£  )rµ  )rZ   rã  r^   r^   r_   rÍ  Ý  s   $z+FillBetweenPolyCollection._fix_pts_xy_order)r±   r?  r@  rA  r4   rE  r½  Úpropertyr¾  rÀ  r™   r¸  rË  rÊ  rÇ  ÚclassmethodrÜ  rå  rÍ  rF  r^   r^   r\   r_   r±  õ  s(    þF


"


r±  c                       sX   e Zd ZdZejjZej	d Z
dddœ‡ fdd„
Zdd	„ Zd
d„ Zejdd„ ƒZ‡  ZS )ÚRegularPolyCollectionz)A collection of n-sided regular polygons.ç      à¿r   )r   )ÚrotationrO  c                   sH   t ƒ jdi |¤Ž |  |¡ || _|  |¡g| _|| _|  t 	¡ ¡ dS )aš  
        Parameters
        ----------
        numsides : int
            The number of sides of the polygon.
        rotation : float
            The rotation of the polygon in radians.
        sizes : tuple of float
            The area of the circle circumscribing the polygon in points^2.
        **kwargs
            Forwarded to `.Collection`.

        Examples
        --------
        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)]

            collection = RegularPolyCollection(
                numsides=5, # a pentagon
                rotation=0, sizes=(50,),
                facecolors=facecolors,
                edgecolors=("black",),
                linewidths=(1,),
                offsets=offsets,
                offset_transform=ax.transData,
                )
        Nr^   )
r3   r4   rR  Ú	_numsidesÚ_path_generatorrY   Ú	_rotationÚset_transformr   rn   )rZ   Únumsidesrõ  rO  r[   r\   r^   r_   r4   í  s   #
zRegularPolyCollection.__init__c                 C   r`   ra   )rö  rc   r^   r^   r_   Úget_numsides  re   z"RegularPolyCollection.get_numsidesc                 C   r`   ra   )rø  rc   r^   r^   r_   Úget_rotation  re   z"RegularPolyCollection.get_rotationc                    s>   ˆ   ˆ jˆ jddj¡ ‡ fdd„ˆ jD ƒˆ _t ˆ |¡ d S )NTr«   c                    s$   g | ]}t  |¡ ˆ j ¡ ¡ ‘qS r^   )r   rÄ   Úrotaterø  Ú
get_matrixrû   rc   r^   r_   r~      s    ÿÿz.RegularPolyCollection.draw.<locals>.<listcomp>)rR  rI  rÇ   rP  rk   r$   rÙ   rš   r^   rc   r_   rÙ     s
   
þzRegularPolyCollection.draw)r±   r?  r@  rA  r   r¢   Úunit_regular_polygonr÷  rQ   ÚpirN  r4   rû  rü  r   rD  rÙ   rF  r^   r^   r\   r_   ró  ç  s    
ü*ró  c                   @   ó   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@  rA  r   r¢   Úunit_regular_starr÷  r^   r^   r^   r_   r  )  ó    r  c                   @   r  )ÚAsteriskPolygonCollectionz>Draw a collection of regular asterisks with *numsides* points.N)r±   r?  r@  rA  r   r¢   Úunit_regular_asteriskr÷  r^   r^   r^   r_   r  .  r  r  c                       s¦   e Zd ZdZdZddœ‡ fdd„
Zdd„ ZeZeZd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Z‡ fdd„Zdd„ ZeZdd„ ZeZdd„ Zdd„ Zdd„ Zdd „ Z‡  ZS )!ÚLineCollectiona­  
    Represents a sequence of `.Line2D`\s that should be drawn together.

    This class extends `.Collection` to represent a sequence of
    `.Line2D`\s instead of just a sequence of `.Patch`\s.
    Just as in `.Collection`, each property of a *LineCollection* may be either
    a single value or a list of values. This list is then used cyclically for
    each element of the LineCollection, so the property of the ``i``\th element
    of the collection is::

      prop[i % len(prop)]

    The properties of each member of a *LineCollection* default to their values
    in :rc:`lines.*` instead of :rc:`patch.*`, and the property *colors* is
    added in place of *edgecolors*.
    Tr2   )r/   c                   s0   |  dd¡ tƒ jdd|i|¤Ž |  |¡ dS )a½  
        Parameters
        ----------
        segments : list of (N, 2) array-like
            A sequence ``[line0, line1, ...]`` where each line is a (N, 2)-shape
            array-like containing points::

                line0 = [(x0, y0), (x1, y1), ...]

            Each line can contain a different number of points.
        linewidths : float or list of float, default: :rc:`lines.linewidth`
            The width of each line in points.
        colors : :mpltype:`color` or list of color, default: :rc:`lines.color`
            A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not
            allowed).
        antialiaseds : bool or list of bool, default: :rc:`lines.antialiased`
            Whether to use antialiasing for each line.
        zorder : float, default: 2
            zorder of the lines once drawn.

        facecolors : :mpltype:`color` or list of :mpltype:`color`, default: 'none'
            When setting *facecolors*, each line is interpreted as a boundary
            for an area, implicitly closing the path from the last point to the
            first point. The enclosed area is filled with *facecolor*.
            In order to manually specify what should count as the "interior" of
            each line, please use `.PathCollection` instead, where the
            "interior" can be specified by appropriate usage of
            `~.path.Path.CLOSEPOLY`.

        **kwargs
            Forwarded to `.Collection`.
        r   r­   r/   Nr^   )Ú
setdefaultr3   r4   Úset_segments)rZ   Úsegmentsr/   r[   r\   r^   r_   r4   G  s   &
ÿþzLineCollection.__init__c                 C   s&   |d u rd S dd„ |D ƒ| _ d| _d S )Nc                 S   s6   g | ]}t |tjjƒrt |¡nt t |t¡¡‘qS r^   )ro   rQ   r‰   rŠ   r   r¢   r  rS   )rz   Úsegr^   r^   r_   r~   w  s
    þÿz/LineCollection.set_segments.<locals>.<listcomp>Trg   )rZ   r
  r^   r^   r_   r	  s  s   þ
zLineCollection.set_segmentsc                 C   s>   g }| j D ]}dd„ |jddD ƒ}t |¡}| |¡ q|S )z¤
        Returns
        -------
        list
            List of segments in the LineCollection. Each list item contains an
            array of vertices.
        c                 S   s   g | ]\}}|‘qS r^   r^   )rz   ÚvertexÚ_r^   r^   r_   r~   Š  s    ÿÿz/LineCollection.get_segments.<locals>.<listcomp>F)Úsimplify)rY   Úiter_segmentsrQ   r  r¡   )rZ   r
  r   rž   r^   r^   r_   Úget_segments  s   

ú
zLineCollection.get_segmentsc                 C   ró   )Nzlines.linewidthrô   rc   r^   r^   r_   rõ   —  ó   
z%LineCollection._get_default_linewidthc                 C   ró   )Nzlines.antialiasedrô   rc   r^   r^   r_   r  š  r  z'LineCollection._get_default_antialiasedc                 C   ró   )Nzlines.colorrô   rc   r^   r^   r_   r%    r  z%LineCollection._get_default_edgecolorc                 C   s   dS )Nr­   r^   rc   r^   r^   r_   r     s   z%LineCollection._get_default_facecolorc                    s*   t ƒ  |¡ | jd ur|  | j¡ d S d S ra   )r3   r.  r:   Úset_gapcolorÚ_original_gapcolorr,  r\   r^   r_   r.  £  s   
ÿzLineCollection.set_alphac                 C   s   |   |¡ dS )aH  
        Set the edgecolor(s) of the LineCollection.

        Parameters
        ----------
        c : :mpltype:`color` or list of :mpltype:`color`
            Single color (all lines have same color), or a
            sequence of RGBA tuples; if it is a sequence the lines will
            cycle through the sequence.
        N)rE   r  r^   r^   r_   r  ©  s   zLineCollection.set_colorc                 C   r`   ra   )r$  rc   r^   r^   r_   Ú	get_color¸  re   zLineCollection.get_colorc                 C   s   || _ |  |¡ dS )a1  
        Set a color to fill the gaps in the dashed line style.

        .. note::

            Striped lines are created by drawing two interleaved dashed lines.
            There can be overlaps between those two, which may result in
            artifacts when using transparency.

            This functionality is experimental and may change.

        Parameters
        ----------
        gapcolor : :mpltype:`color` or list of :mpltype:`color` or None
            The color with which to fill the gaps. If None, the gaps are
            unfilled.
        N)r  Ú_set_gapcolor©rZ   Úgapcolorr^   r^   r_   r  ½  s   zLineCollection.set_gapcolorc                 C   s&   |d urt  || j¡}|| _d| _d S rf   )r>   r  r  r:   rh   r  r^   r^   r_   r  Ò  s   
zLineCollection._set_gapcolorc                 C   r`   ra   )r:   rc   r^   r^   r_   Úget_gapcolorØ  re   zLineCollection.get_gapcolorc                 C   s&   dd„ t | jt | j¡ƒD ƒ}t |Ž S )a%  
        Returns the path and pattern for the gaps in the non-solid lines.

        This path and pattern is the inverse of the path and pattern used to
        construct the non-solid lines. For solid lines, we set the inverse path
        to nans to prevent drawing an inverse line.
        c                 S   s>   g | ]\}}|d krt  t dtj¡¡|fn|tj|Ž f‘qS )r0   rñ   )r   r¢   rQ   ÚfullrŒ   rù   Ú_get_inverse_dash_pattern)rz   r   r   r^   r^   r_   r~   ã  s    þÿýz@LineCollection._get_inverse_paths_linestyles.<locals>.<listcomp>)r  rY   Ú	itertoolsÚcycler7   )rZ   Úpath_patternsr^   r^   r_   rÎ   Û  s   ûz,LineCollection._get_inverse_paths_linestyles)r±   r?  r@  rA  r&  r4   r	  r›  rj   r  rõ   r  r%  r  r.  r  Ú
set_colorsr  Ú
get_colorsr  r  r  rÎ   rF  r^   r^   r\   r_   r  3  s,    þ,	r  c                       s¸   e Zd ZdZdZ	d'dddddddœ‡ f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„ 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 )(ÚEventCollectionzÐ
    A collection of locations along a single axis at which an "event" occurred.

    The events are given by a 1-dimensional array. They do not have an
    amplitude and are displayed as parallel lines.
    TÚ
horizontalr   r   Nr'   )Ú
lineoffsetÚ
linelengthr"   rX  r!   r   c          
         sH   t ƒ jg f||||dœ|	¤Ž d| _|| _|| _|  |¡ |  |¡ dS )aY  
        Parameters
        ----------
        positions : 1D array-like
            Each value is an event.
        orientation : {'horizontal', 'vertical'}, default: 'horizontal'
            The sequence of events is plotted along this direction.
            The marker lines of the single events are along the orthogonal
            direction.
        lineoffset : float, default: 0
            The offset of the center of the markers from the origin, in the
            direction orthogonal to *orientation*.
        linelength : float, default: 1
            The total height of the marker (i.e. the marker stretches from
            ``lineoffset - linelength/2`` to ``lineoffset + linelength/2``).
        linewidth : float or list thereof, default: :rc:`lines.linewidth`
            The line width of the event lines, in points.
        color : :mpltype:`color` or list of :mpltype:`color`, default: :rc:`lines.color`
            The color of the event lines.
        linestyle : str or tuple or list thereof, 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 : bool or list thereof, default: :rc:`lines.antialiased`
            Whether to use antialiasing for drawing the lines.
        **kwargs
            Forwarded to `.LineCollection`.

        Examples
        --------
        .. plot:: gallery/lines_bars_and_markers/eventcollection_demo.py
        )r   r   r
   r   TN)r3   r4   Ú_is_horizontalÚ_linelengthÚ_lineoffsetÚset_orientationÚset_positions)
rZ   Ú	positionsÚorientationr"  r#  r"   rX  r!   r   r[   r\   r^   r_   r4   ÷  s   
0þý
zEventCollection.__init__c                    s&   |   ¡ rdnd‰ ‡ fdd„|  ¡ D ƒS )zX
        Return an array containing the floating-point values of the positions.
        r   r   c                    s   g | ]}|d ˆ f ‘qS )r   r^   )rz   Úsegment©Úposr^   r_   r~   6  r¥  z1EventCollection.get_positions.<locals>.<listcomp>)Úis_horizontalr  rc   r^   r,  r_   Úget_positions1  s   zEventCollection.get_positionsc                 C   sÈ   |du rg }t  |¡dkrtdƒ‚|  ¡ }|  ¡ }|  ¡ rdnd}t  t|ƒddf¡}t  |¡dd…df |dd…dd…|f< ||d  |dd…dd| f< ||d  |dd…dd| f< |  	|¡ dS )z Set the positions of the events.Nr   z!positions must be one-dimensionalr   r2   )
rQ   r7  rÚ   Úget_lineoffsetÚget_linelengthr.  rB  r„   Úsortr	  )rZ   r)  r"  r#  Úpos_idxr
  r^   r^   r_   r(  8  s   (zEventCollection.set_positionsc                 C   sL   |du st |dƒrt|ƒdkrdS |  ¡ }t |t |¡g¡}|  |¡ dS )z2Add one or more events at the specified positions.Nr„   r   )rq   r„   r/  rQ   ÚhstackrR   r(  )rZ   Úpositionr)  r^   r^   r_   Úadd_positionsG  s   zEventCollection.add_positionsc                 C   r`   )z=True if the eventcollection is horizontal, False if vertical.)r$  rc   r^   r^   r_   r.  Q  rê   zEventCollection.is_horizontalc                 C   s   |   ¡ rdS dS )zX
        Return the orientation of the event line ('horizontal' or 'vertical').
        r!  Úvertical)r.  rc   r^   r^   r_   Úget_orientationU  s   zEventCollection.get_orientationc                 C   sH   |   ¡ }t|ƒD ]\}}t |¡||< q|  |¡ |  ¡  | _d| _dS )zv
        Switch the orientation of the event line, either from vertical to
        horizontal or vice versus.
        TN)r  Ú	enumeraterQ   Úfliplrr	  r.  r$  rh   )rZ   r
  Úir+  r^   r^   r_   Úswitch_orientation[  s   

z"EventCollection.switch_orientationc                 C   s0   t jdddœ|d}||  ¡ krdS |  ¡  dS )z
        Set the orientation of the event line.

        Parameters
        ----------
        orientation : {'horizontal', 'vertical'}
        TF)r!  r7  )r*  N)r   Úcheck_getitemr.  r<  )rZ   r*  r.  r^   r^   r_   r'  g  s   þzEventCollection.set_orientationc                 C   r`   )z7Return the length of the lines used to mark each event.)r%  rc   r^   r^   r_   r1  v  rê   zEventCollection.get_linelengthc                 C   sv   ||   ¡ krdS |  ¡ }|  ¡ }|  ¡ rdnd}|D ]}||d  |d|f< ||d  |d|f< q|  |¡ || _dS )z4Set the length of the lines used to mark each event.Nr   r   ç       @)r1  r0  r  r.  r	  r%  )rZ   r#  r"  r
  r-  r+  r^   r^   r_   Úset_linelengthz  ó   

zEventCollection.set_linelengthc                 C   r`   )z7Return the offset of the lines used to mark each event.)r&  rc   r^   r^   r_   r0  ‡  rê   zEventCollection.get_lineoffsetc                 C   sv   ||   ¡ krdS |  ¡ }|  ¡ }|  ¡ rdnd}|D ]}||d  |d|f< ||d  |d|f< q|  |¡ || _dS )z4Set the offset of the lines used to mark each event.Nr   r   r>  )r0  r1  r  r.  r	  r&  )rZ   r"  r#  r
  r-  r+  r^   r^   r_   Úset_lineoffset‹  r@  zEventCollection.set_lineoffsetc                    s   t ƒ  ¡ d S )z3Get the width of the lines used to mark each event.r   ©r3   r/  rc   r\   r^   r_   r/  ˜  s   zEventCollection.get_linewidthc                    s
   t ƒ  ¡ S ra   rB  rc   r\   r^   r_   r~  œ  r  zEventCollection.get_linewidthsc                 C   s   |   ¡ d S )z6Return the color of the lines used to mark each event.r   )r  rc   r^   r^   r_   r  Ÿ  ó   zEventCollection.get_color)r!  )r±   r?  r@  rA  r&  r4   r/  r(  r6  Úextend_positionsÚappend_positionsr.  r8  r<  r'  r1  r?  r0  rA  r/  r~  r  rF  r^   r^   r\   r_   r   í  s6    þ÷:r   c                       s*   e Zd ZdZejd Z‡ fdd„Z‡  ZS )ÚCircleCollectionz-A collection of circles, drawn using splines.rô  c                    s<   t ƒ jdi |¤Ž |  |¡ |  t ¡ ¡ tj ¡ g| _	dS )z½
        Parameters
        ----------
        sizes : float or array-like
            The area of each circle in points^2.
        **kwargs
            Forwarded to `.Collection`.
        Nr^   )
r3   r4   rR  rù  r   rn   r   r¢   Úunit_circlerY   )rZ   rO  r[   r\   r^   r_   r4   ©  s   	
zCircleCollection.__init__)	r±   r?  r@  rA  rQ   r   rN  r4   rF  r^   r^   r\   r_   rF  ¤  s    
rF  c                       sp   e Zd ZdZddœ‡ f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‡ fdd„ƒZ‡  ZS )ÚEllipseCollectionz.A collection of ellipses, drawn using splines.Úpoints)Úunitsc                   sb   t ƒ jdi |¤Ž |  |¡ |  |¡ |  |¡ || _|  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 `~.patches.Ellipse` with
            ``axes.transData`` as its transform.
        **kwargs
            Forwarded to `Collection`.
        r%   Nr^   )r3   r4   Ú
set_widthsÚset_heightsÚ
set_anglesÚ_unitsrù  r   rn   rQ   rB  rk   r   r¢   rG  rY   )rZ   ÚwidthsÚheightsÚanglesrJ  r[   r\   r^   r_   r4   »  s   


zEllipseCollection.__init__c           
      C   sÐ  | j }| jdd}| jdkrd}nT| jdkr|jj|jj }nF| jdkr-|jj|jj }n8| jdkr6|j}n/| jdkrA|jd	 }n$| jd
krK|jj}n| jdkrU|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 dS )z0Calculate transforms immediately before drawing.Fr«   rŸ  r   râ   rã   ÚinchesrI  rK  rÆ   rÈ   ÚdotsrH  zUnrecognized units: r&   Nr   r2   )rr   rÇ   rN  r˜   rÆ   ÚviewLimrÈ   rP  rÚ   rQ   rò   r„   Ú_widthsrk   Ú_heightsÚsinÚ_anglesÚcosr   rÄ   r–   r   rþ  Úcopyrù  )
rZ   ÚaxÚfigÚscrO  rP  Ú	sin_angleÚ	cos_angleÚ_affineÚmr^   r^   r_   Ú_set_transformsÙ  sF   












ýz!EllipseCollection._set_transformsc                 C   ó   dt  |¡ ¡  | _d| _dS )z5Set the lengths of the first axes (e.g., major axis).ç      à?TN)rQ   r  ÚravelrU  rh   )rZ   rO  r^   r^   r_   rK    ó   
zEllipseCollection.set_widthsc                 C   rc  )ú2Set the lengths of second axes (e.g., minor axes).rd  TN)rQ   r  re  rV  rh   )rZ   rP  r^   r^   r_   rL    rf  zEllipseCollection.set_heightsc                 C   s   t  |¡ ¡ | _d| _dS )z>Set the angles of the first axes, degrees CCW from the x-axis.TN)rQ   Údeg2radre  rX  rh   )rZ   rQ  r^   r^   r_   rM    s   
zEllipseCollection.set_anglesc                 C   ó
   | j d S )z5Get the lengths of the first axes (e.g., major axis).r2   )rU  rc   r^   r^   r_   Ú
get_widths  rí   zEllipseCollection.get_widthsc                 C   ri  )rg  r2   )rV  rc   r^   r^   r_   Úget_heights  rí   zEllipseCollection.get_heightsc                 C   s   t  | j¡S )z>Get the angles of the first axes, degrees CCW from the x-axis.)rQ   Úrad2degrX  rc   r^   r^   r_   Ú
get_angles  rC  zEllipseCollection.get_anglesc                    s   |   ¡  tƒ  |¡ d S ra   )rb  r3   rÙ   rš   r\   r^   r_   rÙ     s   zEllipseCollection.draw)r±   r?  r@  rA  r4   rb  rK  rL  rM  rj  rk  rm  r   rD  rÙ   rF  r^   r^   r\   r_   rH  ¸  s    *rH  c                       s.   e Zd ZdZddœ‡ fdd„
Zdd„ Z‡  ZS )ÚPatchCollectionzá
    A generic collection of patches.

    PatchCollection draws faster than a large number of equivalent individual
    Patches. It also makes it easier to assign a colormap to a heterogeneous
    collection of patches.
    F)Úmatch_originalc                   sŠ   |r5dd„ ‰ ‡ fdd„|D ƒ|d< dd„ |D ƒ|d< dd„ |D ƒ|d	< d
d„ |D ƒ|d< dd„ |D ƒ|d< t ƒ jdi |¤Ž |  |¡ dS )a?  
        Parameters
        ----------
        patches : list of `.Patch`
            A sequence of Patch objects.  This list may include
            a heterogeneous assortment of different patch types.

        match_original : bool, default: False
            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.

        **kwargs
            All other parameters are forwarded to `.Collection`.

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

        Notes
        -----
        The use of `~matplotlib.cm.ScalarMappable` functionality is optional.
        If the `~matplotlib.cm.ScalarMappable` matrix ``_A`` has been set (via
        a call to `~.ScalarMappable.set_array`), at draw time a call to scalar
        mappable will be made to set the face colors.
        c                 S   s   |   ¡ r|  ¡ S g d¢S )N)r   r   r   r   )r<  r¿   )Úpatchr^   r^   r_   Údetermine_facecolorK  s   z5PatchCollection.__init__.<locals>.determine_facecolorc                    s   g | ]}ˆ |ƒ‘qS r^   r^   ry   ©rq  r^   r_   r~   P  ó    z,PatchCollection.__init__.<locals>.<listcomp>r   c                 S   ó   g | ]}|  ¡ ‘qS r^   )rÀ   ry   r^   r^   r_   r~   Q  rs  r   c                 S   rt  r^   )r/  ry   r^   r^   r_   r~   R  rs  r   c                 S   rt  r^   )r0  ry   r^   r^   r_   r~   S  rs  r   c                 S   rt  r^   )r  ry   r^   r^   r_   r~   T  rs  r   Nr^   )r3   r4   rj   )rZ   Úpatchesro  r[   r\   rr  r_   r4   -  s   zPatchCollection.__init__c                 C   s   dd„ |D ƒ}|| _ d S )Nc                 S   s   g | ]}|  ¡  | ¡ ¡‘qS r^   )r€   Útransform_pathÚget_pathry   r^   r^   r_   r~   [  s    ÿz-PatchCollection.set_paths.<locals>.<listcomp>rb   )rZ   ru  ri   r^   r^   r_   rj   Z  s   ÿ
zPatchCollection.set_paths)r±   r?  r@  rA  r4   rj   rF  r^   r^   r\   r_   rn  $  s    -rn  c                       sJ   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zedd	„ ƒZe	j
d
d„ ƒZ‡  ZS )ÚTriMeshz™
    Class for the efficient drawing of a triangular mesh using Gouraud shading.

    A triangular mesh is a `~matplotlib.tri.Triangulation` object.
    c                    s\   t ƒ jdi |¤Ž || _d| _tj ¡ | _t 	|j
 dd¡|j dd¡f¡}| j |¡ d S )NÚgouraudr£  r   r^   )r3   r4   Ú_triangulationÚ_shadingr   r‚   ÚunitrÁ  rQ   r4  râ   r;  rã   r•   )rZ   Útriangulationr[   rŸ  r\   r^   r_   r4   f  s   ÿzTriMesh.__init__c                 C   ó   | j d u r	|  ¡  | j S ra   ©rY   rj   rc   r^   r^   r_   rd   s  ó   
zTriMesh.get_pathsc                 C   s   |   | j¡| _d S ra   )Úconvert_mesh_to_pathsrz  rY   rc   r^   r^   r_   rj   x  s   zTriMesh.set_pathsc                 C   s4   |   ¡ }tj| j| | j| fdd}dd„ |D ƒS )z¾
        Convert 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£  r   c                 S   rø   r^   r  rû   r^   r^   r_   r~   …  r   z1TriMesh.convert_mesh_to_paths.<locals>.<listcomp>)Úget_masked_trianglesrQ   rÅ  râ   rã   )ÚtriÚ	trianglesrœ  r^   r^   r_   r  {  s   zTriMesh.convert_mesh_to_pathsc                 C   sº   |   ¡ sd S |j| jj|  ¡ d |  ¡ }| j}| ¡ }tj	|j
| |j| fdd}|  ¡  | j| }| ¡ }|  |¡ | |  ¡ d ¡ | |||| ¡ ¡ | ¡  | | jj¡ d S )N)Úgidr£  r   r   )r¯   r°   r]   r±   r²   r€   rz  r‚  rQ   rÅ  râ   rã   r³   r  r´   rµ   rF   r/  Údraw_gouraud_trianglesr‘   rÐ   rÑ   )rZ   r›   r}   rƒ  r„  rœ  r
   rÒ   r^   r^   r_   rÙ   ‡  s   

zTriMesh.draw)r±   r?  r@  rA  r4   rd   rj   rE  r  r   rD  rÙ   rF  r^   r^   r\   r_   rx  `  s    
rx  c                       sb   e Zd ZdZddœdd„Z‡ fdd„Zdd	„ Z‡ fd
d„Z‡ fdd„Ze	dd„ ƒZ
dd„ Z‡  ZS )r8  aš  
    Class for managing the two dimensional coordinates of Quadrilateral meshes
    and the associated data with them. This class is a mixin and is intended to
    be used with another collection that will implement the draw separately.

    A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are
    defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is
    defined by the vertices ::

               (m+1, n) ----------- (m+1, n+1)
                  /                   /
                 /                 /
                /               /
            (m, n) -------- (m, n+1)

    The mesh need not be regular and the polygons need not be convex.

    Parameters
    ----------
    coordinates : (M+1, N+1, 2) array-like
        The vertices. ``coordinates[m, n]`` specifies the (x, y) coordinates
        of vertex (m, n).

    shading : {'flat', 'gouraud'}, default: 'flat'
    Úflat)Úshadingc                C   s   t jd|d || _|| _d S )N)NNr2   ©Úcoordinates)r   Úcheck_shapeÚ_coordinatesr{  )rZ   rŠ  rˆ  r^   r^   r_   r4   ¹  s   
z_MeshData.__init__c                    sº   | j jdd… \}}| jdkr|d |d }}n||}}||df||df||f|| fg}|durWt |¡}||vrWtd|› d	|› d
| j› dd tt|ƒ¡› d|j› 
ƒ‚tƒ  	|¡S )au  
        Set the data values.

        Parameters
        ----------
        A : array-like
            The mesh data. Supported array shapes are:

            - (M, N) or (M*N,): a mesh with scalar data. The values are mapped
              to colors using normalization and a colormap. See parameters
              *norm*, *cmap*, *vmin*, *vmax*.
            - (M, N, 3): an image with RGB values (0-1 float or 0-255 int).
            - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),
              i.e. including transparency.

            If the values are provided as a 2D grid, the shape must match the
            coordinates grid. If the values are 1D, they are reshaped to 2D.
            M, N follow from the coordinates grid, where the coordinates grid
            shape is (M, N) for 'gouraud' *shading* and (M+1, N+1) for 'flat'
            shading.
        r   r£  r‡  r   r&   é   NzFor X (z	) and Y (z) with z shading, A should have shape z or z, not )
rŒ  rT   r{  rQ   rÚ   ÚjoinrÓ  r   r3   Ú	set_array)rZ   ÚArÈ   rÆ   r–  ÚwÚ	ok_shapesrT   r\   r^   r_   r  ¾  s    

"
þþÿz_MeshData.set_arrayc                 C   r`   )a  
        Return the vertices of the mesh as an (M+1, N+1, 2) array.

        M, N are the number of quadrilaterals in the rows / columns of the
        mesh, corresponding to (M+1, N+1) vertices.
        The last dimension specifies the components (x, y).
        )rŒ  rc   r^   r^   r_   Úget_coordinatesã  r  z_MeshData.get_coordinatesc                    ó   t ƒ  ¡  dd¡S ©Nr£  r  )r3   rÀ   r;  rc   r\   r^   r_   rÀ   í  ó   z_MeshData.get_edgecolorc                    r”  r•  )r3   r¿   r;  rc   r\   r^   r_   r¿   ó  r–  z_MeshData.get_facecolorc              	   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 gdd d¡}dd„ |D ƒS )	zÂ
        Convert 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   r2   r   )r£  r[  r2   c                 S   rø   r^   r  rû   r^   r^   r_   r~   	  r   z4_MeshData._convert_mesh_to_paths.<locals>.<listcomp>)ro   rQ   r‰   rŠ   Údatar¨  r;  )rŠ  r  rI  r^   r^   r_   Ú_convert_mesh_to_pathsù  s   ûúúz _MeshData._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||||||||||||gdd d¡}|  ¡  g |jdd… ¢d‘R ¡}	|  	¡ }
tj 
|
¡rs|
jnd}|dur€tj|	|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||||||||||||gdd d
¡}t |d ¡}||  ||  fS )zË
        Convert a given mesh into a sequence of triangles, each point
        with its own color.  The result can be used to construct a call to
        `~.RendererBase.draw_gouraud_triangles`.
        Nr£  r   g      @r2   r   )r£  r&   r2   r  r&   )r£  r&   r  ).r2   r&   )ro   rQ   r‰   rŠ   r—  r¨  r;  r¿   rT   rh  rä  r“   rŒ   Úisnan)rZ   rŠ  r{   Úp_aÚp_bÚp_cÚp_dÚp_centerr„  r  Úzr“   Úc_aÚc_bÚc_cÚc_dÚc_centerr
   Útmaskr^   r^   r_   Ú_convert_mesh_to_triangles	  sP   üûû"üûûz$_MeshData._convert_mesh_to_triangles)r±   r?  r@  rA  r4   r  r“  rÀ   r¿   rE  r˜  r¦  rF  r^   r^   r\   r_   r8  Ÿ  s    %

r8  c                       sV   e Zd ZdZdddœ‡ fdd„
Zdd„ Zd	d
„ Zdd„ Zej	dd„ ƒZ
dd„ Z‡  ZS )ÚQuadMeshaá  
    Class for the efficient drawing of a quadrilateral mesh.

    A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are
    defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is
    defined by the vertices ::

               (m+1, n) ----------- (m+1, n+1)
                  /                   /
                 /                 /
                /               /
            (m, n) -------- (m, n+1)

    The mesh need not be regular and the polygons need not be convex.

    Parameters
    ----------
    coordinates : (M+1, N+1, 2) array-like
        The vertices. ``coordinates[m, n]`` specifies the (x, y) coordinates
        of vertex (m, n).

    antialiased : bool, default: True

    shading : {'flat', 'gouraud'}, default: 'flat'

    Notes
    -----
    Unlike other `.Collection`\s, the default *pickradius* of `.QuadMesh` is 0,
    i.e. `~.Artist.contains` checks whether the test point is within any of the
    mesh quadrilaterals.

    Tr‡  )r   rˆ  c                   sd   |  dd¡ tƒ j||d tj| fi |¤Ž || _tj ¡ | _| j 	| j
 dd¡¡ |  d¡ d S )Nr-   r   )rŠ  rˆ  r£  r2   F)r  r3   r4   r$   Ú_antialiasedr   r‚   r|  rÁ  r•   rŒ  r;  Úset_mouseover)rZ   rŠ  r   rˆ  r[   r\   r^   r_   r4   [	  s   zQuadMesh.__init__c                 C   r~  ra   r  rc   r^   r^   r_   rd   f	  r€  zQuadMesh.get_pathsc                 C   s   |   | j¡| _d| _d S rf   )r˜  rŒ  rY   rh   rc   r^   r^   r_   rj   k	  s   
zQuadMesh.set_pathsc                 C   s   |   ¡ |  | j¡S ra   )r€   Útransform_bboxrÁ  )rZ   r–   r^   r^   r_   r™   o	  s   zQuadMesh.get_datalimc                 C   sž  |   ¡ sd S | | jj|  ¡ ¡ |  ¡ }|  ¡ }|  ¡ }|  ¡ r=|  	|d d …df ¡}|  
|d d …df ¡}t ||g¡}|  ¡  |js[| j d¡}| |¡}| | jj¡}t ¡ }n| j}|jsj| |¡}| ¡ }| ¡ }| |  ¡ ¡ |  |¡ | |  ¡ d ¡ | jdkrš|  |¡\}	}
| ||	|
|  ¡ ¡ n%| !||  ¡ |jd d |jd d ||||  "¡  d¡| j#|  $¡  d¡¡
 | %¡  | &| jj¡ d| _'d S )Nr   r   )r£  r2   ry  )r£  r  F)(r¯   r°   r]   r±   r²   r€   rs   r†   r   rŸ   r    rQ   r£   r³   r…   rŒ  r;  r}   rT   r   rn   r   r   r´   r¶   r·   rµ   rF   r/  r{  r¦  r†  r‘   Údraw_quad_meshr¿   r¨  Úget_edgecolorsrÐ   rÑ   rh   )rZ   r›   r}   r—   r*   r¥   r¦   rŠ  rÒ   r„  r
   r^   r^   r_   rÙ   r	  sN   




ÿú
zQuadMesh.drawc                 C   s6   |   |¡\}}|r|  ¡ d ur|  ¡  ¡ |d  S d S )NrÝ   )ræ   rh  re  )rZ   ÚeventÚ	containedÚinfor^   r^   r_   Úget_cursor_data£	  s   zQuadMesh.get_cursor_data)r±   r?  r@  rA  r4   rd   rj   r™   r   rD  rÙ   r°  rF  r^   r^   r\   r_   r§  9	  s    !
0r§  c                       sT   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Z‡ fdd	„Z‡ fd
d„Z‡ fdd„Z	‡  Z
S )ÚPolyQuadMeshas  
    Class for drawing a quadrilateral mesh as individual Polygons.

    A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are
    defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is
    defined by the vertices ::

               (m+1, n) ----------- (m+1, n+1)
                  /                   /
                 /                 /
                /               /
            (m, n) -------- (m, n+1)

    The mesh need not be regular and the polygons need not be convex.

    Parameters
    ----------
    coordinates : (M+1, N+1, 2) array-like
        The vertices. ``coordinates[m, n]`` specifies the (x, y) coordinates
        of vertex (m, n).

    Notes
    -----
    Unlike `.QuadMesh`, this class will draw each cell as an individual Polygon.
    This is significantly slower, but allows for more flexibility when wanting
    to add additional properties to the cells, such as hatching.

    Another difference from `.QuadMesh` is that if any of the vertices or data
    of a cell are masked, that Polygon will **not** be drawn and it won't be in
    the list of paths returned.
    c                    s0   t ƒ j|d tj| fdg i|¤Ž |  ¡  d S )Nr‰  rœ  )r3   r4   r™  Ú_set_unmasked_verts)rZ   rŠ  r[   r\   r^   r_   r4   Ë	  s   zPolyQuadMesh.__init__c                 C   sô   t jt j | j¡dd}|dd…dd…f |dd…dd…f B |dd…dd…f B |dd…dd…f B }|  ¡ }|durwt j |¡}|jdkrS|t j|ddO }| S |jdkr_||O }| S || | jdd…dd…dd…f jdd… ¡O }| S )z8Get the unmasked regions using the coordinates and arrayr£  r   r   r   Nr&   r2   )	rQ   r‡   r‰   rÔ  rŒ  rh  r7  r;  rT   )rZ   r“   r  r^   r^   r_   Ú_get_unmasked_polysÓ	  s   P

ü0ÿz PolyQuadMesh._get_unmasked_polysc                 C   sf  | j d }| j d }|  ¡ }tj |d d…d d…f ¡| }tj |d d…d d…f ¡| }tj |dd …d d…f ¡| }tj |dd …d d…f ¡| }tj |dd …dd …f ¡| }tj |dd …dd …f ¡| }	tj |d d…dd …f ¡| }
tj |d d…dd …f ¡| }t|ƒ}tjj||||||	|
|||g
dd}| |ddf¡}|  |¡ d S )N).r   ).r   r£  r   r   r[  r2   )	rŒ  r³  rQ   r‰   r‹   r„   rÅ  r;  r›  )rZ   ÚXÚYÚunmaskÚX1ÚY1ÚX2ÚY2ÚX3ÚY3ÚX4ÚY4ÚnpolyrŸ  rœ  r^   r^   r_   r²  æ	  s   

        $z PolyQuadMesh._set_unmasked_vertsc                    ó:   t ƒ  ¡ }|  ¡  ¡ }t|ƒt|ƒkr|S ||d d …f S ra   )r3   rÀ   r³  re  r„   )rZ   r   Úunmasked_polysr\   r^   r_   rÀ   ù	  ó
   
zPolyQuadMesh.get_edgecolorc                    rÀ  ra   )r3   r¿   r³  re  r„   )rZ   r   rÁ  r\   r^   r_   r¿   
  rÂ  zPolyQuadMesh.get_facecolorc                    s4   |   ¡ }tƒ  |¡ t ||   ¡ ¡s|  ¡  d S d S ra   )r³  r3   r  rQ   Úarray_equalr²  )rZ   r  Úprev_unmaskr\   r^   r_   r  
  s
   ÿzPolyQuadMesh.set_array)r±   r?  r@  rA  r4   r³  r²  rÀ   r¿   r  rF  r^   r^   r\   r_   r±  ª	  s     r±  )3rA  r  rÐ  r
  Únumbersr   r   rm  ÚnumpyrQ   Ú
matplotlibr@   rd  r   r   r   r   r	   Ú
mcolorizerr
   r>   r   r   rè   r   rù   r   r   r   Ú_enumsr   r   Údefine_aliasesÚColorizingArtistr$   rG  rS  r™  r±  ró  r  r  r  r   rF  rH  rn  rx  r8  r§  r±  r^   r^   r^   r_   Ú<module>   s^    4ú       0/ )Q sB ; 8l<? q