o
    Õjª'  ã                   @   sR   d Z ddlmZmZmZ ddlmZmZmZ ddl	m
Z
 dZG dd„ dejƒZd	S )
z¢
The inset module defines the InsetIndicator class, which draws the rectangle and
connectors required for `.Axes.indicate_inset` and `.Axes.indicate_inset_zoom`.
é   )Ú_apiÚartistÚ
transformsé    )ÚConnectionPatchÚ	PathPatchÚ	Rectangle)ÚPath)ÚalphaÚ	edgecolorÚ	linestyleÚ	linewidthc                       sœ   e Zd 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
dd„ Zdd„ Zdd„ Zedd„ ƒZedd„ ƒZdd„ Zejddddd „ ƒZ‡  ZS )"ÚInsetIndicatora  
    An artist to highlight an area of interest.

    An inset indicator is a rectangle on the plot at the position indicated by
    *bounds* that optionally has lines that connect the rectangle to an inset
    Axes (`.Axes.inset_axes`).

    .. versionadded:: 3.10
    gö(\Âõ@Nc           
         sª   |du r|du rt dƒ‚|| _|du rd| _|  ¡ }nd| _|\}}}}t||f||fddi|¤Ž| _g | _tƒ  ¡  |  	|¡ t
D ]}	t| d|	› t | j|	¡ƒ qBdS )aN  
        Parameters
        ----------
        bounds : [x0, y0, width, height], optional
            Lower-left corner of rectangle to be marked, and its width
            and height.  If not set, the bounds will be calculated from the
            data limits of inset_ax, which must be supplied.

        inset_ax : `~.axes.Axes`, optional
            An optional inset Axes to draw connecting lines to.  Two lines are
            drawn connecting the indicator box to the inset Axes on corners
            chosen so as to not overlap with the indicator box.

        zorder : float, default: 4.99
            Drawing order of the rectangle and connector lines.  The default,
            4.99, is just below the default level of inset Axes.

        **kwargs
            Other keyword arguments are passed on to the `.Rectangle` patch.
        Nz3At least one of bounds or inset_ax must be suppliedTFZclip_onÚ_)Ú
ValueErrorÚ	_inset_axÚ_auto_update_boundsÚ_bounds_from_inset_axr   Ú
_rectangleÚ_connectorsÚsuperÚ__init__Z
set_zorderÚ_shared_propertiesÚsetattrr   Úgetp)
ÚselfZboundsZinset_axÚzorderÚkwargsÚxÚyÚwidthÚheightÚprop©Ú	__class__© úQ/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/matplotlib/inset.pyr      s   


ÿzInsetIndicator.__init__c                 C   s.   t | d|› |ƒ t | jg| j¢||¡ dS )z`
        Helper function to set the same style property on the artist and its children.
        r   N)r   r   Zsetpr   r   )r   r"   Úvalr%   r%   r&   Ú_shared_setterJ   s   zInsetIndicator._shared_setterc                 C   s   |   d|¡ d S )Nr
   ©r(   )r   r
   r%   r%   r&   Ú	set_alphaR   s   zInsetIndicator.set_alphac                 C   ó   |   d|¡ dS )z™
        Set the edge color of the rectangle and the connectors.

        Parameters
        ----------
        color : :mpltype:`color` or None
        r   Nr)   )r   Úcolorr%   r%   r&   Úset_edgecolorV   ó   zInsetIndicator.set_edgecolorc                 C   s   |   d|¡ |   d|¡ dS )z¹
        Set the edgecolor of the rectangle and the connectors, and the
        facecolor for the rectangle.

        Parameters
        ----------
        c : :mpltype:`color`
        r   Z	facecolorNr)   )r   Úcr%   r%   r&   Ú	set_color`   s   	zInsetIndicator.set_colorc                 C   r+   )z“
        Set the linewidth in points of the rectangle and the connectors.

        Parameters
        ----------
        w : float or None
        r   Nr)   )r   Úwr%   r%   r&   Úset_linewidthl   r.   zInsetIndicator.set_linewidthc                 C   r+   )aã  
        Set the linestyle of the rectangle and the connectors.

        ==========================================  =================
        linestyle                                   description
        ==========================================  =================
        ``'-'`` or ``'solid'``                      solid line
        ``'--'`` or ``'dashed'``                    dashed line
        ``'-.'`` or ``'dashdot'``                   dash-dotted line
        ``':'`` or ``'dotted'``                     dotted line
        ``'none'``, ``'None'``, ``' '``, or ``''``  draw nothing
        ==========================================  =================

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

            (offset, onoffseq)

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

        Parameters
        ----------
        ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
            The line style.
        r   Nr)   )r   Zlsr%   r%   r&   Úset_linestylev   s   zInsetIndicator.set_linestylec                 C   s@   | j  ¡ }| j  ¡ }|d |d |d |d  |d |d  fS )Nr   r   )r   Zget_xlimZget_ylim)r   ZxlimZylimr%   r%   r&   r   ‘   s   

,z$InsetIndicator._bounds_from_inset_axc                 C   sÀ  | j  ¡ \}}| j  ¡ }| j  ¡ }| jpd gd }tg d¢|ƒD ]Y\}}|\}}	| jj ¡ r2d| }| jj	 ¡ r<d|	 }	|||  ||	|  f}
|d u rit
|| jj|
| jjd| j|  ¡ | j| jd	}| j |¡ q ||_|
|_| jj|_| jj|_q |d u rÞ| j ¡ }| | jddj¡}tj ||||¡ | j  ¡ ¡}|j|jk }|j |j k }|j!|j!k }|j"|j"k }| jd  #||A ¡ | jd  #||k¡ | jd	  #||k¡ | jd
  #||A ¡ d S d S )Né   ))r   r   )r   r   )r   r   )r   r   r   ú-)	ZxyAZcoordsAZxyBZcoordsBZ
arrowstyler   r
   r   r   F)Úrootr   é   é   )$r   Zget_xyZ	get_widthZ
get_heightr   ÚzipZaxesZxaxisZget_invertedZyaxisr   r   Z	transAxesZ	transDataZ
_edgecolorZ	get_alphaZ
_linestyleZ
_linewidthÚappendZxy1Zxy2Zcoords1Zcoords2Zget_positionZtransformedZ
get_figureZtransSubfigurer   ZBboxZfrom_boundsÚget_transformÚx0Úx1Úy0Úy1Zset_visible)r   r   r   r    r!   Zexisting_connectorsZxy_inset_axÚexistingÚexZeyZxy_dataÚpÚposZbboxinsZrectbboxr<   r=   r>   r?   r%   r%   r&   Ú_update_connectors–   sR   

ÿ
û

ÿóz!InsetIndicator._update_connectorsc                 C   s   | j S )z"`.Rectangle`: the indicator frame.)r   ©r   r%   r%   r&   Ú	rectangleÊ   s   zInsetIndicator.rectanglec                 C   s6   | j du rdS | jr| j |  ¡ ¡ |  ¡  t| jƒS )ai  
        4-tuple of `.patches.ConnectionPatch` or None
            The four connector lines connecting to (lower_left, upper_left,
            lower_right upper_right) corners of *inset_ax*. Two lines are
            set with visibility to *False*,  but the user can set the
            visibility to True if the automatic choice is not deemed correct.
        N)r   r   r   Z
set_boundsr   rD   Útupler   rE   r%   r%   r&   Ú
connectorsÏ   s   
	
zInsetIndicator.connectorsc           
      C   sÌ   g }| j pg D ]*}| ¡ r1d}tD ]}t | j|¡t ||¡kr)| |¡ d} nq|s1| |¡ q|r^| jg| }dd„ |D ƒ}tj	|Ž }t
|ƒ}	|	 | j¡ |	 t ¡ ¡ |	 |¡ d S | j |¡ d S )NFTc                 S   s   g | ]}|  ¡  | ¡ ¡‘qS r%   )r;   Ztransform_pathÚget_path)Ú.0Úar%   r%   r&   Ú
<listcomp>ø   s    z'InsetIndicator.draw.<locals>.<listcomp>)rH   Zget_visibler   r   r   r   Údrawr:   r	   Zmake_compound_pathr   Zupdate_fromZset_transformr   ZIdentityTransform)
r   ÚrendererZconn_same_styleÚconnZdrawnÚsZartistsÚpathsÚpathrB   r%   r%   r&   rM   à   s.   
ü
€

zInsetIndicator.drawz3.10zÞSince Matplotlib 3.10 indicate_inset_[zoom] returns a single InsetIndicator artist with a rectangle property and a connectors property.  From 3.12 it will no longer be possible to unpack the return value into two elements.)Úmessagec                 C   s   | j | jg| S )N)r   rH   )r   Úkeyr%   r%   r&   Ú__getitem__  s   zInsetIndicator.__getitem__)NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r(   r*   r-   r0   r2   r3   r   rD   ÚpropertyrF   rH   rM   r   Ú
deprecatedrU   Ú__classcell__r%   r%   r#   r&   r      s,    	0

4

&þr   N)rY   Ú r   r   r   Zmatplotlib.patchesr   r   r   Zmatplotlib.pathr	   r   ZArtistr   r%   r%   r%   r&   Ú<module>   s    