a
    Sic&|                 	   @   s  d Z ddlZddlZddlZddlmZ ddlZddlmZ ddl	Z
ddlZddlmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZm Z  ddl!m"Z" dd	l#m$Z$m%Z% ej&e'd
gdgdg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)Z0G d d! d!e)Z1G d"d# d#e/Z2ej&j3d$4e5e2j6pd%7 d&d d' G d(d) d)e,Z8G d*d+ d+e)Z9G d,d- d-e)Z:G d.d/ d/e9Z;G d0d1 d1e9Z<dKd3d4Z=dLd6d7Z>G d8d9 d9Z?dMdd:d;d<Z@ejAG d=d> d>e?ZBejAG d?d@ d@e?ZCdAdB ZDejAG dCdD dDe?ZEG dEdF dFe)ZFG dGdH dHe)ZGG dIdJ dJeGZHdS )Nz>
Patches are `.Artist`\s with a face color and an edge color.
    N)Number)
namedtuple   )_apiartistcbookcolors
_docstringhatchlines
transforms)NonIntersectingPathExceptionget_cos_singet_intersectionget_parallelsinside_circlemake_wedged_bezier2)split_bezier_intersecting_with_closedpathsplit_path_inout)Path)	JoinStyleCapStyleaaecfclslw)antialiased	edgecolor	facecolor	linestyle	linewidthc                       s  e Zd ZdZdZdZejddddU fd	d
	Zdd Z	dd Z
dVddZdWddZdXddZ 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d'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Z fd5d6Zd7d8 Zd9d: Z d;d< Z!d=d> Z"e#e"e!Z$e%j&d?d@ Z'dAdB Z(e%j&dCdD Z)dEdF Z*dGdH Z+dIdJ Z,dKdL Z-e.j/dMdN Z0dOdP Z1dYdQdRZ2dSdT Z3  Z4S )ZPatchz
    A patch is a 2D artist with a face color and an edge color.

    If any of *edgecolor*, *facecolor*, *linewidth*, or *antialiased*
    are *None*, they default to their rc params setting.
    r   F3.6r   nameNTc                    s   t    |du rd}|	du r$tj}	|
du r2tj}
ttj	d | _
d| _|durx|dusb|durltd | | n| | | | d| _d| _d| _| | | | | | | | | | | |	 | |
 t|r| | dS )zW
        The following kwarg properties are supported

        %(Patch:kwdoc)s
        Nsolidzhatch.colorTzQSetting the 'color' property will override the edgecolor or facecolor properties.r   )r   N)super__init__r   buttr   miterr   to_rgbamplrcParams_hatch_color_fillr   warn_external	set_colorset_edgecolorset_facecolor
_linewidth_unscaled_dash_pattern_dash_patternset_fillset_linestyleset_linewidthset_antialiased	set_hatchset_capstyleset_joinstylelen_internal_update)selfr   r   colorr!   r    r   r
   fillcapstyle	joinstylekwargs	__class__ N/var/www/html/django/DPS/env/lib/python3.9/site-packages/matplotlib/patches.pyr(   .   s:    









zPatch.__init__c                 C   s.   |   }|  }||}t|r*|d S g S )z
        Return a copy of the vertices used in this patch.

        If the patch contains Bezier curves, the curves will be interpolated by
        line segments.  To access the curves as curves, use `get_path`.
        r   )get_transformget_pathto_polygonsr>   )r@   transpathZpolygonsrH   rH   rI   	get_vertsd   s    
zPatch.get_vertsc                 C   sB   |d ur|S t | jtr | j}n|  d dkr6d}n|  }|S )N   r   )
isinstance_pickerr   get_edgecolorget_linewidth)r@   radiusZ_radiusrH   rH   rI   _process_radiusr   s    zPatch._process_radiusc           	         s     \}}|dur||fS  j}|dur j}t|tjk\}|dd }t	tt
||t
||}n
 g}t fdd|D }|i fS )z
        Test whether the mouse event occurred in the patch.

        Returns
        -------
        (bool, empty dict)
        Nr   c                 3   s(   | ] }|  j jf V  qd S N)contains_pointxyrJ   ).0subpath
mouseeventrU   r@   rH   rI   	<genexpr>   s   z!Patch.contains.<locals>.<genexpr>)_default_containsrV   rK   codesverticesnpwherer   MOVETOmapsplitany)	r@   r^   rU   insideinfora   rb   idxsZsubpathsrH   r]   rI   contains~   s"    



zPatch.containsc                 C   s    |  |}|  ||  |S )a@  
        Return whether the given point is inside the patch.

        Parameters
        ----------
        point : (float, float)
            The point (x, y) to check, in target coordinates of
            ``self.get_transform()``. These are display coordinates for patches
            that are added to a figure or axes.
        radius : float, optional
            Add an additional margin on the patch in target coordinates of
            ``self.get_transform()``. See `.Path.contains_point` for further
            details.

        Returns
        -------
        bool

        Notes
        -----
        The proper use of this method depends on the transform of the patch.
        Isolated patches do not have a transform. In this case, the patch
        creation coordinates and the point coordinates match. The following
        example checks that the center of a circle is within the circle

        >>> center = 0, 0
        >>> c = Circle(center, radius=1)
        >>> c.contains_point(center)
        True

        The convention of checking against the transformed patch stems from
        the fact that this method is predominantly used to check if display
        coordinates (e.g. from mouse events) are within the patch. If you want
        to do the above check with data coordinates, you have to properly
        transform them first:

        >>> center = 0, 0
        >>> c = Circle(center, radius=1)
        >>> plt.gca().add_patch(c)
        >>> transformed_center = c.get_transform().transform(center)
        >>> c.contains_point(transformed_center)
        True

        )rV   rK   rX   rJ   )r@   pointrU   rH   rH   rI   rX      s
    -

zPatch.contains_pointc                 C   s    |  |}|  ||  |S )a  
        Return whether the given points are inside the patch.

        Parameters
        ----------
        points : (N, 2) array
            The points to check, in target coordinates of
            ``self.get_transform()``. These are display coordinates for patches
            that are added to a figure or axes. Columns contain x and y values.
        radius : float, optional
            Add an additional margin on the patch in target coordinates of
            ``self.get_transform()``. See `.Path.contains_point` for further
            details.

        Returns
        -------
        length-N bool array

        Notes
        -----
        The proper use of this method depends on the transform of the patch.
        See the notes on `.Patch.contains_point`.
        )rV   rK   contains_pointsrJ   )r@   pointsrU   rH   rH   rI   rn      s
    

zPatch.contains_pointsc                    st   t  | |j| _|j| _|j| _|j| _|j| _|j| _|j| _|j	| _	| 
|j | |  | | _d S rW   )r'   update_from
_edgecolor
_facecolor_original_edgecolor_original_facecolorr/   _hatchr.   r5   r9   r4   set_transformget_data_transformis_transform_set_transformSet)r@   otherrF   rH   rI   rp      s    zPatch.update_fromc                 C   s   |   |  S )zU
        Return the `Patch`'s axis-aligned extents as a `~.transforms.Bbox`.
        rK   get_extentsrJ   r@   rH   rH   rI   r|      s    zPatch.get_extentsc                 C   s   |   tj|  S )z;Return the `~.transforms.Transform` applied to the `Patch`.)get_patch_transformr   ArtistrJ   r}   rH   rH   rI   rJ     s    zPatch.get_transformc                 C   s   t j| S )zo
        Return the `~.transforms.Transform` mapping data coordinates to
        physical coordinates.
        )r   r   rJ   r}   rH   rH   rI   rw     s    zPatch.get_data_transformc                 C   s   t  S )aS  
        Return the `~.transforms.Transform` instance mapping patch coordinates
        to data coordinates.

        For example, one may define a patch of a circle which represents a
        radius of 5 by providing coordinates for a unit circle, and a
        transform which scales the coordinates (the patch coordinate) by 5.
        )r   IdentityTransformr}   rH   rH   rI   r~     s    	zPatch.get_patch_transformc                 C   s   | j S )z0Return whether antialiasing is used for drawing.)_antialiasedr}   rH   rH   rI   get_antialiased  s    zPatch.get_antialiasedc                 C   s   | j S )zReturn the edge color.)rq   r}   rH   rH   rI   rS     s    zPatch.get_edgecolorc                 C   s   | j S )zReturn the face color.rr   r}   rH   rH   rI   get_facecolor"  s    zPatch.get_facecolorc                 C   s   | j S )z Return the line width in points.)r4   r}   rH   rH   rI   rT   &  s    zPatch.get_linewidthc                 C   s   | j S )zReturn the linestyle.)
_linestyler}   rH   rH   rI   get_linestyle*  s    zPatch.get_linestylec                 C   s"   |du rt jd }|| _d| _dS )z|
        Set whether to use antialiased rendering.

        Parameters
        ----------
        aa : bool or None
        Nzpatch.antialiasedT)r,   r-   r   stale)r@   r   rH   rH   rI   r:   .  s    
zPatch.set_antialiasedc                 C   s\   d}|d u r6t jd s"| jr"| jr.t jd }nd}d}t|| j| _|rR| j| _d| _	d S )NTzpatch.force_edgecolorzpatch.edgecolornoneF)
r,   r-   r/   _edge_defaultr   r+   _alpharq   r.   r   )r@   rA   set_hatch_colorrH   rH   rI   _set_edgecolor;  s    
zPatch._set_edgecolorc                 C   s   || _ | | dS )zp
        Set the patch edge color.

        Parameters
        ----------
        color : color or None
        N)rs   r   r@   rA   rH   rH   rI   r2   J  s    zPatch.set_edgecolorc                 C   s:   |d u rt jd }| jr| jnd}t||| _d| _d S )Nzpatch.facecolorr   T)r,   r-   r/   r   r   r+   rr   r   )r@   rA   alpharH   rH   rI   _set_facecolorU  s
    
zPatch._set_facecolorc                 C   s   || _ | | dS )zp
        Set the patch face color.

        Parameters
        ----------
        color : color or None
        N)rt   r   r   rH   rH   rI   r3   \  s    zPatch.set_facecolorc                 C   s   |  | | | dS )a  
        Set both the edgecolor and the facecolor.

        Parameters
        ----------
        c : color

        See Also
        --------
        Patch.set_facecolor, Patch.set_edgecolor
            For setting the edge or face color individually.
        N)r3   r2   )r@   crH   rH   rI   r1   g  s    
zPatch.set_colorc                    s(   t  | | | j | | j d S rW   )r'   	set_alphar   rt   r   rs   )r@   r   rF   rH   rI   r   w  s    zPatch.set_alphac                 C   s>   |du rt jd }t|| _tjg | j|R  | _d| _dS )zu
        Set the patch linewidth in points.

        Parameters
        ----------
        w : float or None
        Nzpatch.linewidthT)	r,   r-   floatr4   mlines_scale_dashesr5   r6   r   r@   wrH   rH   rI   r9   ~  s    


zPatch.set_linewidthc                 C   sN   |du rd}|dv rd}|| _ t|| _tjg | j| jR  | _d| _dS )a  
        Set the patch linestyle.

        ==========================================  =================
        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.
        Nr&   )  r   NoneT)r   r   _get_dash_patternr5   r   r4   r6   r   )r@   r   rH   rH   rI   r8     s    
zPatch.set_linestylec                 C   s,   t || _| | j | | j d| _dS )zh
        Set whether to fill the patch.

        Parameters
        ----------
        b : bool
        TN)boolr/   r   rt   r   rs   r   r@   brH   rH   rI   r7     s    
zPatch.set_fillc                 C   s   | j S )z#Return whether the patch is filled.)r/   r}   rH   rH   rI   get_fill  s    zPatch.get_fillc                 C   s   t |}|| _d| _dS )z
        Set the `.CapStyle`.

        The default capstyle is 'round' for `.FancyArrowPatch` and 'butt' for
        all other patches.

        Parameters
        ----------
        s : `.CapStyle` or %(CapStyle)s
        TN)r   	_capstyler   )r@   scsrH   rH   rI   r<     s    zPatch.set_capstylec                 C   s   | j jS )zReturn the capstyle.)r   r%   r}   rH   rH   rI   get_capstyle  s    zPatch.get_capstylec                 C   s   t |}|| _d| _dS )z
        Set the `.JoinStyle`.

        The default joinstyle is 'round' for `.FancyArrowPatch` and 'miter' for
        all other patches.

        Parameters
        ----------
        s : `.JoinStyle` or %(JoinStyle)s
        TN)r   
_joinstyler   )r@   r   jsrH   rH   rI   r=     s    zPatch.set_joinstylec                 C   s   | j jS )zReturn the joinstyle.)r   r%   r}   rH   rH   rI   get_joinstyle  s    zPatch.get_joinstylec                 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.

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

        Parameters
        ----------
        hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
        TN)mhatch_validate_hatch_patternru   r   )r@   r
   rH   rH   rI   r;     s    
zPatch.set_hatchc                 C   s   | j S )zReturn the hatching pattern.)ru   r}   rH   rH   rI   	get_hatch  s    zPatch.get_hatchc                 C   sJ  | d|   | }|j| jdd | j}| jd dksF| jdkrJd}|| |j| j	  |
| j || j || j | | || j ||   || j | jr|| j || j |  dur|j|    |  rddlm} ||  |}|D ]}|j |g|R   q|!  |"d d	| _#dS )
aJ  
        ``draw()`` helper factored out for sharing with `FancyArrowPatch`.

        Configure *renderer* and the associated graphics context *gc*
        from the artist properties, then repeatedly call
        ``renderer.draw_path(gc, *draw_path_args)`` for each tuple
        *draw_path_args* in *draw_path_args_list*.
        patchT)isRGBArP   r   r   N)PathEffectRendererF)$
open_groupget_gidnew_gcset_foregroundrq   r4   r   r9   
set_dashesr6   r<   r   r=   r   r:   r   _set_gc_clipset_url_urlset_snapget_snapr   r   ru   r;   r   r.   get_sketch_paramsset_sketch_paramsget_path_effectsmatplotlib.patheffectsr   	draw_pathrestoreclose_groupr   )r@   rendererZdraw_path_args_listgcr   r   Zdraw_path_argsrH   rH   rI   "_draw_paths_with_artist_properties  s8    



z(Patch._draw_paths_with_artist_propertiesc                 C   sV   |   sd S |  }|  }||}| }| |||| jd rH| jnd fg d S )NrP   )get_visiblerK   rJ   transform_path_non_affine
get_affiner   rr   )r@   r   rN   	transformtpathaffinerH   rH   rI   drawD  s    
z
Patch.drawc                 C   s   t ddS )zReturn the path of this patch.Derived must overrideNNotImplementedErrorr}   rH   rH   rI   rK   U  s    zPatch.get_pathc                 C   s   |   |  S rW   r{   r@   r   rH   rH   rI   get_window_extentY  s    zPatch.get_window_extentc                 C   s$   |  |d }| |d }||fS )z)Convert x and y units for a tuple (x, y).r   r   )convert_xunitsconvert_yunits)r@   xyrY   rZ   rH   rH   rI   _convert_xy_units\  s    zPatch._convert_xy_units)
NNNNNNNTNN)N)N)N)N)5__name__
__module____qualname____doc__zorderr   r   make_keyword_onlyr(   rO   rV   rl   rX   rn   rp   r|   rJ   rw   r~   r   rS   r   rT   r   r:   r   r2   r   r3   r1   r   r9   r8   r7   r   propertyrB   r	   interpdr<   r   r=   r   r;   r   r   r   allow_rasterizationr   rK   r   r   __classcell__rH   rH   rF   rI   r"      sp   	          5

2
#


!1

r"   c                       sN   e Zd Zdd Zej fddZdd Zdd Zd	d
 Z	 fddZ
  ZS )Shadowc                 C   s   dt | j S )Nz
Shadow(%s))strr   r}   rH   rH   rI   __str__d  s    zShadow.__str__c              	      sz   t    || _|| | _| _t | _| | j dt	
t| j  }| ||dt	| jjt	j d| dS )a  
        Create a shadow of the given *patch*.

        By default, the shadow will have the same face color as the *patch*,
        but darkened.

        Parameters
        ----------
        patch : `.Patch`
            The patch to create the shadow for.
        ox, oy : float
            The shift of the shadow in data coordinates, scaled by a factor
            of dpi/72.
        **kwargs
            Properties of the shadow patch. Supported keys are:

            %(Patch:kwdoc)s
        333333?      ?)r   r   r   r   N)r'   r(   r   _ox_oyr   Affine2D_shadow_transformrp   rc   asarrayr   to_rgbr   update	nextafterr   inf)r@   r   oxoyrE   rA   rF   rH   rI   r(   g  s    


zShadow.__init__c                 C   s.   | | j}| | j}| j || d S rW   )points_to_pixelsr   r   r   clear	translate)r@   r   r   r   rH   rH   rI   _update_transform  s    zShadow._update_transformc                 C   s
   | j  S rW   )r   rK   r}   rH   rH   rI   rK     s    zShadow.get_pathc                 C   s   | j  | j S rW   )r   r~   r   r}   rH   rH   rI   r~     s    zShadow.get_patch_transformc                    s   |  | t | d S rW   )r   r'   r   r   rF   rH   rI   r     s    
zShadow.draw)r   r   r   r   r	   dedent_interpdr(   r   rK   r~   r   r   rH   rH   rF   rI   r   c  s   r   c                       s   e Zd ZdZdd Zejejdddd5dd	 fd
dZ	dd Z
dd Zdd Zedd Zejdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 ZeeeZ   Z!S )6	Rectanglea  
    A rectangle defined via an anchor point *xy* and its *width* and *height*.

    The rectangle extends from ``xy[0]`` to ``xy[0] + width`` in x-direction
    and from ``xy[1]`` to ``xy[1] + height`` in y-direction. ::

      :                +------------------+
      :                |                  |
      :              height               |
      :                |                  |
      :               (xy)---- width -----+

    One may picture *xy* as the bottom left corner, but which corner *xy* is
    actually depends on the direction of the axis and the sign of *width*
    and *height*; e.g. *xy* would be the bottom right corner if the x-axis
    was inverted or if *width* was negative.
    c                 C   s$   | j | j| j| j| jf}d}|| S )Nz5Rectangle(xy=(%g, %g), width=%g, height=%g, angle=%g))_x0_y0_width_heightangler@   ZparsfmtrH   rH   rI   r     s    zRectangle.__str__r#   r   r$           r   )rotation_pointc                   sT   t  jf i | |d | _|d | _|| _|| _t|| _|| _d| _	| 
  dS )a  
        Parameters
        ----------
        xy : (float, float)
            The anchor point.
        width : float
            Rectangle width.
        height : float
            Rectangle height.
        angle : float, default: 0
            Rotation in degrees anti-clockwise about the rotation point.
        rotation_point : {'xy', 'center', (number, number)}, default: 'xy'
            If ``'xy'``, rotate around the anchor point. If ``'center'`` rotate
            around the center. If 2-tuple of number, rotate around this
            coordinate.

        Other Parameters
        ----------------
        **kwargs : `.Patch` properties
            %(Patch:kwdoc)s
        r   r         ?N)r'   r(   r   r   r   r   r   r   r   _aspect_ratio_correction_convert_units)r@   r   widthheightr   r   rE   rF   rH   rI   r(     s    


zRectangle.__init__c                 C   s   t  S )z%Return the vertices of the rectangle.)r   unit_rectangler}   rH   rH   rI   rK     s    zRectangle.get_pathc                 C   sH   |  | j}| | j}|  | j| j }| | j| j }||||fS )z Convert bounds of the rectangle.)r   r   r   r   r   r   r@   x0y0x1y1rH   rH   rI   r     s
    zRectangle._convert_unitsc                 C   s   |   }| jdkrJ|j|j |j|j  }}|j|d  |j|d  f}n| jdkrb|j|jf}n| j}t|t 	|d  |d  
d| j| j
dd| j j	|  S )Ncenter       @r   r   r   )get_bboxr   r  r   r  r  r   BboxTransformTor   r   scaler   
rotate_degr   )r@   bboxr   r   r   rH   rH   rI   r~     s(    


zRectangle.get_patch_transformc                 C   s   | j S )z The rotation point of the patch.)_rotation_pointr}   rH   rH   rI   r     s    zRectangle.rotation_pointc                 C   sN   |dv s:t |trBt|dkrBt |d trBt |d trB|| _ntdd S )N)r  r      r   r   zC`rotation_point` must be one of {'xy', 'center', (number, number)}.)rQ   tupler>   r   r  
ValueError)r@   valuerH   rH   rI   r     s    
c                 C   s   | j S )z,Return the left coordinate of the rectangle.)r   r}   rH   rH   rI   get_x	  s    zRectangle.get_xc                 C   s   | j S )z.Return the bottom coordinate of the rectangle.)r   r}   rH   rH   rI   get_y  s    zRectangle.get_yc                 C   s   | j | jfS )z>Return the left and bottom coords of the rectangle as a tuple.)r   r   r}   rH   rH   rI   get_xy  s    zRectangle.get_xyc                 C   s   |   g dS )zc
        Return the corners of the rectangle, moving anti-clockwise from
        (x0, y0).
        )r   r   )r   r   r   r   r   r   r~   r   r}   rH   rH   rI   get_corners  s    zRectangle.get_cornersc                 C   s   |   dS )z#Return the centre of the rectangle.)r   r   r  r}   rH   rH   rI   
get_center  s    zRectangle.get_centerc                 C   s   | j S z"Return the width of the rectangle.r   r}   rH   rH   rI   	get_width!  s    zRectangle.get_widthc                 C   s   | j S z#Return the height of the rectangle.r   r}   rH   rH   rI   
get_height%  s    zRectangle.get_heightc                 C   s   | j S )z"Get the rotation angle in degrees.)r   r}   rH   rH   rI   	get_angle)  s    zRectangle.get_anglec                 C   s   || _ d| _dS )z)Set the left coordinate of the rectangle.TN)r   r   r@   rY   rH   rH   rI   set_x-  s    zRectangle.set_xc                 C   s   || _ d| _dS )z+Set the bottom coordinate of the rectangle.TN)r   r   r@   rZ   rH   rH   rI   set_y2  s    zRectangle.set_yc                 C   s   || _ d| _dS )zs
        Set the rotation angle in degrees.

        The rotation is performed anti-clockwise around *xy*.
        TN)r   r   r@   r   rH   rH   rI   	set_angle7  s    zRectangle.set_anglec                 C   s   |\| _ | _d| _dS )z
        Set the left and bottom coordinates of the rectangle.

        Parameters
        ----------
        xy : (float, float)
        TN)r   r   r   r@   r   rH   rH   rI   set_xy@  s    zRectangle.set_xyc                 C   s   || _ d| _dS )zSet the width of the rectangle.TNr   r   r   rH   rH   rI   	set_widthK  s    zRectangle.set_widthc                 C   s   || _ d| _dS )z Set the height of the rectangle.TNr   r   r@   hrH   rH   rI   
set_heightP  s    zRectangle.set_heightc                 G   sL   t |dkr|d \}}}}n|\}}}}|| _|| _|| _|| _d| _dS )a@  
        Set the bounds of the rectangle as *left*, *bottom*, *width*, *height*.

        The values may be passed as separate parameters or as a tuple::

            set_bounds(left, bottom, width, height)
            set_bounds((left, bottom, width, height))

        .. ACCEPTS: (left, bottom, width, height)
        r   r   TN)r>   r   r   r   r   r   r@   argslr   r   r,  rH   rH   rI   
set_boundsU  s    zRectangle.set_boundsc                 C   s"   |   \}}}}tj||||S zReturn the `.Bbox`.)r   r   Bboxfrom_extentsr   rH   rH   rI   r  j  s    zRectangle.get_bbox)r   )"r   r   r   r   r   r	   r   r   r   r(   rK   r   r~   r   r   setterr  r  r  r  r  r  r  r  r!  r#  r%  r'  r)  r-  r1  r  r   r   rH   rH   rF   rI   r     s>   '


	r   c                       sN   e Zd ZdZdd Zejejdddd fd	d
	Z	dd Z
dd Z  ZS )RegularPolygonzA regular polygon patch.c                 C   s(   d}|| j d | j d | j| j| jf S )Nz7RegularPolygon((%g, %g), %d, radius=%g, orientation=%g)r   r   )r   numverticesrU   orientationr@   r   rH   rH   rI   r   u  s    zRegularPolygon.__str__r#   rU   r$      r   c                    sD   || _ || _|| _|| _t|| _t | _	t
 jf i | dS )a  
        Parameters
        ----------
        xy : (float, float)
            The center position.

        numVertices : int
            The number of vertices.

        radius : float
            The distance from the center to each of the vertices.

        orientation : float
            The polygon rotation angle (in radians).

        **kwargs
            `Patch` properties:

            %(Patch:kwdoc)s
        N)r   r7  r8  rU   r   unit_regular_polygon_pathr   r   _patch_transformr'   r(   )r@   r   numVerticesrU   r8  rE   rF   rH   rI   r(   z  s    
zRegularPolygon.__init__c                 C   s   | j S rW   r<  r}   rH   rH   rI   rK     s    zRegularPolygon.get_pathc                 C   s"   | j  | j| jj| j S rW   )r=  r   r  rU   rotater8  r   r   r}   rH   rH   rI   r~     s    
z"RegularPolygon.get_patch_transform)r:  r   )r   r   r   r   r   r	   r   r   r   r(   rK   r~   r   rH   rH   rF   rI   r6  r  s   r6  c                       sB   e Zd ZdZdZdd Zej fddZdd Z	d	d
 Z
  ZS )	PathPatchzA general polycurve path patch.Tc                 C   s(   d}|t | jjgt| jjd R  S )NzPathPatch%d((%g, %g) ...)r   )r>   r<  rb   r  r9  rH   rH   rI   r     s    zPathPatch.__str__c                    s   t  jf i | || _dS )zr
        *path* is a `~.path.Path` object.

        Valid keyword arguments are:

        %(Patch:kwdoc)s
        N)r'   r(   r<  )r@   rN   rE   rF   rH   rI   r(     s    	zPathPatch.__init__c                 C   s   | j S rW   r?  r}   rH   rH   rI   rK     s    zPathPatch.get_pathc                 C   s
   || _ d S rW   r?  )r@   rN   rH   rH   rI   set_path  s    zPathPatch.set_path)r   r   r   r   r   r   r	   r   r(   rK   rB  r   rH   rH   rF   rI   rA    s   rA  c                       sL   e Zd ZdZdZejddd fdd
Zdd	 Zd
d Z	dddZ
  ZS )	StepPatchz
    A path patch describing a stepwise constant function.

    By default the path is not closed and starts and stops at
    baseline value.
    Fverticalr   )r8  baselinec                   sX   || _ t|| _t|| _|dur0t|nd| _|   t j| j	fi | dS )a'  
        Parameters
        ----------
        values : array-like
            The step heights.

        edges : array-like
            The edge positions, with ``len(edges) == len(vals) + 1``,
            between which the curve takes on vals values.

        orientation : {'vertical', 'horizontal'}, default: 'vertical'
            The direction of the steps. Vertical means that *values* are
            along the y-axis, and edges are along the x-axis.

        baseline : float, array-like or None, default: 0
            The bottom value of the bounding edges or when
            ``fill=True``, position of lower edge. If *fill* is
            True or an array is passed to *baseline*, a closed
            path is drawn.

        Other valid keyword arguments are:

        %(Patch:kwdoc)s
        N)
r8  rc   r   _edges_values	_baseline_update_pathr'   r(   r<  )r@   valuesedgesr8  rE  rE   rF   rH   rI   r(     s    zStepPatch.__init__c           
      C   s(  t t | jrtd| jjd | jjkrLtd| jj d| jj dt dgt jdtj	dg }}t | j}| j
d ur|t | j
O }t| D ]j\}}t | j||d  d	}t | j|| d	}| j
d u rt |d d ||d
d  g}n| j
jdkr.t | j
g|| j
gg}n| j
jdkrt | j
|| d	d d d
 }t ||d d d
 g}t |d
d  ||d d |d d ||d
d  g}ntd| jdkrt ||g}	nt ||g}	||	 |tjgtjgt|	d    qtt |t || _d S )Nz$Nan values in "edges" are disallowedr   ziSize mismatch between "values" and "edges". Expected `len(values) + 1 == len(edges)`, but `len(values) = z` and `len(edges) = z`.r   r  r   )dtyper  zInvalid `baseline` specifiedrD  )rc   isnansumrF  r  sizerG  emptyr   	code_typerH  r   contiguous_regionsrepeatconcatenatendimr8  column_stackappendre   LINETOr>   r<  )
r@   vertsra   	_nan_maskidx0idx1rY   rZ   baser   rH   rH   rI   rI    s@    
 
" 
$zStepPatch._update_pathc                 C   s   t dd}|| j| j| jS )z:Get `.StepPatch` values, edges and baseline as namedtuple.	StairDatazvalues edges baseline)r   rG  rF  rH  )r@   r`  rH   rH   rI   get_data  s    
zStepPatch.get_dataNc                 C   sn   |du r |du r |du r t d|dur4t|| _|durHt|| _|dur\t|| _|   d| _dS )a  
        Set `.StepPatch` values, edges and baseline.

        Parameters
        ----------
        values : 1D array-like or None
            Will not update values, if passing None
        edges : 1D array-like, optional
        baseline : float, 1D array-like or None
        Nz)Must set *values*, *edges* or *baseline*.T)r  rc   r   rG  rF  rH  rI  r   )r@   rJ  rK  rE  rH   rH   rI   set_data  s    zStepPatch.set_data)NNN)r   r   r   r   r   r	   r   r(   rI  ra  rb  r   rH   rH   rF   rI   rC    s   !$rC  c                       st   e Zd ZdZdd Zejejdddd fdd		Z	d
d Z
dd Zdd Zdd Zdd ZeeeddZ  ZS )PolygonzA general polygon patch.c                 C   s8   t | jjr0d}|t | jjg| jjd R  S dS d S )NzPolygon%d((%g, %g) ...)r   z
Polygon0())r>   r<  rb   r9  rH   rH   rI   r   /  s     zPolygon.__str__r#   closedr$   Tc                    s&   t  jf i | || _| | dS )z
        *xy* is a numpy array with shape Nx2.

        If *closed* is *True*, the polygon will be closed so the
        starting and ending points are the same.

        Valid keyword arguments are:

        %(Patch:kwdoc)s
        N)r'   r(   _closedr'  )r@   r   rd  rE   rF   rH   rI   r(   6  s    zPolygon.__init__c                 C   s   | j S )zGet the `.Path` of the polygon.r?  r}   rH   rH   rI   rK   G  s    zPolygon.get_pathc                 C   s   | j S )z%Return whether the polygon is closed.)re  r}   rH   rH   rI   
get_closedK  s    zPolygon.get_closedc                 C   s4   | j t|krdS t|| _ | |   d| _dS )z
        Set whether the polygon is closed.

        Parameters
        ----------
        closed : bool
           True if the polygon is closed
        NT)re  r   r'  r  r   )r@   rd  rH   rH   rI   
set_closedO  s
    	
zPolygon.set_closedc                 C   s   | j jS )z
        Get the vertices of the path.

        Returns
        -------
        (N, 2) numpy array
            The coordinates of the vertices.
        )r<  rb   r}   rH   rH   rI   r  ^  s    	zPolygon.get_xyc                 C   s   t |}|j\}}| jrT|dks>|dkr||d |d k r|t ||d gg}n(|dkr||d |d k r||dd }t|| jd| _d| _	dS )a  
        Set the vertices of the polygon.

        Parameters
        ----------
        xy : (N, 2) array-like
            The coordinates of the vertices.

        Notes
        -----
        Unlike `~.path.Path`, we do not ignore the last input vertex. If the
        polygon is meant to be closed, and the last point of the polygon is not
        equal to the first, we assume that the user has not explicitly passed a
        ``CLOSEPOLY`` vertex, and add it ourselves.
        r   r   rN  r  Nrd  T)
rc   r   shapere  rh   rV  allr   r<  r   )r@   r   nverts_rH   rH   rI   r'  i  s    

$zPolygon.set_xyz/The vertices of the path as (N, 2) numpy array.)doc)T)r   r   r   r   r   r	   r   r   r   r(   rK   rf  rg  r  r'  r   r   r   rH   rH   rF   rI   rc  ,  s   !rc  c                       sv   e Zd ZdZdd Zejej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dd Z  ZS )WedgezWedge shaped patch.c                 C   s0   | j d | j d | j| j| j| jf}d}|| S )Nr   r   z<Wedge(center=(%g, %g), r=%g, theta1=%g, theta2=%g, width=%s))r  rtheta1theta2r   r   rH   rH   rI   r     s
    zWedge.__str__r#   r   r$   Nc                    sJ   t  jf i | || _|| | _| _|| | _| _t | _	| 
  dS )a4  
        A wedge centered at *x*, *y* center with radius *r* that
        sweeps *theta1* to *theta2* (in degrees).  If *width* is given,
        then a partial wedge is drawn from inner radius *r* - *width*
        to outer radius *r*.

        Valid keyword arguments are:

        %(Patch:kwdoc)s
        N)r'   r(   r  ro  r   rp  rq  r   r   r=  _recompute_path)r@   r  ro  rp  rq  r   rE   rF   rH   rI   r(     s    
zWedge.__init__c           	      C   s*  t | j| j d dkr(d\}}tj}n| j| j }}tj}t||}| jd ur|j}|jd d d | j	| j  | j	 }t
|||dd d f dgg}t
|j|j|tjgg}||t|j< n<t
|jd|jdd d f dgg}t
|j||tjgg}|| j	9 }|t
| j7 }t||| _d S )Nh  g-q=)r   rs  rN  r   r  )absrq  rp  r   re   rZ  arcr   rb   ro  rc   rV  ra   	CLOSEPOLYr>   r   r  r<  )	r@   rp  rq  	connectorru  v1v2vr   rH   rH   rI   rr    s.    
" 
zWedge._recompute_pathc                 C   s   d | _ || _d| _d S NT)r<  r  r   )r@   r  rH   rH   rI   
set_center  s    zWedge.set_centerc                 C   s   d | _ || _d| _d S r{  )r<  ro  r   r@   rU   rH   rH   rI   
set_radius  s    zWedge.set_radiusc                 C   s   d | _ || _d| _d S r{  )r<  rp  r   )r@   rp  rH   rH   rI   
set_theta1  s    zWedge.set_theta1c                 C   s   d | _ || _d| _d S r{  )r<  rq  r   )r@   rq  rH   rH   rI   
set_theta2  s    zWedge.set_theta2c                 C   s   d | _ || _d| _d S r{  )r<  r   r   r@   r   rH   rH   rI   r)    s    zWedge.set_widthc                 C   s   | j d u r|   | j S rW   r<  rr  r}   rH   rH   rI   rK     s    
zWedge.get_path)N)r   r   r   r   r   r	   r   r   r   r(   rr  r|  r~  r  r  r)  rK   r   rH   rH   rF   rI   rn    s   !rn  c                
       s   e Zd ZdZdd Zeddgddgddgddgd	dgdd
gddggZej	e
jdddd fdd	Zdd Zdd Z  ZS )ArrowzAn arrow patch.c                 C   s   dS )NzArrow()rH   r}   rH   rH   rI   r     s    zArrow.__str__r   皙?g皙?g333333ӿr   r   r#   r   r$   c                    sJ   t  jf i | t t|||t||	||
 | _dS )aQ  
        Draws an arrow from (*x*, *y*) to (*x* + *dx*, *y* + *dy*).
        The width of the arrow is scaled by *width*.

        Parameters
        ----------
        x : float
            x coordinate of the arrow tail.
        y : float
            y coordinate of the arrow tail.
        dx : float
            Arrow length in the x direction.
        dy : float
            Arrow length in the y direction.
        width : float, default: 1
            Scale factor for the width of the arrow. With a default value of 1,
            the tail width is 0.2 and head width is 0.6.
        **kwargs
            Keyword arguments control the `Patch` properties:

            %(Patch:kwdoc)s

        See Also
        --------
        FancyArrow
            Patch that allows independent control of the head and tail
            properties.
        N)r'   r(   r   r   r  rc   hypotr@  arctan2r   frozenr=  )r@   rY   rZ   dxdyr   rE   rF   rH   rI   r(     s    
zArrow.__init__c                 C   s   | j S rW   r?  r}   rH   rH   rI   rK     s    zArrow.get_pathc                 C   s   | j S rW   )r=  r}   rH   rH   rI   r~      s    zArrow.get_patch_transform)r   )r   r   r   r   r   r   _create_closedr<  r	   r   r   r   r(   rK   r~   r   rH   rH   rF   rI   r    s   %r  c                	       sd   e Zd ZdZdZdd Zejej	dddd fdd	Z
d
d
d
d
d
d
d
dddZdd Z  ZS )
FancyArrowzP
    Like Arrow, but lets you set head width and head height independently.
    Tc                 C   s   dS )NzFancyArrow()rH   r}   rH   rH   rI   r   +  s    zFancyArrow.__str__r#   r   r$   MbP?FNfullr   c                    sh   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|   t j| jfddi| dS )av  
        Parameters
        ----------
        x, y : float
            The x and y coordinates of the arrow base.

        dx, dy : float
            The length of the arrow along x and y direction.

        width : float, default: 0.001
            Width of full arrow tail.

        length_includes_head : bool, default: False
            True if head is to be counted in calculating the length.

        head_width : float or None, default: 3*width
            Total width of the full arrow head.

        head_length : float or None, default: 1.5*head_width
            Length of arrow head.

        shape : {'full', 'left', 'right'}, default: 'full'
            Draw the left-half, right-half, or full arrow.

        overhang : float, default: 0
            Fraction that the arrow is swept back (0 overhang means
            triangular shape). Can be negative or greater than one.

        head_starts_at_zero : bool, default: False
            If True, the head starts being drawn at coordinate 0
            instead of ending at coordinate 0.

        **kwargs
            `.Patch` properties:

            %(Patch:kwdoc)s
        rd  TN)_x_y_dx_dyr   _length_includes_head_head_width_head_length_shape	_overhang_head_starts_at_zero_make_vertsr'   r(   r[  )r@   rY   rZ   r  r  r   Zlength_includes_head
head_widthhead_lengthri  ZoverhangZhead_starts_at_zerorE   rF   rH   rI   r(   .  s    *zFancyArrow.__init__)rY   rZ   r  r  r   r  r  c                C   sz   |dur|| _ |dur|| _|dur*|| _|dur8|| _|durF|| _|durT|| _|durb|| _|   | | j	 dS )a  
        Set `.FancyArrow` x, y, dx, dy, width, head_with, and head_length.
        Values left as None will not be updated.

        Parameters
        ----------
        x, y : float or None, default: None
            The x and y coordinates of the arrow base.

        dx, dy : float or None, default: None
            The length of the arrow along x and y direction.

        width : float or None, default: None
            Width of full arrow tail.

        head_width : float or None, default: None
            Total width of the full arrow head.

        head_length : float or None, default: None
            Length of arrow head.
        N)
r  r  r  r  r   r  r  r  r'  r[  )r@   rY   rZ   r  r  r   r  r  rH   rH   rI   rb  f  s     zFancyArrow.set_datac                 C   s  | j d u rd| j }n| j }| jd u r0d| }n| j}t| j| j}| jrR|}n|| }|srtddg| _	nZ|| }}| j
| j }}tddg| | d g| d|  | d g| | d g| dgg}	| js|	|dg7 }	| j r|	|d dg7 }	| jdkr|	}
n\|	ddg }| jd	kr.|}
n>| jd
kr\t|	d d |dd d g}
ntd| j|dkr| j| }| j| }nd\}}||g| |gg}t|
|| j| j | j| j g | _	d S )NrP   g      ?r   r  r   r   leftrN  rightr  zGot unknown shape: r  )r  r   r  rc   r  r  r  r  rR  r[  r  arrayr  r  rV  r  dotr  r  )r@   r  r  distancelengthhwZhlhsr   Zleft_half_arrowcoordsZright_half_arrowcxsxMrH   rH   rI   r    sX    








zFancyArrow._make_verts)r  FNNr  r   F)r   r   r   r   r   r   r	   r   r   r   r(   rb  r  r   rH   rH   rF   rI   r  $  s      6
(r  
r   r  )r  c                       s>   e Zd ZdZdd Zejejdddd fd	d
	Z	  Z
S )CirclePolygonz*A polygon-approximation of a circle patch.c                 C   s$   d}|| j d | j d | j| jf S )Nz1CirclePolygon((%g, %g), radius=%g, resolution=%d)r   r   )r   rU   r7  r9  rH   rH   rI   r     s    zCirclePolygon.__str__r#   
resolutionr$   r:     c                    s    t  j||f|dd| dS )a  
        Create a circle at *xy* = (*x*, *y*) with given *radius*.

        This circle is approximated by a regular polygon with *resolution*
        sides.  For a smoother circle drawn with splines, see `Circle`.

        Valid keyword arguments are:

        %(Patch:kwdoc)s
        r   )rU   r8  Nr'   r(   )r@   r   rU   r  rE   rF   rH   rI   r(     s    zCirclePolygon.__init__)r:  r  )r   r   r   r   r   r	   r   r   r   r(   r   rH   rH   rF   rI   r    s     r  c                       s   e Zd ZdZdd Zejejdddd" fdd		Z	d
d Z
dd Zdd Zdd Zdd ZeeeZdd Zdd ZeeeZdd Zdd ZeeeZdd Zdd ZeeeZd d! Z  ZS )#EllipsezA scale-free ellipse.c                 C   s,   | j d | j d | j| j| jf}d}|| S )Nr   r   z3Ellipse(xy=(%s, %s), width=%s, height=%s, angle=%s))_centerr   r   r   r   rH   rH   rI   r     s
    zEllipse.__str__r#   r   r$   r   c                    sJ   t  jf i | || _|| | _| _|| _t | _d| _	t
 | _dS )a  
        Parameters
        ----------
        xy : (float, float)
            xy coordinates of ellipse centre.
        width : float
            Total length (diameter) of horizontal axis.
        height : float
            Total length (diameter) of vertical axis.
        angle : float, default: 0
            Rotation in degrees anti-clockwise.

        Notes
        -----
        Valid keyword arguments are:

        %(Patch:kwdoc)s
        r   N)r'   r(   r  r   r   _angler   unit_circler<  r   r   r   r=  )r@   r   r   r   r   rE   rF   rH   rI   r(     s    
zEllipse.__init__c                 C   sx   |  | jd | | jd f}|  | j}| | j}t |d |d | j 	| j
dd| j j| | _dS )a!  
        Notes
        -----
        This cannot be called until after this has been added to an Axes,
        otherwise unit conversion will fail. This makes it very important to
        call the accessor method and not directly access the transformation
        member variable.
        r   r   r   N)r   r  r   r   r   r   r   r  r   r	  r   r   r=  )r@   r  r   r   rH   rH   rI   _recompute_transform  s    	
zEllipse._recompute_transformc                 C   s   | j S )zReturn the path of the ellipse.r?  r}   rH   rH   rI   rK   ,  s    zEllipse.get_pathc                 C   s   |    | jS rW   )r  r=  r}   rH   rH   rI   r~   0  s    zEllipse.get_patch_transformc                 C   s   || _ d| _dS )zs
        Set the center of the ellipse.

        Parameters
        ----------
        xy : (float, float)
        TN)r  r   r&  rH   rH   rI   r|  4  s    zEllipse.set_centerc                 C   s   | j S )z!Return the center of the ellipse.r  r}   rH   rH   rI   r  ?  s    zEllipse.get_centerc                 C   s   || _ d| _dS )zl
        Set the width of the ellipse.

        Parameters
        ----------
        width : float
        TNr(  r  rH   rH   rI   r)  E  s    zEllipse.set_widthc                 C   s   | j S )z2
        Return the width of the ellipse.
        r  r}   rH   rH   rI   r  P  s    zEllipse.get_widthc                 C   s   || _ d| _dS )zn
        Set the height of the ellipse.

        Parameters
        ----------
        height : float
        TNr*  )r@   r   rH   rH   rI   r-  X  s    zEllipse.set_heightc                 C   s   | j S )z!Return the height of the ellipse.r  r}   rH   rH   rI   r  c  s    zEllipse.get_heightc                 C   s   || _ d| _dS )zl
        Set the angle of the ellipse.

        Parameters
        ----------
        angle : float
        TN)r  r   r$  rH   rH   rI   r%  i  s    zEllipse.set_anglec                 C   s   | j S )z Return the angle of the ellipse.r  r}   rH   rH   rI   r  t  s    zEllipse.get_anglec                 C   s   |   g dS )z
        Return the corners of the ellipse bounding box.

        The bounding box orientation is moving anti-clockwise from the
        lower left corner defined before rotation.
        ))rN  rN  )r   rN  r  )rN  r   r  r}   rH   rH   rI   r  z  s    zEllipse.get_corners)r   )r   r   r   r   r   r	   r   r   r   r(   r  rK   r~   r|  r  r   r  r)  r  r   r-  r  r   r%  r  r   r  r   rH   rH   rF   rI   r    s*   "



r  c                       s   e Zd ZdZejd! fdd	Zdd Zdd Zd	d
 Z	e
e	eZdd Zdd Ze
eeZdd Zdd Ze
eeZdd Zdd Zdd Zdd Ze
eeZdd Zdd Zdd  Z  ZS )"Annulusz 
    An elliptical annulus.
    r   c                    s8   t  jf i | | | || _|| _|| _d| _dS )a  
        Parameters
        ----------
        xy : (float, float)
            xy coordinates of annulus centre.
        r : float or (float, float)
            The radius, or semi-axes:

            - If float: radius of the outer circle.
            - If two floats: semi-major and -minor axes of outer ellipse.
        width : float
            Width (thickness) of the annular ring. The width is measured inward
            from the outer ellipse so that for the inner ellipse the semi-axes
            are given by ``r - width``. *width* must be less than or equal to
            the semi-minor axis.
        angle : float, default: 0
            Rotation angle in degrees (anti-clockwise from the positive
            x-axis). Ignored for circular annuli (i.e., if *r* is a scalar).
        **kwargs
            Keyword arguments control the `Patch` properties:

            %(Patch:kwdoc)s
        N)r'   r(   	set_radiir  r   r   r<  )r@   r   ro  r   r   rE   rF   rH   rI   r(     s    
zAnnulus.__init__c                 C   s@   | j | jkr| j }n| j | jf}dg | j|| j| jR  S )Nz.Annulus(xy=(%s, %s), r=%s, width=%s, angle=%s))ar   r  r   r   r@   ro  rH   rH   rI   r     s    zAnnulus.__str__c                 C   s   || _ d| _d| _dS )zs
        Set the center of the annulus.

        Parameters
        ----------
        xy : (float, float)
        NT)r  r<  r   r&  rH   rH   rI   r|    s    zAnnulus.set_centerc                 C   s   | j S )z!Return the center of the annulus.r  r}   rH   rH   rI   r    s    zAnnulus.get_centerc                 C   s0   t | j| j|krtd|| _d| _d| _dS )z
        Set the width (thickness) of the annulus ring.

        The width is measured inwards from the outer ellipse.

        Parameters
        ----------
        width : float
        z;Width of annulus must be less than or equal semi-minor axisNT)minr  r   r  r   r<  r   r  rH   rH   rI   r)    s    
zAnnulus.set_widthc                 C   s   | j S )z1Return the width (thickness) of the annulus ring.r  r}   rH   rH   rI   r    s    zAnnulus.get_widthc                 C   s   || _ d| _d| _dS )zq
        Set the tilt angle of the annulus.

        Parameters
        ----------
        angle : float
        NT)r  r<  r   r$  rH   rH   rI   r%    s    zAnnulus.set_anglec                 C   s   | j S )z Return the angle of the annulus.r  r}   rH   rH   rI   r    s    zAnnulus.get_anglec                 C   s   t || _d| _d| _dS )zv
        Set the semi-major axis *a* of the annulus.

        Parameters
        ----------
        a : float
        NT)r   r  r<  r   )r@   r  rH   rH   rI   set_semimajor  s    
zAnnulus.set_semimajorc                 C   s   t || _d| _d| _dS )zv
        Set the semi-minor axis *b* of the annulus.

        Parameters
        ----------
        b : float
        NT)r   r   r<  r   r   rH   rH   rI   set_semiminor  s    
zAnnulus.set_semiminorc                 C   sT   t |dkr|\| _| _n(t |dkr<t| | _| _ntdd| _d| _dS )aE  
        Set the semi-major (*a*) and semi-minor radii (*b*) of the annulus.

        Parameters
        ----------
        r : float or (float, float)
            The radius, or semi-axes:

            - If float: radius of the outer circle.
            - If two floats: semi-major and -minor axes of outer ellipse.
        )r  rH   z(Parameter 'r' must be one or two floats.NT)rc   ri  r  r   r   r  r<  r   r  rH   rH   rI   r    s    zAnnulus.set_radiic                 C   s   | j | jfS )z:Return the semi-major and semi-minor radii of the annulus.)r  r   r}   rH   rH   rI   	get_radii  s    zAnnulus.get_radiic                 C   s4   t  j| ||f | jj| | j |S rW   )	r   r   r  r   r	  r   r   r  r   )r@   r[  r  r   rH   rH   rI   _transform_verts$  s    
zAnnulus._transform_vertsc           	      C   s   t dd}| j| j| j  }}}| |j||}| |jd d d || || }t|||dd d f dg}t	|j
t j|j
dd  t jt jg}t ||| _d S )Nr   rs  rN  r  r   )r   ru  r  r   r   r  rb   rc   vstackhstackra   re   rv  r<  )	r@   ru  r  r   r   rx  ry  rz  r   rH   rH   rI   rr  +  s    "zAnnulus._recompute_pathc                 C   s   | j d u r|   | j S rW   r  r}   rH   rH   rI   rK   :  s    
zAnnulus.get_path)r   )r   r   r   r   r	   r   r(   r   r|  r  r   r  r)  r  r   r%  r  r   r  r  r  r  radiir  rr  rK   r   rH   rH   rF   rI   r    s*    	



r  c                       sJ   e Zd ZdZdd Zejd fdd	Zdd Zd	d
 Z	e
e	eZ  ZS )Circlez
    A circle patch.
    c                 C   s$   | j d | j d | jf}d}|| S )Nr   r   zCircle(xy=(%g, %g), radius=%g))r  rU   r   rH   rH   rI   r   D  s    zCircle.__str__r:  c                    s*   t  j||d |d fi | || _dS )a&  
        Create a true circle at center *xy* = (*x*, *y*) with given *radius*.

        Unlike `CirclePolygon` which is a polygonal approximation, this uses
        Bezier splines and is much closer to a scale-free circle.

        Valid keyword arguments are:

        %(Patch:kwdoc)s
        r  N)r'   r(   rU   )r@   r   rU   rE   rF   rH   rI   r(   I  s     zCircle.__init__c                 C   s   d|  | _ | _d| _dS )zm
        Set the radius of the circle.

        Parameters
        ----------
        radius : float
        r  TN)r   r   r   r}  rH   rH   rI   r~  X  s    zCircle.set_radiusc                 C   s
   | j d S )z Return the radius of the circle.r  )r   r}   rH   rH   rI   
get_radiusc  s    zCircle.get_radius)r:  )r   r   r   r   r   r	   r   r(   r~  r  r   rU   r   rH   rH   rF   rI   r  @  s   r  c                       s\   e Zd ZdZdd Zejejdddd fd	d
	Z	e
jdd Zdd Zdd Z  ZS )Arczx
    An elliptical arc, i.e. a segment of an ellipse.

    Due to internal optimizations, the arc cannot be filled.
    c                 C   s4   | j d | j d | j| j| j| j| jf}d}|| S )Nr   r   zEArc(xy=(%g, %g), width=%g, height=%g, angle=%g, theta1=%g, theta2=%g))r  r   r   r   rp  rq  r   rH   rH   rI   r   q  s
    zArc.__str__r#   r   r$   r        v@c           	         sn   | dd}|rtdt j|||fd|i| || _|| _|  \| _| _| _	| _
t| j| j| _dS )a  
        Parameters
        ----------
        xy : (float, float)
            The center of the ellipse.

        width : float
            The length of the horizontal axis.

        height : float
            The length of the vertical axis.

        angle : float
            Rotation of the ellipse in degrees (counterclockwise).

        theta1, theta2 : float, default: 0, 360
            Starting and ending angles of the arc in degrees. These values
            are relative to *angle*, e.g. if *angle* = 45 and *theta1* = 90
            the absolute starting angle is 135.
            Default *theta1* = 0, *theta2* = 360, i.e. a complete ellipse.
            The arc is drawn in the counterclockwise direction.
            Angles greater than or equal to 360, or smaller than 0, are
            represented by an equivalent angle in the range [0, 360), by
            taking the input value mod 360.

        Other Parameters
        ----------------
        **kwargs : `.Patch` properties
            Most `.Patch` properties are supported as keyword arguments,
            with the exception of *fill* and *facecolor* because filling is
            not supported.

        %(Patch:kwdoc)s
        rB   FzArc objects can not be filledr   N)
setdefaultr  r'   r(   rp  rq  _theta_stretch_theta1_theta2_stretched_width_stretched_heightr   ru  r<  )	r@   r   r   r   r   rp  rq  rE   rB   rF   rH   rI   r(   x  s    &zArc.__init__c                    s  |   sdS |   |   |  }|| j| jf|d \}}d}||k rd||k rdt| |S dd   fdd}t	
| jp| jj|   }t |}t }	t|jdd |jd	d D ]\\}
}|g |
|R  }|j\}}tt||d
 d
 }|	|| j|k || jk @   qt|	| jg }	| j}t| j}|t|t |f}| j!}|	D ]6}|rt"||d| _!t| | d}nd}|}qj|| _!dS )a  
        Draw the arc to the given *renderer*.

        Notes
        -----
        Ellipses are normally drawn using an approximation that uses
        eight cubic Bezier splines.  The error of this approximation
        is 1.89818e-6, according to this unverified source:

          Lancaster, Don.  *Approximating a Circle or an Ellipse Using
          Four Bezier Cubic Splines.*

          https://www.tinaja.com/glib/ellipse4.pdf

        There is a use case where very large ellipses must be drawn
        with very high accuracy, and it is too expensive to render the
        entire ellipse with enough segments (either splines or line
        segments).  Therefore, in the case where either radius of the
        ellipse is large enough that the error of the spline
        approximation will be visible (greater than one pixel offset
        from the ideal), a different technique is used.

        In that case, only the visible parts of the ellipse are drawn,
        with each visible arc using a fixed number of spline segments
        (8).  The algorithm proceeds as follows:

        1. The points where the ellipse intersects the axes (or figure)
           bounding box are located.  (This is done by performing an inverse
           transformation on the bbox such that it is relative to the unit
           circle -- this makes the intersection calculation much easier than
           doing rotated ellipse intersection directly.)

           This uses the "line intersecting a circle" algorithm from:

               Vince, John.  *Geometry for Computer Graphics: Formulae,
               Examples & Proofs.*  London: Springer-Verlag, 2005.

        2. The angles of each of the intersection points are calculated.

        3. Proceeding counterclockwise starting in the positive
           x-direction, each of the visible arc-segments between the
           pairs of vertices are drawn using the Bezier arc
           approximation technique implemented in `.Path.arc`.
        Nr  g\!Ac                 S   s   ||  }|| }|| ||  }| | ||  }|| }|| }	|	dkrt d|}
t |	}t || |
| |  | | | t||  | g|| |
| |  | | | t||  | ggS t dS d S )Nr   r   rL  )rc   copysignsqrtr  rt  rR  )r   r  r  r  r  r  Zdr2DZD2ZdiscrimZsign_dyZsqrt_discrimrH   rH   rI   line_circle_intersect  s&    
z'Arc.draw.<locals>.line_circle_intersectc                    s   d}|| k r||  }}n
| | }}||k r6|| }}n
|| }} | |||}	|	j \}
}|	|| |
k |
|| k @ || |k @ ||| k @  S )Ng&.>)T)r   r  r  r  epsilonZx0eZx1eZy0eZy1exysxsysr  rH   rI   segment_circle_intersect  s     




z*Arc.draw.<locals>.segment_circle_intersectrN  r   rs     FT)#r   r  rI  rw   r   r  r  r"   r   r   r  axesfigurer
  rJ   r   r   transformedsetziprb   r  rc   rad2degr  r   r  r  sorteddeg2radrX   cossinr<  ru  )r@   r   Zdata_to_screen_transZpwidthZpheightZ	inv_errorr  Zbox_path_transformZbox_pathZthetasp0p1r   rY   rZ   thetaZ
last_thetaZ
theta1_radri   Zpath_originalrH   r  rI   r     sX    .&
zArc.drawc                 C   sZ   |   }tdd t|| j| j| j| jfD rV|\| _| _| _| _t| j| j| _	d S )Nc                 s   s   | ]\}}||kV  qd S rW   rH   )r[   r  r   rH   rH   rI   r_   <      z#Arc._update_path.<locals>.<genexpr>)
r  rh   r  r  r  r  r  r   ru  r<  )r@   Z	stretchedrH   rH   rI   rI  9  s    

zArc._update_pathc                 C   s   dd }|  | j}| | j}||krt| j| jkrH| jd | jd kst|| j|| }|| j|| }||||fS | j| j||fS )Nc                 S   s@   t | } t | }t | }t t || |}|d d S )Nrs  )rc   r  r  r  r  r  )r  r  rY   rZ   ZsthetarH   rH   rI   theta_stretchF  s
    


z)Arc._theta_stretch.<locals>.theta_stretchrs  )r   r   r   r   rp  rq  )r@   r  r   r   rp  rq  rH   rH   rI   r  C  s    	

zArc._theta_stretch)r   r   r  )r   r   r   r   r   r	   r   r   r   r(   r   r   r   rI  r  r   rH   rH   rF   rI   r  j  s     0
 
r  Tc                 C   s   |du ri }|  }|dd}||}| |}t|j|d  |j|d  f|j| |j| |t	
 dd}|| || dS )a>  
    A debug function to draw a rectangle around the bounding
    box returned by an artist's `.Artist.get_window_extent`
    to test whether the artist is returning the correct bbox.

    *props* is a dict of rectangle props with the additional property
    'pad' that sets the padding around the bbox in points.
    Npad   r  F)r   r   r   rB   r   clip_on)copypopr   r   r   r   r  r   r   r   r   r   r   )r   r   propsrB   r  r
  ro  rH   rH   rI   bbox_artistb  s    	



r  kc                 C   s:   t | j| j| j|ddd}|dur,|| || dS )z
    A debug function to draw a rectangle around the bounding
    box returned by an artist's `.Artist.get_window_extent`
    to test whether the artist is returning the correct bbox.
    F)r   r   r   r   rB   r  N)r   r  r   r   rv   r   )r
  r   rA   rM   ro  rH   rH   rI   	draw_bboxy  s    
r  c                   @   sD   e Zd ZdZdd Zdd Zedd Zedd	 Zed
d Z	dS )_Stylez
    A base class for the Styles. It is meant to be a container class,
    where actual styles are declared as subclass of it, and it
    provides some helper functions.
    c                 C   sL   t j| j d|  | j d|  d dtdj| j d i d S )Nz:tablez:table_and_acceptsz

    .. ACCEPTS: [|z '{}' ])	r	   r   r   r   pprint_stylesjoinrf   format_style_listclsrH   rH   rI   __init_subclass__  s    

z_Style.__init_subclass__c           	   
   K   s   | ddd}|d  }z| j| }W n4 ty` } ztd||W Y d}~n
d}~0 0 z(dd |d	d D }d
d |D }W n4 ty } ztd||W Y d}~n
d}~0 0 |f i i ||S )z>Return the instance of the subclass with the given style name.r   r   ,r   zUnknown style: Nc                 S   s   g | ]}| d qS )=)rg   )r[   r   rH   rH   rI   
<listcomp>  r  z"_Style.__new__.<locals>.<listcomp>r   c                 S   s   i | ]\}}|t |qS rH   )r   )r[   r  rz  rH   rH   rI   
<dictcomp>  r  z"_Style.__new__.<locals>.<dictcomp>zIncorrect style argument: )replacerg   lowerr  KeyErrorr  )	r  	stylenamerE   _list_name_clserrZ
_args_pair_argsrH   rH   rI   __new__  s     &z_Style.__new__c                 C   s   | j S )z(Return a dictionary of available styles.)r  r  rH   rH   rI   
get_styles  s    z_Style.get_stylesc              
      s   dgdd | j  D }dd t| D  ddd  D }dd	|dd
d t|d  D |g fdd|dd D |}tj|ddS )z5Return the available styles as pretty-printed string.)ClassNameAttrsc                 S   s:   g | ]2\}}|j d | d tt|dd p2dfqS )z``r   rN  r   )r   r   inspect	signature)r[   r%   r  rH   rH   rI   r    s
   
z(_Style.pprint_styles.<locals>.<listcomp>c                 S   s   g | ]}t d d |D qS )c                 s   s   | ]}t |V  qd S rW   )r>   )r[   cellrH   rH   rI   r_     r  2_Style.pprint_styles.<locals>.<listcomp>.<genexpr>)max)r[   columnrH   rH   rI   r    r    c                 s   s   | ]}d | V  qdS )r  NrH   )r[   clrH   rH   rI   r_     r  z'_Style.pprint_styles.<locals>.<genexpr>r  r   c                 s   s   | ]\}}| |V  qd S rW   ljustr[   r  r  rH   rH   rI   r_     r  r   c                    s&   g | ]}d  dd t| D qS )r  c                 s   s   | ]\}}| |V  qd S rW   r  r  rH   rH   rI   r_     r  r  )r  r  )r[   rowcol_lenrH   rI   r    s   r   Nz    )prefix)r  itemsr  r  textwrapindent)r  tabletable_formatstrZ	rst_tablerH   r  rI   r    s(    

	z_Style.pprint_stylesc                 C   s,   t || jstd|| jf || j|< dS )zRegister a new style.z%s must be a subclass of %sN)
issubclass_Baser  r  )r  r%   stylerH   rH   rI   register  s
    z_Style.registerN)
r   r   r   r   r  r  classmethodr  r  r"  rH   rH   rH   rI   r    s   

r  r$   c                C   s.   |du rt jt| |dS || |p(|j < |S )z=Class decorator that stashes a class in a (style) dictionary.Nr$   )	functoolspartial_register_styler   r  )Z
style_listr  r%   rH   rH   rI   r&    s    r&  c                   @   s   e Zd ZdZi ZeeG dd dZeeG dd dZeeG dd dZeeG dd	 d	eZ	eeG d
d dZ
eeG dd dZeeG dd dZeeG dd dZeeG dd deZdS )BoxStylea  
    `BoxStyle` is a container class which defines several
    boxstyle classes, which are used for `FancyBboxPatch`.

    A style object can be created as::

           BoxStyle.Round(pad=0.2)

    or::

           BoxStyle("Round", pad=0.2)

    or::

           BoxStyle("Round, pad=0.2")

    The following boxstyle classes are defined.

    %(BoxStyle:table)s

    An instance of a boxstyle class is a callable object, with the signature ::

       __call__(self, x0, y0, width, height, mutation_size) -> Path

    *x0*, *y0*, *width* and *height* specify the location and size of the box
    to be drawn; *mutation_size* scales the outline properties such as padding.
    c                   @   s"   e Zd ZdZdddZdd ZdS )	zBoxStyle.SquarezA square box.r   c                 C   s
   || _ dS z
            Parameters
            ----------
            pad : float, default: 0.3
                The amount of padding around the original box.
            Nr  r@   r  rH   rH   rI   r(   	  s    zBoxStyle.Square.__init__c           	      C   sj   || j  }|d|  |d|   }}|| ||  }}|| ||  }}t||f||f||f||fgS Nr  r  r   r  )	r@   r   r  r   r   mutation_sizer  r  r  rH   rH   rI   __call__	  s    
zBoxStyle.Square.__call__N)r   r   r   r   r   r(   r.  rH   rH   rH   rI   Square 	  s   
	r0  c                   @   s"   e Zd ZdZdddZdd ZdS )	zBoxStyle.CirclezA circular box.r   c                 C   s
   || _ dS r(  r)  r*  rH   rH   rI   r(   	  s    zBoxStyle.Circle.__init__c                 C   s`   || j  }|d|  |d|   }}|| ||  }}t||d  ||d  ft||d S r+  )r  r   circler  )r@   r   r  r   r   r-  r  rH   rH   rI   r.  $	  s    
zBoxStyle.Circle.__call__N)r   r/  rH   rH   rH   rI   r  	  s   
	r  c                   @   s"   e Zd ZdZdddZdd ZdS )	zBoxStyle.LArrowz,A box in the shape of a left-pointing arrow.r   c                 C   s
   || _ dS r(  r)  r*  rH   rH   rI   r(   0	  s    zBoxStyle.LArrow.__init__c                 C   s   || j  }|d|  |d|   }}|| ||  }}|| ||  }}|| d }	|	d }
||d  }t||
 |f||f||f||
 |f||
 ||
 f||	 ||	 f||
 ||
 f||
 |fgS Nr  gffffff?r,  r@   r   r  r   r   r-  r  r  r  r  ZdxxrH   rH   rI   r.  9	  s    
 
zBoxStyle.LArrow.__call__N)r   r/  rH   rH   rH   rI   LArrow,	  s   
	r4  c                   @   s   e Zd ZdZdd ZdS )zBoxStyle.RArrowz-A box in the shape of a right-pointing arrow.c                 C   sF   t j| |||||}d| | |jd d df  |jd d df< |S )Nr  r   )r'  r4  r.  rb   )r@   r   r  r   r   r-  prH   rH   rI   r.  P	  s
    ,zBoxStyle.RArrow.__call__Nr   r   r   r   r.  rH   rH   rH   rI   RArrowL	  s   r7  c                   @   s"   e Zd ZdZdddZdd ZdS )	zBoxStyle.DArrowz&A box in the shape of a two-way arrow.r   c                 C   s
   || _ dS r(  r)  r*  rH   rH   rI   r(   [	  s    zBoxStyle.DArrow.__init__c                 C   s   || j  }|d|  }|| ||  }}|| ||  }}|| d }	|	d }
||d  }t||
 |f||f|||
 f||	 |
 ||	 f|||
 f||f||
 |f||
 ||
 f||	 ||	 f||
 ||
 f||
 |fgS r2  r,  r3  rH   rH   rI   r.  d	  s     


zBoxStyle.DArrow.__call__N)r   r/  rH   rH   rH   rI   DArrowV	  s   
	r8  c                   @   s"   e Zd ZdZdddZdd ZdS )	zBoxStyle.RoundzA box with round corners.r   Nc                 C   s   || _ || _dS )z
            Parameters
            ----------
            pad : float, default: 0.3
                The amount of padding around the original box.
            rounding_size : float, default: *pad*
                Radius of the corners.
            Nr  rounding_sizer@   r  r:  rH   rH   rI   r(   	  s    	zBoxStyle.Round.__init__c                 C   s(  || j  }| jr|| j }n|}|d|  |d|   }}|| ||  }}|| ||  }}	|| |f|| |f||f||| f||	| f||	f|| |	f|| |	f||	f||	| f||| f||f|| |f|| |fg}
tjtjtjtjtjtjtjtjtjtjtjtjtjtjg}t|
|}|S r+  )r  r:  r   re   rZ  CURVE3rv  r@   r   r  r   r   r-  r  drr  r  cpcomrN   rH   rH   rI   r.  	  s>    







zBoxStyle.Round.__call__)r   Nr/  rH   rH   rH   rI   Round{	  s   
rA  c                   @   s"   e Zd ZdZdddZdd ZdS )	zBoxStyle.Round4zA box with rounded edges.r   Nc                 C   s   || _ || _dS )z
            Parameters
            ----------
            pad : float, default: 0.3
                The amount of padding around the original box.
            rounding_size : float, default: *pad*/2
                Rounding of edges.
            Nr9  r;  rH   rH   rI   r(   	  s    	zBoxStyle.Round4.__init__c                 C   sZ  || j  }| jr|| j }n|d }|d|  d|  }|d|  d|  }|| | || |  }}|| ||  }}	||f|| || f|| || f||f|| || f|| |	| f||	f|| |	| f|| |	| f||	f|| |	| f|| || f||f||fg}
tjtjtjtjtjtjtjtjtjtjtjtjtjtjg}t|
|}|S )Nr  r  )r  r:  r   re   CURVE4rv  r=  rH   rH   rI   r.  	  s0    
""""
zBoxStyle.Round4.__call__)r   Nr/  rH   rH   rH   rI   Round4	  s   
rC  c                   @   s*   e Zd ZdZd
ddZdd Zdd	 ZdS )zBoxStyle.SawtoothzA box with a sawtooth outline.r   Nc                 C   s   || _ || _dS )z
            Parameters
            ----------
            pad : float, default: 0.3
                The amount of padding around the original box.
            tooth_size : float, default: *pad*/2
                Size of the sawtooth.
            N)r  
tooth_size)r@   r  rD  rH   rH   rI   r(   	  s    	zBoxStyle.Sawtooth.__init__c                 C   sZ  || j  }| jd u r$| j d | }n
| j| }|d }|d|  | }|d|  | }tt|| |d  d }	|| |	 }
tt|| |d  d }|| | }|| | || |  }}|| ||  }}|g|| |
d t|	d   || }|g|| ||| |g|	 || }|g|| ||| |g|	 || }|g|| |d t|d   || }|g|| |
d t|	d   || }|g|| ||| |g|	 || }|g|| ||| |g| || }|g|| |d t|d   || }g t||t||t||t|||d |d f}|S )Nr   r  r   )r  rD  introundrc   aranger  )r@   r   r  r   r   r-  r  rD  Ztooth_size2Zdsx_nZdsxZdsy_nZdsyr  r  Zbottom_saw_xZbottom_saw_yZright_saw_xZright_saw_yZ	top_saw_xZ	top_saw_yZ
left_saw_xZ
left_saw_ysaw_verticesrH   rH   rI   _get_sawtooth_vertices	  s    


z(BoxStyle.Sawtooth._get_sawtooth_verticesc                 C   s"   |  |||||}t|dd}|S )NTrh  )rI  r   )r@   r   r  r   r   r-  rH  rN   rH   rH   rI   r.  D
  s
    
zBoxStyle.Sawtooth.__call__)r   N)r   r   r   r   r(   rI  r.  rH   rH   rH   rI   Sawtooth	  s   
JrJ  c                   @   s   e Zd ZdZdd ZdS )zBoxStyle.Roundtoothz&A box with a rounded sawtooth outline.c                 C   s\   |  |||||}t||d gg}tjgtjtjgt|d d   tjg }t||S )Nr   r   r  )rI  rc   rV  r   re   r<  r>   rv  )r@   r   r  r   r   r-  rH  ra   rH   rH   rI   r.  N
  s    zBoxStyle.Roundtooth.__call__Nr6  rH   rH   rH   rI   
RoundtoothJ
  s   rK  N)r   r   r   r   r  r&  r0  r  r4  r7  r8  rA  rC  rJ  rK  rH   rH   rH   rI   r'    s(   	$;2_r'  c                   @   s   e Zd ZdZi ZG dd dZeeG dd deZeeG dd deZeeG dd	 d	eZ	eeG d
d deZ
eeG dd deZdS )ConnectionStylea  
    `ConnectionStyle` is a container class which defines
    several connectionstyle classes, which is used to create a path
    between two points.  These are mainly used with `FancyArrowPatch`.

    A connectionstyle object can be either created as::

           ConnectionStyle.Arc3(rad=0.2)

    or::

           ConnectionStyle("Arc3", rad=0.2)

    or::

           ConnectionStyle("Arc3, rad=0.2")

    The following classes are defined

    %(ConnectionStyle:table)s

    An instance of any connection style class is an callable object,
    whose call signature is::

        __call__(self, posA, posB,
                 patchA=None, patchB=None,
                 shrinkA=2., shrinkB=2.)

    and it returns a `.Path` instance. *posA* and *posB* are
    tuples of (x, y) coordinates of the two points to be
    connected. *patchA* (or *patchB*) is given, the returned path is
    clipped so that it start (or end) from the boundary of the
    patch. The path is further shrunk by *shrinkA* (or *shrinkB*)
    which is given in points.
    c                   @   s8   e Zd ZdZG dd dZdd Zdd Zdd
dZd	S )zConnectionStyle._Basea  
        A base class for connectionstyle classes. The subclass needs
        to implement a *connect* method whose call signature is::

          connect(posA, posB)

        where posA and posB are tuples of x, y coordinates to be
        connected.  The method needs to return a path connecting two
        points. This base class defines a __call__ method, and a few
        helper methods.
        c                   @   s   e Zd Zdd ZdS )z!ConnectionStyle._Base.SimpleEventc                 C   s   |\| _ | _d S rW   )rY   rZ   r&  rH   rH   rI   r(   
  s    z*ConnectionStyle._Base.SimpleEvent.__init__N)r   r   r   r(   rH   rH   rH   rI   SimpleEvent
  s   rM  c                    s    r> fdd}zt ||\}}W n ty8   |}Y n0 |}r|fdd}zt ||\}}W n tyv   |}Y n0 |}|S )aI  
            Clip the path to the boundary of the patchA and patchB.
            The starting point of the path needed to be inside of the
            patchA and the end point inside the patch B. The *contains*
            methods of each patch object is utilized to test if the point
            is inside the path.
            c                    s   t j| } |d S Nr   rL  r   rM  rl   Z
xy_displayZxy_event)patchArH   rI   insideA
  s    z,ConnectionStyle._Base._clip.<locals>.insideAc                    s   t j| } |d S rN  rO  rP  )patchBrH   rI   insideB
  s    z,ConnectionStyle._Base._clip.<locals>.insideB)r   r  )r@   rN   rQ  rS  rR  r  r  rT  rH   )rQ  rS  rI   _clip
  s    	

zConnectionStyle._Base._clipc                 C   s   |rBt g |jd |R  }zt||\}}W n ty@   Y n0 |rt g |jd |R  }zt||\}}W n ty   Y n0 |S )z]
            Shrink the path by fixed size (in points) with shrinkA and shrinkB.
            r   rN  )r   rb   r   r  )r@   rN   shrinkAshrinkBrR  r  rT  r  rH   rH   rI   _shrink
  s    zConnectionStyle._Base._shrinkr  Nc           
      C   s,   |  ||}| |||}| |||}	|	S )z
            Call the *connect* method to create a path between *posA* and
            *posB*; then clip and shrink the path.
            )connectrU  rX  )
r@   posAposBrV  rW  rQ  rS  rN   Zclipped_pathZshrunk_pathrH   rH   rI   r.  
  s    zConnectionStyle._Base.__call__)r  r  NN)r   r   r   r   rM  rU  rX  r.  rH   rH   rH   rI   r   
  s   # r   c                   @   s"   e Zd ZdZdddZdd ZdS )	zConnectionStyle.Arc3aM  
        Creates a simple quadratic Bezier curve between two
        points. The curve is created so that the middle control point
        (C1) is located at the same distance from the start (C0) and
        end points(C2) and the distance of the C1 to the line
        connecting C0-C2 is *rad* times the distance of C0-C2.
        r   c                 C   s
   || _ dS )zE
            *rad*
              curvature of the curve.
            N)rad)r@   r\  rH   rH   rI   r(   
  s    zConnectionStyle.Arc3.__init__c                 C   s   |\}}|\}}|| d || d  }}|| ||  }	}
| j }|||
  |||	   }}||f||f||fg}tjtjtjg}t||S )Nr  )r\  r   re   r<  )r@   rZ  r[  r  r  x2y2Zx12Zy12r  r  fr  cyrb   ra   rH   rH   rI   rY  
  s    zConnectionStyle.Arc3.connectN)r   r   r   r   r   r(   rY  rH   rH   rH   rI   Arc3
  s   
rb  c                   @   s"   e Zd ZdZd	ddZdd ZdS )
zConnectionStyle.Angle3a
  
        Creates a simple quadratic Bezier curve between two
        points. The middle control points is placed at the
        intersecting point of two lines which cross the start and
        end point, and have a slope of angleA and angleB, respectively.
        Z   r   c                 C   s   || _ || _dS )z
            *angleA*
              starting angle of the path

            *angleB*
              ending angle of the path
            N)angleAangleB)r@   rd  re  rH   rH   rI   r(      s    	zConnectionStyle.Angle3.__init__c              	   C   s   |\}}|\}}t t | j}t t | j}t t | j}	t t | j}
t|||||||	|
\}}||f||f||fg}tjtj	tj	g}t||S rW   )
mathr  radiansrd  r  re  r   r   re   r<  )r@   rZ  r[  r  r  r]  r^  cosAsinAcosBsinBr  r`  rb   ra   rH   rH   rI   rY    s    
zConnectionStyle.Angle3.connectN)rc  r   ra  rH   rH   rH   rI   Angle3
  s   
rl  c                   @   s"   e Zd ZdZd
ddZdd Zd	S )zConnectionStyle.AngleaX  
        Creates a piecewise continuous quadratic Bezier path between
        two points. The path has a one passing-through point placed at
        the intersecting point of two lines which cross the start
        and end point, and have a slope of angleA and angleB, respectively.
        The connecting edges are rounded with *rad*.
        rc  r   r   c                 C   s   || _ || _|| _dS )z
            *angleA*
              starting angle of the path

            *angleB*
              ending angle of the path

            *rad*
              rounding radius of the edge
            N)rd  re  r\  )r@   rd  re  r\  rH   rH   rI   r(   '  s    zConnectionStyle.Angle.__init__c              	   C   sp  |\}}|\}}t t | j}t t | j}t t | j}	t t | j}
t|||||||	|
\}}||fg}tjg}| j	dkr|
||f |
tj n|| ||  }}t||}| j	| }|| ||  }}t||}| j	| }||||  |||  f||f|||  |||  fg |tjtjtjg |
||f |
tj t||S )Nr   )rf  r  rg  rd  r  re  r   r   re   r\  rY  rZ  rc   r  extendr<  )r@   rZ  r[  r  r  r]  r^  rh  ri  rj  rk  r  r`  rb   ra   dx1dy1d1f1dx2dy2d2f2rH   rH   rI   rY  8  s8    




zConnectionStyle.Angle.connectN)rc  r   r   ra  rH   rH   rH   rI   Angle  s   
rv  c                   @   s"   e Zd ZdZd	ddZdd ZdS )
zConnectionStyle.Arca:  
        Creates a piecewise continuous quadratic Bezier path between
        two points. The path can have two passing-through points, a
        point placed at the distance of armA and angle of angleA from
        point A, another point with respect to point B. The edges are
        rounded with *rad*.
        r   Nr   c                 C   s"   || _ || _|| _|| _|| _dS )aH  
            *angleA* :
              starting angle of the path

            *angleB* :
              ending angle of the path

            *armA* :
              length of the starting arm

            *armB* :
              length of the ending arm

            *rad* :
              rounding radius of the edges
            N)rd  re  armAarmBr\  )r@   rd  re  rw  rx  r\  rH   rH   rI   r(   e  s
    zConnectionStyle.Arc.__init__c                 C   sv  |\}}|\}}||fg}g }t jg}	| jrtt| j}
tt| j}| j| j }|	|||
  |||  f | j}|	|||
  |||  f | j
rtt| j}tt| j}|| j
|  || j
|   }}|rl|d \}}|| ||  }}|| ||  d }|	|| j| |  || j| |  f || |	t jt jt jg n2|d \}}|| ||  }}|| ||  d }|| j }||| |  ||| |  f||fg}|rR|d \}}|| ||  }}|| ||  d }|	|| j| |  || j| |  f || |	t jt jt jg |	||f |		t j t ||	S )NrN  r   )r   re   rw  rf  r  rg  rd  r  r\  rY  rx  re  rm  rZ  r<  )r@   rZ  r[  r  r  r]  r^  rb   roundedra   rh  ri  drj  rk  Zx_armBZy_armBxpypr  r  ddrH   rH   rI   rY  ~  sd    



zConnectionStyle.Arc.connect)r   r   NNr   ra  rH   rH   rH   rI   r  [  s   
r  c                   @   s"   e Zd ZdZd	ddZdd ZdS )
zConnectionStyle.Bara  
        A line with *angle* between A and B with *armA* and
        *armB*. One of the arms is extended so that they are connected in
        a right angle. The length of armA is determined by (*armA*
        + *fraction* x AB distance). Same for armB.
        r   r   Nc                 C   s   || _ || _|| _|| _dS )a  
            Parameters
            ----------
            armA : float
                minimum length of armA

            armB : float
                minimum length of armB

            fraction : float
                a fraction of the distance between two points that
                will be added to armA and armB.

            angle : float or None
                angle of the connecting line (if None, parallel
                to A and B)
            N)rw  rx  fractionr   )r@   rw  rx  r~  r   rH   rH   rI   r(     s    zConnectionStyle.Bar.__init__c                 C   s  |\}}| \}}\}}t || || }	|| ||  }
}|
|
 ||  d }|
| ||  }}| j| j }}| jd urt| j}|	| }|t | }|t | }||t |  ||t |   }}|| }|| ||  }
}|
|
 ||  d }|
| ||  }}t	||}| j
| | }|||  |||   }}|||  |||   }}||f||f||f||fg}tjtjtjtjg}t||S )Nr   )rf  atan2rw  rx  r   rc   r  r  r  r  r~  r   re   rZ  )r@   rZ  r[  r  r  Zx20Zy20r]  r^  rp  r  r  r}  ddxddyrw  rx  Ztheta0dthetadlZdLZdd2armr_  cx1cy1cx2cy2rb   ra   rH   rH   rI   rY    s@    &
zConnectionStyle.Bar.connect)r   r   r   Nra  rH   rH   rH   rI   Bar  s   
r  N)r   r   r   r   r  r   r&  rb  rl  rv  r  r  rH   rH   rH   rI   rL  Z
  s   $Q#%=]rL  c           
      C   sL   | | ||  }}||| ||  d  }| ||  |||   }}	||	fS )z{
    Return the point on the line connecting (*x0*, *y0*) -- (*x1*, *y1*) whose
    distance from (*x0*, *y0*) is *d*.
    r   rH   )
r   r  r  r  rz  r  r  ffr]  r^  rH   rH   rI   _point_along_a_line  s    r  c                   @   s  e Zd ZdZi ZG dd dZG dd deZeeddG dd	 d	eZeed
dG dd deZ	eeddG dd deZ
eeddG dd deZeeddG dd deZeeddG dd deZeeddG dd deZeeddG dd deZeeddG d d! d!eZeed"dG d#d$ d$eZeed%dG d&d' d'eZeed(dG d)d* d*eZeed+dG d,d- d-eZeeG d.d/ d/eZeeG d0d1 d1eZeeG d2d3 d3eZd4S )5
ArrowStylea  
    `ArrowStyle` is a container class which defines several
    arrowstyle classes, which is used to create an arrow path along a
    given path.  These are mainly used with `FancyArrowPatch`.

    A arrowstyle object can be either created as::

           ArrowStyle.Fancy(head_length=.4, head_width=.4, tail_width=.4)

    or::

           ArrowStyle("Fancy", head_length=.4, head_width=.4, tail_width=.4)

    or::

           ArrowStyle("Fancy, head_length=.4, head_width=.4, tail_width=.4")

    The following classes are defined

    %(ArrowStyle:table)s

    An instance of any arrow style class is a callable object,
    whose call signature is::

        __call__(self, path, mutation_size, linewidth, aspect_ratio=1.)

    and it returns a tuple of a `.Path` instance and a boolean
    value. *path* is a `.Path` instance along which the arrow
    will be drawn. *mutation_size* and *aspect_ratio* have the same
    meaning as in `BoxStyle`. *linewidth* is a line width to be
    stroked. This is meant to be used to correct the location of the
    head so that it does not overshoot the destination point, but not all
    classes support it.
    c                   @   s.   e Zd ZdZedd Zdd Zd
ddZd	S )zArrowStyle._Basea  
        Arrow Transmuter Base class

        ArrowTransmuterBase and its derivatives are used to make a fancy
        arrow around a given path. The __call__ method returns a path
        (which will be used to create a PathPatch instance) and a boolean
        value indicating the path is open therefore is not fillable.  This
        class is not an artist and actual drawing of the fancy arrow is
        done by the FancyArrowPatch class.
        c                 C   s`   t |  }t|dks<|d d tjks<|d d tjkrDtdg |d d |d d S )aP  
            Some ArrowStyle classes only works with a simple quadratic
            Bezier curve (created with `.ConnectionStyle.Arc3` or
            `.ConnectionStyle.Angle3`). This static method checks if the
            provided path is a simple quadratic Bezier curve and returns its
            control points if true.
            r  r   r   z,'path' is not a valid quadratic Bezier curve)listiter_segmentsr>   r   re   r<  r  )rN   segmentsrH   rH   rI   ensure_quadratic_bezierF  s    	z(ArrowStyle._Base.ensure_quadratic_bezierc                 C   s   t ddS )a  
            The transmute method is the very core of the ArrowStyle class and
            must be overridden in the subclasses. It receives the path object
            along which the arrow will be drawn, and the mutation_size, with
            which the arrow head etc. will be scaled. The linewidth may be
            used to adjust the path so that it does not pass beyond the given
            points. It returns a tuple of a Path instance and a boolean. The
            boolean value indicate whether the path can be filled or not. The
            return value can also be a list of paths and list of booleans of a
            same length.
            r   Nr   )r@   rN   r-  r!   rH   rH   rI   	transmuteV  s    zArrowStyle._Base.transmuter   c           
         st    durb|j d g }t||j}| |||\}}t|rX fdd|D }	|	|fS ||fS n| |||S dS )z
            The __call__ method is a thin wrapper around the transmute method
            and takes care of the aspect ratio.
            Nr   c                    s"   g | ]}t |jd  g |jqS )r   )r   rb   ra   )r[   r5  aspect_ratiorH   rI   r  u  s   z-ArrowStyle._Base.__call__.<locals>.<listcomp>)rb   r   ra   r  rc   iterable)
r@   rN   r-  r!   r  rb   Zpath_shrunkZpath_mutatedfillable	path_listrH   r  rI   r.  d  s    


zArrowStyle._Base.__call__N)r   )r   r   r   r   staticmethodr  r  r.  rH   rH   rH   rI   r   6  s   
 r   c                
       sN   e Zd ZdZd ZZdZd ZZd fd	d
	Z	dd Z
dd Zdd Z  ZS )zArrowStyle._Curvea9  
        A simple arrow which will work with any path instance. The
        returned path is the concatenation of the original path, and at
        most two paths representing the arrow head or bracket at the begin
        point and at the end point. The arrow heads can be either open
        or closed.
        N-F皙?皙?r   r   c                    s  || | _ | _|| | _| _|| | _| _|| | _| _|	|
 | _| _	d| _
d| _d| _d| _d| jvrptd| jdd\}}|dkrd| _
d| _n|dkrd| _
d| _d| _nf|dv rd| _
d| _nP| jdu rd| _
d| _tjd	d
dd n(| jdu rd| _
d| _tjd	d
dd |dkr2d| _d| _n|dkrPd| _d| _d| _nj|dv rhd| _d| _nR| jdu rd| _d| _tjd	ddd n(| jdu rd| _d| _tjd	ddd t   dS )a=  
            Parameters
            ----------
            head_length : float, default: 0.4
                Length of the arrow head, relative to *mutation_scale*.
            head_width : float, default: 0.2
                Width of the arrow head, relative to *mutation_scale*.
            widthA : float, default: 1.0
                Width of the bracket at the beginning of the arrow
            widthB : float, default: 1.0
                Width of the bracket at the end of the arrow
            lengthA : float, default: 0.2
                Length of the bracket at the beginning of the arrow
            lengthB : float, default: 0.2
                Length of the bracket at the end of the arrow
            angleA : float, default 0
                Orientation of the bracket at the beginning, as a
                counterclockwise angle. 0 degrees means perpendicular
                to the line.
            angleB : float, default 0
                Orientation of the bracket at the beginning, as a
                counterclockwise angle. 0 degrees means perpendicular
                to the line.
            scaleA : float, default *mutation_size*
                The mutation_size for the beginning bracket
            scaleB : float, default *mutation_size*
                The mutation_size for the end bracket
            Fr  z-arrow must have the '-' between the two headsr   <Tz<|)r  r  3.5
beginarrowarrow)r%   alternative>z|>)[r  endarrowN)r  r  widthAwidthBlengthAlengthBrd  re  scaleAscaleB_beginarrow_head_beginarrow_bracket_endarrow_head_endarrow_bracketr  r  rg   	fillbeginr  r   warn_deprecatedfillendr  r'   r(   )r@   r  r  r  r  r  r  rd  re  r  r  r  r  rF   rH   rI   r(     sr     




zArrowStyle._Curve.__init__c	                 C   s  || ||  }	}
t |	|
}d| | }|dkr6d}||	 | }||
 | }|	| | }	|
| | }
||	 ||
  | |	 ||
   }}||	 ||
  ||	 ||
   }}|| | || | f|| || f|| | || | fg}tjtjtjg}||||fS )a  
            Return the paths for arrow heads. Since arrow lines are
            drawn with capstyle=projected, The arrow goes beyond the
            desired point. This method also returns the amount of the path
            to be shrunken so that it does not overshoot.
            r   r   r   )rc   r  r   re   rZ  )r@   r   r  r  r  	head_distcos_tsin_tr!   r  r  Zcp_distanceZpad_projectedr  r  rn  ro  rr  rs  vertices_arrowcodes_arrowrH   rH   rI   _get_arrow_wedge  s(    
$"z"ArrowStyle._Curve._get_arrow_wedgec                 C   s   t ||||\}}	ddlm}
 |
||||	|\}}}}|| ||	  }}|| || f||f||f|| || fg}tjtjtjtjg}|rt |||}|	|}||fS )Nr   )get_normal_points)
r   Zmatplotlib.bezierr  r   re   rZ  r   r   rotate_deg_aroundr   )r@   r   r  r  r  r   r  r   r  r  r  r]  r^  r  r  r  r  rM   rH   rH   rI   _get_bracket  s$    
zArrowStyle._Curve._get_bracketc           !   
   C   s2  | j s| jr>| j| }| j| }t||}|| ||  }}| jd u rL|n| j}	| jd u r`|n| j}
|jd \}}|jd \}}| j o||f||fk}|r| 	||||||||n
g g ddf\}}}}|jd \}}|jd \}}| jo||f||fk}|r| 	||||||||n
g g ddf\}}}}t
t|| || fg|jdd || || fgg|jg}dg}|r| jrt||d |d gg}t|t
jt
jgg} |t
||  |d n|t
|| |d nf| jrN|jd \}}|jd \}}| ||||| j|	 | j|	 | j\}}|t
|| |d |r| jr|d t||d |d gg}t|t
jt
jgg} |t
||  n|d |t
|| nf| jr*|jd \}}|jd \}}| ||||| j|
 | j|
 | j\}}|t
|| |d ||fS )Nr   r   r  rN  FT)r  r  r  r  rc   r  r  r  rb   r  r   rV  ra   r  rZ  rv  rY  r  r  r  r  rd  r  r  r  r  re  )!r@   rN   r-  r!   r  r  r  r  r  r  r  r   r  r  r  Zhas_begin_arrowZ	verticesAZcodesAZddxAZddyAr]  r^  x3Zy3Zhas_end_arrowZ	verticesBZcodesBZddxBZddyBr<  Z	_fillabler5  r   rH   rH   rI   r  /  s    





	



zArrowStyle._Curve.transmute)
r  r  r   r   r  r  r   r   NN)r   r   r   r   r  r  r  r  r  r(   r  r  r  r   rH   rH   rF   rI   _Curve}  s      a*r  r  r$   c                       s    e Zd ZdZ fddZ  ZS )zArrowStyle.Curvez&A simple curve without any arrow head.c                    s   t  jddd d S )Nr  r  )r  r  r  r}   rF   rH   rI   r(     s    zArrowStyle.Curve.__init__)r   r   r   r   r(   r   rH   rH   rF   rI   Curve  s   r  <-c                   @   s   e Zd ZdZdZdS )zArrowStyle.CurveAz(An arrow with a head at its begin point.r  Nr   r   r   r   r  rH   rH   rH   rI   CurveA  s   r  ->c                   @   s   e Zd ZdZdZdS )zArrowStyle.CurveBz&An arrow with a head at its end point.r  Nr  rH   rH   rH   rI   CurveB  s   r  <->c                   @   s   e Zd ZdZdZdS )zArrowStyle.CurveABz8An arrow with heads both at the begin and the end point.r  Nr  rH   rH   rH   rI   CurveAB  s   r  <|-c                   @   s   e Zd ZdZdZdS )zArrowStyle.CurveFilledAz0An arrow with filled triangle head at the begin.r  Nr  rH   rH   rH   rI   CurveFilledA  s   r  -|>c                   @   s   e Zd ZdZdZdS )zArrowStyle.CurveFilledBz.An arrow with filled triangle head at the end.r  Nr  rH   rH   rH   rI   CurveFilledB  s   r  <|-|>c                   @   s   e Zd ZdZdZdS )zArrowStyle.CurveFilledABz1An arrow with filled triangle heads at both ends.r  Nr  rH   rH   rH   rI   CurveFilledAB  s   r  ]-c                       s&   e Zd ZdZdZd fdd	Z  ZS )	zArrowStyle.BracketAz5An arrow with an outward square bracket at its start.r  r   r  r   c                    s   t  j|||d dS a  
            Parameters
            ----------
            widthA : float, default: 1.0
                Width of the bracket.
            lengthA : float, default: 0.2
                Length of the bracket.
            angleA : float, default: 0 degrees
                Orientation of the bracket, as a counterclockwise angle.
                0 degrees means perpendicular to the line.
            )r  r  rd  Nr  r@   r  r  rd  rF   rH   rI   r(     s    zArrowStyle.BracketA.__init__)r   r  r   r   r   r   r   r  r(   r   rH   rH   rF   rI   BracketA  s   r  -[c                       s&   e Zd ZdZdZd fdd	Z  ZS )	zArrowStyle.BracketBz3An arrow with an outward square bracket at its end.r  r   r  r   c                    s   t  j|||d dS a  
            Parameters
            ----------
            widthB : float, default: 1.0
                Width of the bracket.
            lengthB : float, default: 0.2
                Length of the bracket.
            angleB : float, default: 0 degrees
                Orientation of the bracket, as a counterclockwise angle.
                0 degrees means perpendicular to the line.
            )r  r  re  Nr  r@   r  r  re  rF   rH   rI   r(     s    zArrowStyle.BracketB.__init__)r   r  r   r  rH   rH   rF   rI   BracketB  s   r  ]-[c                       s&   e Zd ZdZdZd fdd	Z  ZS )	zArrowStyle.BracketABz3An arrow with outward square brackets at both ends.r  r   r  r   c                    s   t  j||||||d dS )a  
            Parameters
            ----------
            widthA, widthB : float, default: 1.0
                Width of the bracket.
            lengthA, lengthB : float, default: 0.2
                Length of the bracket.
            angleA, angleB : float, default: 0 degrees
                Orientation of the bracket, as a counterclockwise angle.
                0 degrees means perpendicular to the line.
            r  r  rd  r  r  re  Nr  )r@   r  r  rd  r  r  re  rF   rH   rI   r(     s    zArrowStyle.BracketAB.__init__)r   r  r   r   r  r   r  rH   rH   rF   rI   	BracketAB  s
     r  |-|c                       s&   e Zd ZdZdZd fdd	Z  ZS )zArrowStyle.BarABz/An arrow with vertical bars ``|`` at both ends.r  r   r   c                    s   t  j|d||d|d dS )aM  
            Parameters
            ----------
            widthA, widthB : float, default: 1.0
                Width of the bracket.
            angleA, angleB : float, default: 0 degrees
                Orientation of the bracket, as a counterclockwise angle.
                0 degrees means perpendicular to the line.
            r   r  Nr  )r@   r  rd  r  re  rF   rH   rI   r(     s    
zArrowStyle.BarAB.__init__)r   r   r   r   r  rH   rH   rF   rI   BarAB  s   r  ]->c                       s&   e Zd ZdZdZd fdd	Z  ZS )	zArrowStyle.BracketCurveze
        An arrow with an outward square bracket at its start and a head at
        the end.
        r  r   r  Nc                    s   t  j|||d dS r  r  r  rF   rH   rI   r(     s    z ArrowStyle.BracketCurve.__init__)r   r  Nr  rH   rH   rF   rI   BracketCurve  s   r  <-[c                       s&   e Zd ZdZdZd fdd	Z  ZS )	zArrowStyle.CurveBracketze
        An arrow with an outward square bracket at its end and a head at
        the start.
        r  r   r  Nc                    s   t  j|||d dS r  r  r  rF   rH   rI   r(     s    z ArrowStyle.CurveBracket.__init__)r   r  Nr  rH   rH   rF   rI   CurveBracket  s   r  c                       s*   e Zd ZdZd fdd	Zdd Z  ZS )	zArrowStyle.Simplez9A simple arrow. Only works with a quadratic Bezier curve.r   r  c                    s$   |||  | _ | _| _t   dS )aA  
            Parameters
            ----------
            head_length : float, default: 0.5
                Length of the arrow head.

            head_width : float, default: 0.5
                Width of the arrow head.

            tail_width : float, default: 0.2
                Width of the arrow tail.
            Nr  r  
tail_widthr'   r(   r@   r  r  r  rF   rH   rI   r(   -  s    zArrowStyle.Simple.__init__c                 C   s  |  |\}}}}}}	| j| }
t||	|
}||f||f||	fg}zt||dd\}}W nZ ty   t||	|||
\}}d||  d||	   }}||f||f||	fg}d }Y n0 | j| }t||d dd\}}|d ur| j| }t	||d \}}t
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d fg}nLt
j|d ft
j|d ft
j|d ft
j|d ft
j|d ft
j|d fg}t
d	d
 |D dd
 |D }|dfS )N{Gz?	tolerancer   r  wmr   r   r  c                 S   s   g | ]\}}|qS rH   rH   r[   r   r5  rH   rH   rI   r  u  r  z/ArrowStyle.Simple.transmute.<locals>.<listcomp>c                 S   s   g | ]\}}|qS rH   rH   r  rH   rH   rI   r  u  r  T)r  r  r   r   r   r  r  r   r  r   r   re   r<  rZ  rv  )r@   rN   r-  r!   r   r  r  r  r]  r^  r  in_f
arrow_pathZ	arrow_outZarrow_inx1ny1nr  	head_left
head_rightr  	tail_left
tail_right
patch_pathrH   rH   rI   r  >  s\    






zArrowStyle.Simple.transmute)r   r   r  r   r   r   r   r(   r  r   rH   rH   rF   rI   Simple)  s   r  c                       s*   e Zd ZdZd fdd	Zdd Z  ZS )zArrowStyle.Fancyz8A fancy arrow. Only works with a quadratic Bezier curve.r  c                    s$   |||  | _ | _| _t   dS )aA  
            Parameters
            ----------
            head_length : float, default: 0.4
                Length of the arrow head.

            head_width : float, default: 0.4
                Width of the arrow head.

            tail_width : float, default: 0.4
                Width of the arrow tail.
            Nr  r  rF   rH   rI   r(   }  s    zArrowStyle.Fancy.__init__c                 C   s  |  |\}}}}}}	| j| }
||f||f||	fg}t||	|
}zt||dd\}}W nZ ty   t||	|||
\}}d||  d||	   }}||f||f||	fg}|}Y n0 |}t||	|
d }t||dd\}}|}| j| }t||d dd\}}| j| }t||d ddd	d
\}}t|||d	 }t||dd\}}|d }|| }}t	j
|ft	j|d ft	j|d ft	j|d ft	j|d ft	j|d ft	j|d ft	j|d ft	j|d ft	j|d ft	j|d ft	j|d ft	j|ft	j|fg}t	dd |D dd |D }|dfS )Nr  r  r   r  r  g333333?r  r   r   )w1r  w2rN  r   r   r  c                 S   s   g | ]\}}|qS rH   rH   r  rH   rH   rI   r    r  z.ArrowStyle.Fancy.transmute.<locals>.<listcomp>c                 S   s   g | ]\}}|qS rH   rH   r  rH   rH   rI   r    r  T)r  r  r   r   r   r  r  r   r  r   re   rZ  r<  rv  )r@   rN   r-  r!   r   r  r  r  r]  r^  r  r  r  path_outpath_inr  r  	path_headZ	path_tailr  Zhead_lZhead_rr  r  r  Z
tail_startr  r  r  rH   rH   rI   r    sh    








zArrowStyle.Fancy.transmute)r  r  r  r  rH   rH   rF   rI   Fancyy  s   r  c                       s*   e Zd ZdZd fdd	Zdd Z  ZS )	zArrowStyle.Wedgez
        Wedge(?) shape. Only works with a quadratic Bezier curve.  The
        begin point has a width of the tail_width and the end point has a
        width of 0. At the middle, the width is shrink_factor*tail_width.
        r   r   c                    s   || _ || _t   dS )z
            Parameters
            ----------
            tail_width : float, default: 0.3
                Width of the tail.

            shrink_factor : float, default: 0.5
                Fraction of the arrow width at the middle point.
            N)r  shrink_factorr'   r(   )r@   r  r  rF   rH   rI   r(     s    
zArrowStyle.Wedge.__init__c              	   C   s   |  |\}}}}}}	||f||f||	fg}
t|
| j| d | jd\}}tj|d ftj|d ftj|d ftj|d ftj|d ftj|d ftj|d fg}tdd |D dd |D }|d	fS )
Nr  r  r   r   r  c                 S   s   g | ]\}}|qS rH   rH   r  rH   rH   rI   r    r  z.ArrowStyle.Wedge.transmute.<locals>.<listcomp>c                 S   s   g | ]\}}|qS rH   rH   r  rH   rH   rI   r    r  T)	r  r   r  r  r   re   r<  rZ  rv  )r@   rN   r-  r!   r   r  r  r  r]  r^  r  Zb_plusZb_minusr  rH   rH   rI   r    s"    
zArrowStyle.Wedge.transmute)r   r   r  rH   rH   rF   rI   rn    s   rn  N)r   r   r   r   r  r   r  r&  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rn  rH   rH   rH   rI   r    sL   #G  












OWr  c                       s   e Zd ZdZdZdd Zejej	dddej
dd	d
dd3 fdd	Zejd4ddZdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Z  ZS )5FancyBboxPatchaO  
    A fancy box around a rectangle with lower left at *xy* = (*x*, *y*)
    with specified width and height.

    `.FancyBboxPatch` is similar to `.Rectangle`, but it draws a fancy box
    around the rectangle. The transformation of the rectangle box to the
    fancy box is delegated to the style classes defined in `.BoxStyle`.
    Tc                 C   s$   | j jd }|| j| j| j| jf S )Nz((%g, %g), width=%g, height=%g))rG   r   r  r  r   r   r9  rH   rH   rI   r   
  s    zFancyBboxPatch.__str__r#   mutation_scaler$   3.4bbox_transmuterboxstyler  rF  Nr   c           	         s   t  jf i | |d | _|d | _|| _|| _|dkr`tjddd |du rXtd|| _	n
| 
| || _|| _d	| _dS )
a   
        Parameters
        ----------
        xy : float, float
          The lower left corner of the box.

        width : float
            The width of the box.

        height : float
            The height of the box.

        boxstyle : str or `matplotlib.patches.BoxStyle`
            The style of the fancy box. This can either be a `.BoxStyle`
            instance or a string of the style name and optionally comma
            separated attributes (e.g. "Round, pad=0.2"). This string is
            passed to `.BoxStyle` to construct a `.BoxStyle` object. See
            there for a full documentation.

            The following box styles are available:

            %(BoxStyle:table)s

        mutation_scale : float, default: 1
            Scaling factor applied to the attributes of the box style
            (e.g. pad or rounding_size).

        mutation_aspect : float, default: 1
            The height of the rectangle will be squeezed by this value before
            the mutation and the mutated box will be stretched by the inverse
            of it. For example, this allows different horizontal and vertical
            padding.

        Other Parameters
        ----------------
        **kwargs : `.Patch` properties

        %(Patch:kwdoc)s
        r   r   customr  zSupport for boxstyle='custom' is deprecated since %(since)s and will be removed %(removal)s; directly pass a boxstyle instance as the boxstyle parameter instead.messageNz7bbox_transmuter argument is needed with custom boxstyleT)r'   r(   r  r  r   r   r   r  r  _bbox_transmuterset_boxstyle_mutation_scale_mutation_aspectr   )	r@   r   r   r   r  r  r  mutation_aspectrE   rF   rH   rI   r(     s     /


zFancyBboxPatch.__init__c                 K   s:   |du rt  S t|tr*t |fi |n|| _d| _dS )a  
        Set the box style, possibly with further attributes.

        Attributes from the previous box style are not reused.

        Without argument (or with ``boxstyle=None``), the available box styles
        are returned as a human-readable string.

        Parameters
        ----------
        boxstyle : str or `matplotlib.patches.BoxStyle`
            The style of the box: either a `.BoxStyle` instance, or a string,
            which is the style name and optionally comma separated attributes
            (e.g. "Round,pad=0.2"). Such a string is used to construct a
            `.BoxStyle` object, as documented in that class.

            The following box styles are available:

            %(BoxStyle:table_and_accepts)s

        **kwargs
            Additional attributes for the box style. See the table above for
            supported parameters.

        Examples
        --------
        ::

            set_boxstyle("Round,pad=0.2")
            set_boxstyle("round", pad=0.2)
        NT)r'  r  rQ   r   r  r   )r@   r  rE   rH   rH   rI   r   U  s    !zFancyBboxPatch.set_boxstylec                 C   s   | j S )zReturn the boxstyle object.)r  r}   rH   rH   rI   get_boxstyle}  s    zFancyBboxPatch.get_boxstylec                 C   s   || _ d| _dS zf
        Set the mutation scale.

        Parameters
        ----------
        scale : float
        TNr  r   r@   r  rH   rH   rI   set_mutation_scale  s    z!FancyBboxPatch.set_mutation_scalec                 C   s   | j S )zReturn the mutation scale.r  r}   rH   rH   rI   get_mutation_scale  s    z!FancyBboxPatch.get_mutation_scalec                 C   s   || _ d| _dS zz
        Set the aspect ratio of the bbox mutation.

        Parameters
        ----------
        aspect : float
        TNr  r   r@   aspectrH   rH   rI   set_mutation_aspect  s    z"FancyBboxPatch.set_mutation_aspectc                 C   s   | j dur| j S dS z-Return the aspect ratio of the bbox mutation.Nr   r  r}   rH   rH   rI   get_mutation_aspect  s    z"FancyBboxPatch.get_mutation_aspectc              
   C   s   |   }| j}| j}| j}| j}|  }|  }|| ||  }}zt|	||||| W n2 t
y   ||||||d}tjddd Y n0 ||||||}|j|j }	}
|	dddf | |	dddf< t|	|
S )z)Return the mutated path of the rectangle.r   r  zboxstyles must be callable without the 'mutation_aspect' parameter since %(since)s; support for the old call signature will be removed %(removal)s.r  N)r  r  r  r   r   r
  r  r  r  bind	TypeErrorr   r  rb   ra   r   )r@   r  rY   rZ   r   r   Zm_scaleZm_aspectrN   rb   ra   rH   rH   rI   rK     s&     zFancyBboxPatch.get_pathc                 C   s   | j S )z'Return the left coord of the rectangle.)r  r}   rH   rH   rI   r    s    zFancyBboxPatch.get_xc                 C   s   | j S )z)Return the bottom coord of the rectangle.)r  r}   rH   rH   rI   r    s    zFancyBboxPatch.get_yc                 C   s   | j S r  r  r}   rH   rH   rI   r    s    zFancyBboxPatch.get_widthc                 C   s   | j S r  r  r}   rH   rH   rI   r    s    zFancyBboxPatch.get_heightc                 C   s   || _ d| _dS )zo
        Set the left coord of the rectangle.

        Parameters
        ----------
        x : float
        TN)r  r   r   rH   rH   rI   r!    s    zFancyBboxPatch.set_xc                 C   s   || _ d| _dS )zq
        Set the bottom coord of the rectangle.

        Parameters
        ----------
        y : float
        TN)r  r   r"  rH   rH   rI   r#    s    zFancyBboxPatch.set_yc                 C   s   || _ d| _dS )zc
        Set the rectangle width.

        Parameters
        ----------
        w : float
        TNr(  r   rH   rH   rI   r)    s    zFancyBboxPatch.set_widthc                 C   s   || _ d| _dS )zd
        Set the rectangle height.

        Parameters
        ----------
        h : float
        TNr*  r+  rH   rH   rI   r-    s    zFancyBboxPatch.set_heightc                 G   sL   t |dkr|d \}}}}n|\}}}}|| _|| _|| _|| _d| _dS )a  
        Set the bounds of the rectangle.

        Call signatures::

            set_bounds(left, bottom, width, height)
            set_bounds((left, bottom, width, height))

        Parameters
        ----------
        left, bottom : float
            The coordinates of the bottom left corner of the rectangle.
        width, height : float
            The width/height of the rectangle.
        r   r   TN)r>   r  r  r   r   r   r.  rH   rH   rI   r1    s    zFancyBboxPatch.set_boundsc                 C   s   t j| j| j| j| jS r2  )r   r3  from_boundsr  r  r   r   r}   rH   rH   rI   r    s    zFancyBboxPatch.get_bbox)rF  Nr   r   )N)r   r   r   r   r   r   r	   r   r   r   delete_parameterr(   r   r  r  r
  r  r  rK   r  r  r  r  r!  r#  r)  r-  r1  r  r   rH   rH   rF   rI   r    s6   	  D'r  c                       s   e Zd ZdZdZdd Zejej	dddd. fdd	Z
dd Zdd Zdd Zejd/ddZdd Zd0ddZdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zejd)d*d+Zd,d- Z  ZS )1FancyArrowPatcha  
    A fancy arrow patch. It draws an arrow using the `ArrowStyle`.

    The head and tail positions are fixed at the specified start and end points
    of the arrow, but the size and shape (in display coordinates) of the arrow
    does not change when the axis is moved or zoomed.
    Tc              
   C   sh   | j d urL| j \\}}\}}t| j d|dd|dd|dd|dd
S t| j d| j dS d S )Nz((gz, z)->(z))())
_posA_posBtyper   _path_original)r@   r  r  r]  r^  rH   rH   rI   r   $  s    
0zFancyArrowPatch.__str__r#   rN   r$   Nsimplearc3r  r   c                    s   | dtj | dtj t jf i | |durh|durh|du rh||g| _|du r\d}| | n(|du r|du r|durd| _ntd|| _	|| _
|| _|	| _|| _| | |
| _|| _d| _dS )ao
  
        There are two ways for defining an arrow:

        - If *posA* and *posB* are given, a path connecting two points is
          created according to *connectionstyle*. The path will be
          clipped with *patchA* and *patchB* and further shrunken by
          *shrinkA* and *shrinkB*. An arrow is drawn along this
          resulting path using the *arrowstyle* parameter.

        - Alternatively if *path* is provided, an arrow is drawn along this
          path and *patchA*, *patchB*, *shrinkA*, and *shrinkB* are ignored.

        Parameters
        ----------
        posA, posB : (float, float), default: None
            (x, y) coordinates of arrow tail and arrow head respectively.

        path : `~matplotlib.path.Path`, default: None
            If provided, an arrow is drawn along this path and *patchA*,
            *patchB*, *shrinkA*, and *shrinkB* are ignored.

        arrowstyle : str or `.ArrowStyle`, default: 'simple'
            The `.ArrowStyle` with which the fancy arrow is drawn.  If a
            string, it should be one of the available arrowstyle names, with
            optional comma-separated attributes.  The optional attributes are
            meant to be scaled with the *mutation_scale*.  The following arrow
            styles are available:

            %(ArrowStyle:table)s

        connectionstyle : str or `.ConnectionStyle` or None, optional, default: 'arc3'
            The `.ConnectionStyle` with which *posA* and *posB* are connected.
            If a string, it should be one of the available connectionstyle
            names, with optional comma-separated attributes.  The following
            connection styles are available:

            %(ConnectionStyle:table)s

        patchA, patchB : `.Patch`, default: None
            Head and tail patches, respectively.

        shrinkA, shrinkB : float, default: 2
            Shrinking factor of the tail and head of the arrow respectively.

        mutation_scale : float, default: 1
            Value with which attributes of *arrowstyle* (e.g., *head_length*)
            will be scaled.

        mutation_aspect : None or float, default: None
            The height of the rectangle will be squeezed by this value before
            the mutation and the mutated box will be stretched by the inverse
            of it.

        Other Parameters
        ----------------
        **kwargs : `.Patch` properties, optional
            Here is a list of available `.Patch` properties:

        %(Patch:kwdoc)s

            In contrast to other patches, the default ``capstyle`` and
            ``joinstyle`` for `FancyArrowPatch` are set to ``"round"``.
        rD   rC   Nr  z.Either posA and posB, or path need to providedr   )r  r   rF  r   r'   r(   r  set_connectionstyler  rQ  rS  rV  rW  r  set_arrowstyler  r  _dpi_cor)r@   rZ  r[  rN   
arrowstyleconnectionstylerQ  rS  rV  rW  r  r  rE   rF   rH   rI   r(   +  s(    I

zFancyArrowPatch.__init__c                 C   s.   |dur|| j d< |dur$|| j d< d| _dS )a  
        Set the begin and end positions of the connecting path.

        Parameters
        ----------
        posA, posB : None, tuple
            (x, y) coordinates of arrow tail and arrow head respectively. If
            `None` use current value.
        Nr   r   T)r  r   )r@   rZ  r[  rH   rH   rI   set_positions  s
    


zFancyArrowPatch.set_positionsc                 C   s   || _ d| _dS )zn
        Set the tail patch.

        Parameters
        ----------
        patchA : `.patches.Patch`
        TN)rQ  r   )r@   rQ  rH   rH   rI   
set_patchA  s    zFancyArrowPatch.set_patchAc                 C   s   || _ d| _dS )zn
        Set the head patch.

        Parameters
        ----------
        patchB : `.patches.Patch`
        TN)rS  r   )r@   rS  rH   rH   rI   
set_patchB  s    zFancyArrowPatch.set_patchBc                 K   s:   |du rt  S t|tr*t |fi |n|| _d| _dS )aY  
        Set the connection style, possibly with further attributes.

        Attributes from the previous connection style are not reused.

        Without argument (or with ``connectionstyle=None``), the available box
        styles are returned as a human-readable string.

        Parameters
        ----------
        connectionstyle : str or `matplotlib.patches.ConnectionStyle`
            The style of the connection: either a `.ConnectionStyle` instance,
            or a string, which is the style name and optionally comma separated
            attributes (e.g. "Arc,armA=30,rad=10"). Such a string is used to
            construct a `.ConnectionStyle` object, as documented in that class.

            The following connection styles are available:

            %(ConnectionStyle:table_and_accepts)s

        **kwargs
            Additional attributes for the connection style. See the table above
            for supported parameters.

        Examples
        --------
        ::

            set_connectionstyle("Arc,armA=30,rad=10")
            set_connectionstyle("arc", armA=30, rad=10)
        NT)rL  r  rQ   r   
_connectorr   )r@   r$  rE   rH   rH   rI   r     s    !z#FancyArrowPatch.set_connectionstylec                 C   s   | j S )z"Return the `ConnectionStyle` used.)r(  r}   rH   rH   rI   get_connectionstyle  s    z#FancyArrowPatch.get_connectionstylec                 K   s:   |du rt  S t|tr*t |fi |n|| _d| _dS )a   
        Set the arrow style, possibly with further attributes.

        Attributes from the previous arrow style are not reused.

        Without argument (or with ``arrowstyle=None``), the available box
        styles are returned as a human-readable string.

        Parameters
        ----------
        arrowstyle : str or `matplotlib.patches.ArrowStyle`
            The style of the arrow: either a `.ArrowStyle` instance, or a
            string, which is the style name and optionally comma separated
            attributes (e.g. "Fancy,head_length=0.2"). Such a string is used to
            construct a `.ArrowStyle` object, as documented in that class.

            The following arrow styles are available:

            %(ArrowStyle:table_and_accepts)s

        **kwargs
            Additional attributes for the arrow style. See the table above for
            supported parameters.

        Examples
        --------
        ::

            set_arrowstyle("Fancy,head_length=0.2")
            set_arrowstyle("fancy", head_length=0.2)
        NT)r  r  rQ   r   _arrow_transmuterr   )r@   r#  rE   rH   rH   rI   r!    s     zFancyArrowPatch.set_arrowstylec                 C   s   | j S )zReturn the arrowstyle object.)r*  r}   rH   rH   rI   get_arrowstyle  s    zFancyArrowPatch.get_arrowstylec                 C   s   || _ d| _dS r  r  r  rH   rH   rI   r    s    z"FancyArrowPatch.set_mutation_scalec                 C   s   | j S )z\
        Return the mutation scale.

        Returns
        -------
        scalar
        r	  r}   rH   rH   rI   r
    s    z"FancyArrowPatch.get_mutation_scalec                 C   s   || _ d| _dS r  r  r  rH   rH   rI   r  %  s    z#FancyArrowPatch.set_mutation_aspectc                 C   s   | j dur| j S dS r  r  r}   rH   rH   rI   r  0  s    z#FancyArrowPatch.get_mutation_aspectc                 C   s2   |   \}}t|r tj| }|   |S )z5Return the path of the arrow in the data coordinates.)_get_path_in_displaycoordrc   r  r   make_compound_pathrJ   invertedtransform_path)r@   r<  r  rH   rH   rI   rK   5  s    

zFancyArrowPatch.get_pathc                 C   s   | j }| jdurp| | jd }| | jd }|  ||f\}}|  ||| j| j| j| | j	| d}n|  
| j}|  ||  | |  | |  \}}||fS )<Return the mutated path of the arrow in display coordinates.Nr   r   rQ  rS  rV  rW  )r"  r  r   rJ   r   r)  rQ  rS  rV  rW  r/  r  r+  r
  rT   r  )r@   dpi_corrZ  r[  r<  r  rH   rH   rI   r,  >  s&    



z)FancyArrowPatch._get_path_in_displaycoordr  z4self.get_transform().transform_path(self.get_path())r  c                    sh     sd S |d_ \}}t|s:|g}|g}t  | fddt	||D  d S )Nr   c                    s.   g | ]&\}}| |r$j d  r$j ndfqS )rP   Nr   )r[   r5  r_  r   r@   rH   rI   r  m  s   z(FancyArrowPatch.draw.<locals>.<listcomp>)
r   r   r"  r,  rc   r  r   r   r   r  )r@   r   rN   r  rH   r3  rI   r   [  s    
zFancyArrowPatch.draw)NNNr  r  NNr  r  r   r   )N)N)r   r   r   r   r   r   r	   r   r   r   r(   r%  r&  r'  r   r)  r!  r+  r  r
  r  r  rK   r,  deprecate_privatize_attributeZget_path_in_displaycoordr   r   rH   rH   rF   rI   r    s<        f'
'
	r  c                       st   e Zd ZdZdd Zejejdddd fdd	Z	dddZ
dd Zdd Zdd Zdd Z fddZ  ZS )ConnectionPatchz>A patch that connects two points (possibly in different axes).c                 C   s(   d| j d | j d | jd | jd f S )Nz#ConnectionPatch((%g, %g), (%g, %g))r   r   )xy1xy2r}   rH   rH   rI   r   t  s    "zConnectionPatch.__str__r#   axesAr$   Nr  r  r         $@Fc                    sd   |du r|}|| _ || _|| _|| _|| _|| _t jf dd|||	|
|||||d| d| _dS )a^  
        Connect point *xyA* in *coordsA* with point *xyB* in *coordsB*.

        Valid keys are

        ===============  ======================================================
        Key              Description
        ===============  ======================================================
        arrowstyle       the arrow style
        connectionstyle  the connection style
        relpos           default is (0.5, 0.5)
        patchA           default is bounding box of the text
        patchB           default is None
        shrinkA          default is 2 points
        shrinkB          default is 2 points
        mutation_scale   default is text size (in points)
        mutation_aspect  default is 1.
        ?                any key for `matplotlib.patches.PathPatch`
        ===============  ======================================================

        *coordsA* and *coordsB* are strings that indicate the
        coordinates of *xyA* and *xyB*.

        ==================== ==================================================
        Property             Description
        ==================== ==================================================
        'figure points'      points from the lower left corner of the figure
        'figure pixels'      pixels from the lower left corner of the figure
        'figure fraction'    0, 0 is lower left of figure and 1, 1 is upper
                             right
        'subfigure points'   points from the lower left corner of the subfigure
        'subfigure pixels'   pixels from the lower left corner of the subfigure
        'subfigure fraction' fraction of the subfigure, 0, 0 is lower left.
        'axes points'        points from lower left corner of axes
        'axes pixels'        pixels from lower left corner of axes
        'axes fraction'      0, 0 is lower left of axes and 1, 1 is upper right
        'data'               use the coordinate system of the object being
                             annotated (default)
        'offset points'      offset (in points) from the *xy* value
        'polar'              you can specify *theta*, *r* for the annotation,
                             even in cartesian plots.  Note that if you are
                             using a polar axes, you do not need to specify
                             polar for the coordinate system since that is the
                             native "data" coordinate system.
        ==================== ==================================================

        Alternatively they can be set to any valid
        `~matplotlib.transforms.Transform`.

        Note that 'subfigure pixels' and 'figure pixels' are the same
        for the parent figure, so users who want code that is usable in
        a subfigure can use 'subfigure pixels'.

        .. note::

           Using `ConnectionPatch` across two `~.axes.Axes` instances
           is not directly compatible with :doc:`constrained layout
           </tutorials/intermediate/constrainedlayout_guide>`. Add the artist
           directly to the `.Figure` instead of adding it to a specific Axes,
           or exclude it from the layout using ``con.set_in_layout(False)``.

           .. code-block:: default

              fig, ax = plt.subplots(1, 2, constrained_layout=True)
              con = ConnectionPatch(..., axesA=ax[0], axesB=ax[1])
              fig.add_artist(con)

        Nr  r  )rZ  r[  r#  r$  rQ  rS  rV  rW  r  r  r  )	r6  r7  coords1coords2r8  axesBr'   r(   _annotation_clip)r@   ZxyAZxyBZcoordsAZcoordsBr8  r<  r#  r$  rQ  rS  rV  rW  r  r  r  rE   rF   rH   rI   r(   x  s(    R
zConnectionPatch.__init__c                 C   sb  |}|du r| j }t|}|dv rB|| jjd 9 }|dd}n2|dkrT| jj}n |dkrf| jj}n|dkrt|j}|\}}|d	kr|j	}t
| |}t
| |}|||fS |d
kr| jd
kr| | jd	S | | j| j|| jj d  S |dkr8|| }}	|	t| }|	t| }|j	}|||fS |dkr| jj}
|dkr^|
j| n|
j| }|dkr||
j| n|
j| }||fS |dkr| jj}
|dkr|
j| n|
j| }|dkr|
j| n|
j| }||fS |dkr8|j}
|dkr|
j| n|
j| }|dkr&|
j| n|
j| }||fS t|tjrP||S t| ddS )z,Calculate the pixel position of given point.N)zfigure pointszaxes pointsH   ro   pixelszfigure fractionzsubfigure fractionzaxes fractiondatazoffset pointspolarzfigure pixelsr   zsubfigure pixelszaxes pixelsz) is not a valid coordinate transformation)r  rc   r  r  dpir  transFigureZtransSubfigure	transAxes	transDatar   r   r   r   xycoords_get_xyr   r  r  Zfigbboxr   r  r  r  r
  rQ   r   	Transformr  )r@   r   r   r  s0rY   rZ   rM   r  ro  bbrH   rH   rI   rG    sd    









zConnectionPatch._get_xyc                 C   s   || _ d| _dS )a  
        Set the annotation's clipping behavior.

        Parameters
        ----------
        b : bool or None
            - True: The annotation will be clipped when ``self.xy`` is
              outside the axes.
            - False: The annotation will always be drawn.
            - None: The annotation will be clipped when ``self.xy`` is
              outside the axes and ``self.xycoords == "data"``.
        TN)r=  r   r   rH   rH   rI   set_annotation_clip  s    z#ConnectionPatch.set_annotation_clipc                 C   s   | j S )zx
        Return the clipping behavior.

        See `.set_annotation_clip` for the meaning of the return value.
        )r=  r}   rH   rH   rI   get_annotation_clip*  s    z#ConnectionPatch.get_annotation_clipc                 C   s   | j }| | j| j| j}| | j| j| j}|  ||| j	| j
| j| | j| d}|  ||  | |  | |  \}}||fS )r0  r1  )r"  rG  r6  r:  r8  r7  r;  r<  r)  rQ  rS  rV  rW  r+  r
  rT   r  )r@   r2  rZ  r[  rN   r  rH   rH   rI   r,  2  s    

z)ConnectionPatch._get_path_in_displaycoordc                 C   s   |   }|s|du rX| jdkrX| | j| j| j}| jdu rD| j}n| j}||sXdS |sn|du r| jdkr| | j| j| j	}| j	du r| j}n| j	}||sdS dS )z/Check whether the annotation needs to be drawn.Nr@  FT)
rL  r:  rG  r6  r8  r  rX   r;  r7  r<  )r@   r   r   Zxy_pixelr  rH   rH   rI   	_check_xyD  s     



zConnectionPatch._check_xyc                    s4   |d ur|| _ |  r | |s$d S t | d S rW   )Z	_rendererr   rM  r'   r   r   rF   rH   rI   r   ]  s
    zConnectionPatch.draw)NNNr  r  NNr   r   r9  NF)N)r   r   r   r   r   r	   r   r   r   r(   rG  rK  rL  r,  rM  r   r   rH   rH   rF   rI   r5  q  s,              g
9r5  )NT)r  N)N)Ir   r$  r  rf  numbersr   r  collectionsr   numpyrc   
matplotlibr,   r   r   r   r   r   r	   r
   r   r   r   r   bezierr   r   r   r   r   r   r   r   rN   r   _enumsr   r   r   define_aliasesr   r"   r   r   r6  rA  rC  rc  rn  r  r  r   r  getdocr(   
splitlinesr  r  r  r  r  r  r  r  r&  r   r'  rL  r  r  r  r  r5  rH   rH   rH   rI   <module>   s   ((    F4 \2lb^8 *  <* y

R  {   +     s    Y