a
    ëÝEbÌv  ã                   @   sb  d Z ddlmZ ddlmZ ddlZddlmZm	Z	 ddl
mZ ddlmZ ddlmZ dd	„ ZG d
d„ dƒ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'eƒZ G d(d)„ d)eƒZ!dS )*a  
Default legend handlers.

.. important::

    This is a low-level legend API, which most end users do not need.

    We recommend that you are familiar with the :doc:`legend guide
    </tutorials/intermediate/legend_guide>` before reading this documentation.

Legend handlers are expected to be a callable object with a following
signature. ::

    legend_handler(legend, orig_handle, fontsize, handlebox)

Where *legend* is the legend itself, *orig_handle* is the original
plot, *fontsize* is the fontsize in pixels, and *handlebox* is a
OffsetBox instance. Within the call, you should create relevant
artists (using relevant properties from the *legend* and/or
*orig_handle*) and add them into the handlebox. The artists needs to
be scaled according to the fontsize (note that the size is in pixel,
i.e., this is dpi-scaled value).

This module includes definition of several legend handler classes
derived from the base class (HandlerBase) with the following method::

    def legend_artist(self, legend, orig_handle, fontsize, handlebox)
é    )ÚSequence)ÚcycleN)Ú_apiÚcbook©ÚLine2D)Ú	Rectanglec                 C   s(   t t| ¡ ƒd ƒ}|d ur$|  |¡ d S ©N)ÚnextÚiterZget_childrenÚupdate_from)ZtgtÚsrcZfirst_child© r   úY/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/legend_handler.pyÚupdate_from_first_child)   s    r   c                   @   sJ   e Z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S )ÚHandlerBasea   
    A Base class for default legend handlers.

    The derived classes are meant to override *create_artists* method, which
    has a following signature.::

      def create_artists(self, legend, orig_handle,
                         xdescent, ydescent, width, height, fontsize,
                         trans):

    The overridden method needs to create artists of the given
    transform that fits in the given dimension (xdescent, ydescent,
    width, height) that are scaled by fontsize if necessary.

    ç        Nc                 C   s   || | _ | _|| _d S r	   )Ú_xpadÚ_ypadÚ_update_prop_func)ÚselfZxpadZypadZupdate_funcr   r   r   Ú__init__?   s    zHandlerBase.__init__c                 C   s(   | j d u r|  ||¡ n|   ||¡ d S r	   )r   Ú_default_update_prop©r   Úlegend_handleÚorig_handler   r   r   Ú_update_propC   s    
zHandlerBase._update_propc                 C   s   |  |¡ d S r	   )r   r   r   r   r   r   I   s    z HandlerBase._default_update_propc                 C   s.   |   ||¡ | |¡ | d ¡ | d ¡ d S r	   )r   Z_set_artist_propsÚset_clip_boxÚset_clip_path©r   r   r   Úlegendr   r   r   Úupdate_propL   s    

zHandlerBase.update_propc                 C   sD   || j |  }|| j|  }|| j |  }|| j|  }||||fS r	   )r   r   )r   r    r   ÚxdescentÚydescentÚwidthÚheightÚfontsizer   r   r   Úadjust_drawing_areaT   s
    zHandlerBase.adjust_drawing_areac                 C   sr   |   |||j|j|j|j|¡\}}}}|  |||||||| ¡ ¡}	t|	tƒrV|	d g}	|	D ]}
| 	|
¡ qZ|	d S )a-  
        Return the artist that this HandlerBase generates for the given
        original artist/handle.

        Parameters
        ----------
        legend : `~matplotlib.legend.Legend`
            The legend for which these legend artists are being created.
        orig_handle : :class:`matplotlib.artist.Artist` or similar
            The object for which these legend artists are being created.
        fontsize : int
            The fontsize in pixels. The artists being created should
            be scaled according to the given fontsize.
        handlebox : `matplotlib.offsetbox.OffsetBox`
            The box which has been created to hold this legend entry's
            artists. Artists created in the `legend_artist` method must
            be added to this handlebox inside this method.

        r   )
r'   r"   r#   r$   r%   Úcreate_artistsZget_transformÚ
isinstanceÚ_Line2DHandleListZ
add_artist)r   r    r   r&   Z	handleboxr"   r#   r$   r%   ÚartistsÚar   r   r   Úlegend_artist]   s    üþ

zHandlerBase.legend_artistc	           	      C   s   t dƒ‚d S )NzDerived must override)ÚNotImplementedError)	r   r    r   r"   r#   r$   r%   r&   Útransr   r   r   r(   …   s    zHandlerBase.create_artists)r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r!   r'   r-   r(   r   r   r   r   r   /   s   
	(r   c                       s2   e Zd ZdZd
‡ fdd„	Zdd„ Zdd	„ Z‡  ZS )ÚHandlerNpointszM
    A legend handler that shows *numpoints* points in the legend entry.
    ç333333Ó?Nc                    s"   t ƒ jf i |¤Ž || _|| _dS )a  
        Parameters
        ----------
        marker_pad : float
            Padding between points in legend entry.
        numpoints : int
            Number of points to show in legend entry.
        **kwargs
            Keyword arguments forwarded to `.HandlerBase`.
        N)Úsuperr   Ú
_numpointsÚ_marker_pad©r   Ú
marker_padÚ	numpointsÚkwargs©Ú	__class__r   r   r   �   s    zHandlerNpoints.__init__c                 C   s   | j d u r|jS | j S d S r	   )r7   r;   ©r   r    r   r   r   Úget_numpoints    s    
zHandlerNpoints.get_numpointsc                 C   sh   |   |¡}|dkr@| j| }t | | | | | |¡}	|	}
n | | | g}	| d|  g}
|	|
fS )Né   ç      à?)r@   r8   ÚnpÚlinspace)r   r    r"   r#   r$   r%   r&   r;   ÚpadÚxdataÚxdata_markerr   r   r   Ú	get_xdata¦   s    

þzHandlerNpoints.get_xdata)r5   N)r0   r1   r2   r3   r   r@   rH   Ú__classcell__r   r   r=   r   r4   ‹   s   r4   c                       s*   e Zd ZdZd‡ fdd„	Zdd„ Z‡  ZS )ÚHandlerNpointsYoffsetsz‚
    A legend handler that shows *numpoints* in the legend, and allows them to
    be individually offset in the y-direction.
    Nc                    s    t ƒ jf d|i|¤Ž || _dS )aL  
        Parameters
        ----------
        numpoints : int
            Number of points to show in legend entry.
        yoffsets : array of floats
            Length *numpoints* list of y offsets for each point in
            legend entry.
        **kwargs
            Keyword arguments forwarded to `.HandlerNpoints`.
        r;   N)r6   r   Ú	_yoffsets)r   r;   Úyoffsetsr<   r=   r   r   r   »   s    zHandlerNpointsYoffsets.__init__c                 C   s*   | j d u r||j }n|t | j ¡ }|S r	   ©rK   Z_scatteryoffsetsrC   Úasarray©r   r    r"   r#   r$   r%   r&   Úydatar   r   r   Ú	get_ydataÊ   s    
z HandlerNpointsYoffsets.get_ydata)NN)r0   r1   r2   r3   r   rQ   rI   r   r   r=   r   rJ   µ   s   rJ   c                       s*   e Zd ZdZd‡ fdd„	Zdd„ Z‡  ZS )	ÚHandlerLine2DCompoundz™
    Original handler for `.Line2D` instances, that relies on combining
    a line-only with a marker-only artist.  May be deprecated in the future.
    r5   Nc                    s   t ƒ jf ||dœ|¤Ž dS ©a  
        Parameters
        ----------
        marker_pad : float
            Padding between points in legend entry.
        numpoints : int
            Number of points to show in legend entry.
        **kwargs
            Keyword arguments forwarded to `.HandlerNpoints`.
        ©r:   r;   N)r6   r   r9   r=   r   r   r   Ù   s    zHandlerLine2DCompound.__init__c	                 C   sÊ   |   ||||||¡\}	}
t |	|| d ¡}t|	|ƒ}|  |||¡ | d¡ | d¡ t|
|d t|
ƒ… ƒ}|  |||¡ | d¡ |j	dkr¨| 
¡ |j	 }| |¡ ||_| |¡ | |¡ ||gS )Né   ÚdefaultÚ ÚNonerA   )rH   rC   Ú	full_liker   r!   Úset_drawstyleÚ
set_markerÚlenÚset_linestyleÚmarkerscaleÚget_markersizeÚset_markersizeZ
_legmarkerÚset_transform)r   r    r   r"   r#   r$   r%   r&   r/   rF   rG   rP   ÚleglineÚlegline_markerÚnewszr   r   r   r(   æ   s$    
ÿ







z$HandlerLine2DCompound.create_artists)r5   N©r0   r1   r2   r3   r   r(   rI   r   r   r=   r   rR   Ó   s   rR   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )r*   c                 C   s
   || _ d S r	   )Ú_legline)r   rb   r   r   r   r     s    z_Line2DHandleList.__init__c                 C   s   dS ©NrU   r   )r   r   r   r   Ú__len__	  s    z_Line2DHandleList.__len__c                 C   s&   |dkrt jddd� | j| jg| S )Nr   z3.5zuAccess to the second element returned by HandlerLine2D is deprecated since %(since)s; it will be removed %(removal)s.)Úmessage)r   Zwarn_deprecatedrf   )r   Úindexr   r   r   Ú__getitem__  s
    ÿz_Line2DHandleList.__getitem__N)r0   r1   r2   r   rh   rk   r   r   r   r   r*     s   r*   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )	ÚHandlerLine2Dzâ
    Handler for `.Line2D` instances.

    See Also
    --------
    HandlerLine2DCompound : An earlier handler implementation, which used one
                            artist for the line and another for the marker(s).
    r5   Nc                 K   s   t j| f||dœ|¤Ž dS rS   )r4   r   )r   r:   r;   Úkwr   r   r   r   !  s
    
ÿÿzHandlerLine2D.__init__c	                 C   sª   |   ||||||¡\}	}
d }|  |¡dkrFt |	d |	d d¡}	dg}t |	|| d ¡}t|	||d�}|  |||¡ |jdkr˜| ¡ |j }| 	|¡ | 
|¡ t|ƒS )NrA   r   éÿÿÿÿé   rU   )Ú	markevery)rH   r@   rC   rD   rY   r   r!   r^   r_   r`   ra   r*   )r   r    r   r"   r#   r$   r%   r&   r/   rF   rG   rp   rP   rb   rd   r   r   r   r(   /  s    
ÿ


zHandlerLine2D.create_artists)r5   N)r0   r1   r2   r3   r   r(   r   r   r   r   rl     s   	
rl   c                       s2   e Zd ZdZd	‡ fdd„	Zdd„ Zdd„ Z‡  ZS )
ÚHandlerPatchz)
    Handler for `.Patch` instances.
    Nc                    s   t ƒ jf i |¤Ž || _dS )a…  
        Parameters
        ----------
        patch_func : callable, optional
            The function that creates the legend key artist.
            *patch_func* should have the signature::

                def patch_func(legend=legend, orig_handle=orig_handle,
                               xdescent=xdescent, ydescent=ydescent,
                               width=width, height=height, fontsize=fontsize)

            Subsequently the created artist will have its ``update_prop``
            method called and the appropriate transform will be applied.

        **kwargs
            Keyword arguments forwarded to `.HandlerBase`.
        N)r6   r   Ú_patch_func)r   Z
patch_funcr<   r=   r   r   r   Q  s    zHandlerPatch.__init__c           	   	   C   s>   | j d u r"t| | f||d�}n| j |||||||d�}|S )N©Úxyr$   r%   )r    r   r"   r#   r$   r%   r&   )rr   r   ©	r   r    r   r"   r#   r$   r%   r&   Úpr   r   r   Ú_create_patchf  s    
ÿþzHandlerPatch._create_patchc	           
   	   C   s4   |   |||||||¡}	|  |	||¡ |	 |¡ |	gS r	   )rw   r!   ra   ©
r   r    r   r"   r#   r$   r%   r&   r/   rv   r   r   r   r(   q  s    
ÿ
zHandlerPatch.create_artists)N)r0   r1   r2   r3   r   rw   r(   rI   r   r   r=   r   rq   L  s   rq   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚHandlerStepPatchzA
    Handler for `~.matplotlib.patches.StepPatch` instances.
    c           	      C   s    t | | f| ¡ ||d�}|S )N)rt   Úcolorr$   r%   )r   Úget_facecolorru   r   r   r   rw     s
    þzHandlerStepPatch._create_patchc           	      C   sF   t d|g|d |d g| ¡ | ¡ | ¡ d�}| d¡ | d¡ |S )Nr   rU   )rz   Z	linestyleZ	linewidthrV   rW   )r   Úget_edgecolorÚget_linestyleZget_linewidthrZ   r[   )	r   r    r   r"   r#   r$   r%   r&   rb   r   r   r   Ú_create_line‡  s    ý

zHandlerStepPatch._create_linec	           
   	   C   s`   |  ¡ s| ¡ d ur:|  |||||||¡}	|  |	||¡ n|  |||||||¡}	|	 |¡ |	gS r	   )Úget_fillÚ	get_hatchrw   r!   r~   ra   rx   r   r   r   r(   •  s    
ÿ
ÿ
zHandlerStepPatch.create_artistsN)r0   r1   r2   r3   rw   r~   r(   r   r   r   r   ry   z  s   ry   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚHandlerLineCollectionz2
    Handler for `.LineCollection` instances.
    c                 C   s   | j d u r|jS | j S d S r	   ©r7   Zscatterpointsr?   r   r   r   r@   ¦  s    
z#HandlerLineCollection.get_numpointsc                 C   sD   |  ¡ d }|jd }| ¡ d }| |¡ | |¡ | |¡ d S ©Nr   )Úget_linewidthsZ_us_linestylesZ
get_colorsÚ	set_colorr]   Úset_linewidth)r   r   r   ZlwÚdashesrz   r   r   r   r   ¬  s    


z*HandlerLineCollection._default_update_propc	                 C   sT   |   ||||||¡\}	}
t |	|| d ¡}t|	|ƒ}|  |||¡ | |¡ |gS rg   )rH   rC   rY   r   r!   ra   )r   r    r   r"   r#   r$   r%   r&   r/   rF   rG   rP   rb   r   r   r   r(   ´  s    
ÿ

z$HandlerLineCollection.create_artistsN)r0   r1   r2   r3   r@   r   r(   r   r   r   r   r�   ¢  s   r�   c                       sJ   e Zd ZdZd‡ fdd„	Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	‡  Z
S )ÚHandlerRegularPolyCollectionz'Handler for `.RegularPolyCollection`\s.Nc                    s    t ƒ jf d|i|¤Ž || _d S )NrL   )r6   r   Ú_sizes)r   rL   Úsizesr<   r=   r   r   r   Å  s    z%HandlerRegularPolyCollection.__init__c                 C   s   | j d u r|jS | j S d S r	   r‚   r?   r   r   r   r@   Ê  s    
z*HandlerRegularPolyCollection.get_numpointsc                 C   sœ   | j d u r’| ¡ }t|ƒs dg}t|ƒ|jd  }	t|ƒ|jd  }
|  |¡}|dk rrd|	|
  |	|
gd |… }q˜|	|
 }|t dd|¡ |
 }n| j }|S )NrA   rU   é   rB   r   )	r‰   Ú	get_sizesr\   Úmaxr^   Úminr@   rC   rD   )r   r    r   r"   r#   r$   r%   r&   Zhandle_sizesZsize_maxZsize_minr;   rŠ   Úrngr   r   r   rŒ   Ð  s"    

ÿÿz&HandlerRegularPolyCollection.get_sizesc                 C   s0   |   ||¡ | |j¡ | d ¡ | d ¡ d S r	   )r   Ú
set_figureÚfigurer   r   r   r   r   r   r!   å  s    
z(HandlerRegularPolyCollection.update_propc                 C   s"   t |ƒ| ¡ | ¡ |||d�}|S )N)ZrotationrŠ   ÚoffsetsÚtransOffset)ÚtypeZget_numsidesZget_rotation©r   r   rŠ   r’   r“   rv   r   r   r   Úcreate_collectionî  s    üz.HandlerRegularPolyCollection.create_collectionc	              	   C   sx   |   ||||||¡\}	}
|  ||||||¡}|  |||||||¡}| j||tt|
|ƒƒ|d�}|  |||¡ ||_|gS ©N)r’   r“   )rH   rQ   rŒ   r–   ÚlistÚzipr!   Z_transOffset)r   r    r   r"   r#   r$   r%   r&   r/   rF   rG   rP   rŠ   rv   r   r   r   r(   ÷  s     
ÿ
ÿÿþz+HandlerRegularPolyCollection.create_artists)NN)r0   r1   r2   r3   r   r@   rŒ   r!   r–   r(   rI   r   r   r=   r   rˆ   Â  s   		rˆ   c                   @   s   e Zd ZdZdd„ ZdS )ÚHandlerPathCollectionzDHandler for `.PathCollection`\s, which are used by `~.Axes.scatter`.c                 C   s"   t |ƒ| ¡ d g|||d�}|S )Nr   )rŠ   r’   r“   )r”   Ú	get_pathsr•   r   r   r   r–     s    ýz'HandlerPathCollection.create_collectionN©r0   r1   r2   r3   r–   r   r   r   r   rš     s   rš   c                   @   s   e Zd ZdZdd„ ZdS )ÚHandlerCircleCollectionz"Handler for `.CircleCollection`\s.c                 C   s   t |ƒ|||d�}|S r—   )r”   r•   r   r   r   r–     s
    þz)HandlerCircleCollection.create_collectionNrœ   r   r   r   r   r�     s   r�   c                       s2   e Zd ZdZd‡ fdd„	Zdd„ Zd	d
„ Z‡  ZS )ÚHandlerErrorbarzHandler for Errorbars.rB   Nr5   c                    s(   || _ || _tƒ jf ||dœ|¤Ž d S )NrT   )Ú
_xerr_sizeÚ
_yerr_sizer6   r   )r   Ú	xerr_sizeÚ	yerr_sizer:   r;   r<   r=   r   r   r   $  s    zHandlerErrorbar.__init__c           	      C   s,   | j | }| jd u r|}n
| j| }||fS r	   )rŸ   r    )	r   r    r"   r#   r$   r%   r&   r¡   r¢   r   r   r   Úget_err_size,  s
    


zHandlerErrorbar.get_err_sizec	                    sš  |\}	}
}|   ||||||¡\}}t ||| d ¡}t||ƒ}t |¡}t |d t|ƒ… ¡}|  ||||||¡\‰ ‰t||ƒ}|	d u r | d¡ | d¡ n\|  ||	|¡ | 	d¡ | 
d¡ |  ||	|¡ | d¡ |jdkrü| ¡ |j }| |¡ g }g }|j�r¸‡ fdd„t||ƒD ƒ}t |¡}|  ||d |¡ | |¡ |
�r¸t|ˆ  |ƒ}t|ˆ  |ƒ}|  ||
d |¡ |  ||
d |¡ | 
d	¡ | 
d	¡ | |¡ | |¡ |j�rl‡fd
d„t||ƒD ƒ}t |¡}|  ||d |¡ | |¡ |
�rlt||ˆ ƒ}t||ˆ ƒ}|  ||
d |¡ |  ||
d |¡ | 
d¡ | 
d¡ | |¡ | |¡ g |¢|¢|‘|‘}|D ]}| |¡ �q„|S )NrU   FrV   rX   rA   c                    s(   g | ] \}}|ˆ  |f|ˆ  |ff‘qS r   r   ©Ú.0ÚxÚy)r¡   r   r   Ú
<listcomp>a  s   ÿz2HandlerErrorbar.create_artists.<locals>.<listcomp>r   ú|c                    s(   g | ] \}}||ˆ  f||ˆ  ff‘qS r   r   r¤   )r¢   r   r   r¨   s  s   ÿÚ_)rH   rC   rY   r   rN   r\   r£   Zset_visibler!   rZ   r[   r]   r^   r_   r`   Zhas_xerrr™   ÚmcollÚLineCollectionÚappendZhas_yerrra   )r   r    r   r"   r#   r$   r%   r&   r/   Z	plotlinesZcaplinesZbarlinecolsrF   rG   rP   rb   Zydata_markerrc   rd   Zhandle_barlinecolsZhandle_caplinesZvertsZcollZcapline_leftZcapline_rightr+   Úartistr   )r¡   r¢   r   r(   7  sŠ    

ÿ


ÿ







ÿ






ÿ





ÿÿÿÿzHandlerErrorbar.create_artists)rB   Nr5   N)r0   r1   r2   r3   r   r£   r(   rI   r   r   r=   r   rž   !  s     ÿrž   c                       s:   e Zd ZdZd‡ fdd„	Zdd„ Zdd	„ Zd
d„ Z‡  ZS )ÚHandlerStemz6
    Handler for plots produced by `~.Axes.stem`.
    r5   Nc                    s$   t ƒ jf |||dœ|¤Ž || _dS )aç  
        Parameters
        ----------
        marker_pad : float, default: 0.3
            Padding between points in legend entry.
        numpoints : int, optional
            Number of points to show in legend entry.
        bottom : float, optional

        yoffsets : array of floats, optional
            Length *numpoints* list of y offsets for each point in
            legend entry.
        **kwargs
            Keyword arguments forwarded to `.HandlerNpointsYoffsets`.
        )r:   r;   rL   N)r6   r   Ú_bottom)r   r:   r;   ÚbottomrL   r<   r=   r   r   r   ‘  s    ÿÿzHandlerStem.__init__c                 C   s2   | j d u r|d|j d  }n|t | j ¡ }|S )NrB   rM   rO   r   r   r   rQ   ¦  s    
zHandlerStem.get_ydatac	                    sZ  |\}	}
}t |
tjƒ}|  ||||||¡\}}|  ||||||¡}| jd u rRd‰ n| j‰ t||d t|ƒ… ƒ}|  ||	|¡ ‡ fdd„t	||ƒD ƒ}|rât
j| | jd��( |D ]}|  ||
|¡ q®W d   ƒ n1 sÖ0    Y  n"t	||
ƒD ]\}}|  |||¡ qìtt |¡t |¡gˆ ˆ gƒ}|  |||¡ g |¢|‘|‘}|D ]}| |¡ �qD|S )Nr   c                    s"   g | ]\}}t ||gˆ |gƒ‘qS r   r   r¤   ©r±   r   r   r¨   Å  s   ÿz.HandlerStem.create_artists.<locals>.<listcomp>)r   )r)   r«   r¬   rH   rQ   r°   r   r\   r!   r™   r   Z_setattr_cmÚ_copy_collection_propsrC   rŽ   r�   ra   )r   r    r   r"   r#   r$   r%   r&   r/   Z
markerlineZ	stemlinesZbaselineZusing_linecollrF   rG   rP   Zleg_markerlineZleg_stemlinesÚlineZlmÚmZleg_baseliner+   r®   r   r²   r   r(   ®  s@    

ÿ
ÿ

ÿÿ0ÿzHandlerStem.create_artistsc                 C   s(   |  | ¡ d ¡ | | ¡ d ¡ dS )zt
        Copy properties from the `.LineCollection` *orig_handle* to the
        `.Line2D` *legend_handle*.
        r   N)r…   Ú	get_colorr]   r}   r   r   r   r   r³   Ý  s    z"HandlerStem._copy_collection_props)r5   NNN)	r0   r1   r2   r3   r   rQ   r(   r³   rI   r   r   r=   r   r¯   Œ  s     ÿ/r¯   c                       s*   e Zd ZdZd‡ fdd„	Zdd„ Z‡  ZS )	ÚHandlerTuplez
    Handler for Tuple.
    rA   Nc                    s"   || _ || _tƒ jf i |¤Ž dS )a…  
        Parameters
        ----------
        ndivide : int, default: 1
            The number of sections to divide the legend area into.  If None,
            use the length of the input tuple.
        pad : float, default: :rc:`legend.borderpad`
            Padding in units of fraction of font size.
        **kwargs
            Keyword arguments forwarded to `.HandlerBase`.
        N)Ú_ndivideÚ_padr6   r   )r   ÚndividerE   r<   r=   r   r   r   ë  s    zHandlerTuple.__init__c	                 C   sÐ   |  ¡ }	| jd u rt|ƒ}
n| j}
| jd u r8|j| }n
| j| }|
dkr^|||
d   |
 }t||| t |
¡  ƒ}g }|D ]J}| |	|¡}| 	||t
|ƒ|||||¡}t|tƒrÀ|d g}| |¡ q€|S )NrA   r   )Zget_legend_handler_mapr¸   r\   r¹   Z	borderpadr   rC   ZarangeZget_legend_handlerr(   r
   r)   r*   Úextend)r   r    r   r"   r#   r$   r%   r&   r/   Zhandler_maprº   rE   Z	xds_cycleÚa_listZhandle1ÚhandlerZ_a_listr   r   r   r(   û  s*    



þ

zHandlerTuple.create_artists)rA   Nre   r   r   r=   r   r·   æ  s   r·   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚHandlerPolyCollectionza
    Handler for `.PolyCollection` used in `~.Axes.fill_between` and
    `~.Axes.stackplot`.
    c                 C   s�   dd„ }dd„ }||  ¡ ƒ|_|| ¡ ƒ|_| ¡ |_| ¡ |_|j|_| 	|| 
¡ ƒ¡ | || ¡ ƒ¡ | || ¡ ƒ¡ | | ¡ ¡ d S )Nc                 S   s   | j dkrdS t| d ƒS )Nr   )r   r   r   r   )ÚsizeÚtuple)Úcolorsr   r   r   Úfirst_color#  s    
z7HandlerPolyCollection._update_prop.<locals>.first_colorc                 S   s   t | ƒr| d S d S d S rƒ   )r\   )Z
prop_arrayr   r   r   Ú	get_first(  s    z5HandlerPolyCollection._update_prop.<locals>.get_first)r{   Z
_facecolorr|   Z
_edgecolorr   Z_fillr€   Z_hatchZ_hatch_colorr†   r„   r]   Zget_linestylesra   Zget_transformsr�   Z
get_figure)r   r   r   rÂ   rÃ   r   r   r   r   "  s    

z"HandlerPolyCollection._update_propc	           
      C   s4   t | | f||d�}	|  |	||¡ |	 |¡ |	gS )Nrs   )r   r!   ra   rx   r   r   r   r(   =  s    ÿ
z$HandlerPolyCollection.create_artistsN)r0   r1   r2   r3   r   r(   r   r   r   r   r¾     s   r¾   )"r3   Úcollections.abcr   Ú	itertoolsr   ÚnumpyrC   Z
matplotlibr   r   Zmatplotlib.linesr   Zmatplotlib.patchesr   Zmatplotlib.collectionsÚcollectionsr«   r   r   r4   rJ   rR   r*   rl   rq   ry   r�   rˆ   rš   r�   rž   r¯   r·   r¾   r   r   r   r   Ú<module>   s0   \*25.( J
kZ7