o
    h~                 	   @   s  d Z ddlZddlZddlZddlmZmZ ddlZddlm	Z	 ddl
m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.Z0G dd de.Z1G dd de.Z2G dd de2Z3G dd de.Z4G d d! d!e.Z5G d"d# d#e.Z6G d$d% d%e4Z7ej+j8d&9e:e7j;pd'< d(d d) G d*d+ d+e1Z=G d,d- d-e.Z>G d.d/ d/e.Z?G d0d1 d1e>Z@G d2d3 d3e>ZAdMd5d6ZBdNd8d9ZCG d:d; d;ZDdOdd<d=d>ZEej+G d?d@ d@eDZFej+G dAdB dBeDZGdCdD ZHej+G dEdF dFeDZIG dGdH dHe.ZJG dIdJ dJe.ZKG dKdL dLeKZLdS )Pz>
Patches are `.Artist`\s with a face color and an edge color.
    N)NumberReal)SimpleNamespace)
namedtuple)Affine2D   )_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ddddddddddd
 fdd
Zd	d
 Zdd ZdWddZ	dWddZ
dWd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-d. Zd/d0 Zd1d2 Z fd3d4Zd5d6 Zd7d8 Zd9d: Zd;d< Z e!e eZ"e#j$d=d> Z%d?d@ Z&e#j$dAdB Z'dCdD Z(dEdF Z)dGdH Z*dIdJ Z+dKdL Z,dMdN Z-e.j/dOdP Z0dQdR Z1dWdSdTZ2dUdV Z3  Z4S )X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   FNT)
r!   r"   colorr$   r#   r    r   fillcapstyle	joinstylec       
            s  t    |du rd}|	du rtj}	|
du rtj}
ttj	d | _
tj	d | _t|| _|durD|dus9|dur>td | | n
| | | | d| _d| _d| _| | | | | | | | | |	 | |
 t|r| | dS dS )zW
        The following kwarg properties are supported

        %(Patch:kwdoc)s
        Nsolidzhatch.colorzhatch.linewidthzQSetting the 'color' property will override the edgecolor or facecolor properties.r   )r   N)super__init__r   buttr   miterr   to_rgbamplrcParams_hatch_color_hatch_linewidthbool_fillr   warn_external	set_colorset_edgecolorset_facecolor
_linewidth_unscaled_dash_pattern_dash_patternset_linestyleset_linewidthset_antialiased	set_hatchset_capstyleset_joinstylelen_internal_update)selfr!   r"   r&   r$   r#   r    r   r'   r(   r)   kwargs	__class__ f/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/matplotlib/patches.pyr,   0   s<   









zPatch.__init__c                 C   s.   |   }|  }||}t|r|d S g S )u   
        Return a copy of the vertices used in this patch.

        If the patch contains Bézier curves, the curves will be interpolated by
        line segments.  To access the curves as curves, use `get_path`.
        r   )get_transformget_pathto_polygonsrC   )rE   transpathpolygonsrI   rI   rJ   	get_vertse   s   
zPatch.get_vertsc                 C   sF   |d ur|S t | jtr| j}|S |  d dkrd}|S |  }|S )N   r   )
isinstance_pickerr   get_edgecolorget_linewidth)rE   radius_radiusrI   rI   rJ   _process_radiuss   s   zPatch._process_radiusc                    s     r	di 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 )aY  
        Test whether the mouse event occurred in the patch.

        Parameters
        ----------
        mouseevent : `~matplotlib.backend_bases.MouseEvent`
            Where the user clicked.

        radius : float, optional
            Additional margin on the patch in target coordinates of
            `.Patch.get_transform`. See `.Path.contains_point` for further
            details.

            If `None`, the default value depends on the state of the object:

            - If `.Artist.get_picker` is a number, the default
              is that value.  This is so that picking works as expected.
            - Otherwise if the edge color has a non-zero alpha, the default
              is half of the linewidth.  This is so that all the colored
              pixels are "in" the patch.
            - Finally, if the edge has 0 alpha, the default is 0.  This is
              so that patches without a stroked edge do not have points
              outside of the filled region report as "in" due to an
              invisible edge.


        Returns
        -------
        (bool, empty dict)
        FNr   c                 3   s*    | ]}|  j jf V  qd S N)contains_pointxyrK   ).0subpath
mouseeventrW   rE   rI   rJ   	<genexpr>   s    
z!Patch.contains.<locals>.<genexpr>)_different_canvasrY   rL   codesverticesnpwherer   MOVETOmapsplitany)rE   ra   rW   rd   re   idxssubpathsinsiderI   r`   rJ   contains   s    




zPatch.containsc                 C       |  |}|  ||  |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
            ``.Patch.get_transform()``. These are display coordinates for patches
            that are added to a figure or Axes.
        radius : float, optional
            Additional margin on the patch in target coordinates of
            `.Patch.get_transform`. See `.Path.contains_point` for further
            details.

            If `None`, the default value depends on the state of the object:

            - If `.Artist.get_picker` is a number, the default
              is that value.  This is so that picking works as expected.
            - Otherwise if the edge color has a non-zero alpha, the default
              is half of the linewidth.  This is so that all the colored
              pixels are "in" the patch.
            - Finally, if the edge has 0 alpha, the default is 0.  This is
              so that patches without a stroked edge do not have points
              outside of the filled region report as "in" due to an
              invisible edge.

        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=3)
        >>> plt.gca().add_patch(c)
        >>> transformed_interior_point = c.get_data_transform().transform((0, 2))
        >>> c.contains_point(transformed_interior_point)
        True

        )rY   rL   r[   rK   )rE   pointrW   rI   rI   rJ   r[      s
   
9
zPatch.contains_pointc                 C   rp   )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
            Additional margin on the patch in target coordinates of
            `.Patch.get_transform`. See `.Path.contains_point` for further
            details.

            If `None`, the default value depends on the state of the object:

            - If `.Artist.get_picker` is a number, the default
              is that value.  This is so that picking works as expected.
            - Otherwise if the edge color has a non-zero alpha, the default
              is half of the linewidth.  This is so that all the colored
              pixels are "in" the patch.
            - Finally, if the edge has 0 alpha, the default is 0.  This is
              so that patches without a stroked edge do not have points
              outside of the filled region report as "in" due to an
              invisible edge.

        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`.
        )rY   rL   contains_pointsrK   )rE   pointsrW   rI   rI   rJ   rr      s
   
$
zPatch.contains_pointsc                    st   t  | |j| _|j| _|j| _|j| _|j| _|j| _|j| _|j	| _	| 
|j | |  | | _d S rZ   )r+   update_from
_edgecolor
_facecolor_original_edgecolor_original_facecolorr5   _hatchr2   r;   r>   r:   set_transformget_data_transformis_transform_set_transformSet)rE   otherrG   rI   rJ   rt     s   zPatch.update_fromc                 C      |   |  S )zU
        Return the `Patch`'s axis-aligned extents as a `~.transforms.Bbox`.
        rL   get_extentsrK   rE   rI   rI   rJ   r   -  s   zPatch.get_extentsc                 C   s   |   tj|  S )z;Return the `~.transforms.Transform` applied to the `Patch`.)get_patch_transformr	   ArtistrK   r   rI   rI   rJ   rK   3  s   zPatch.get_transformc                 C   s   t j| S )zo
        Return the `~.transforms.Transform` mapping data coordinates to
        physical coordinates.
        )r	   r   rK   r   rI   rI   rJ   r{   7     zPatch.get_data_transformc                 C      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   rI   rI   rJ   r   >     	zPatch.get_patch_transformc                 C      | j S )z0Return whether antialiasing is used for drawing.)_antialiasedr   rI   rI   rJ   get_antialiasedI     zPatch.get_antialiasedc                 C   r   )zReturn the edge color.)ru   r   rI   rI   rJ   rU   M  r   zPatch.get_edgecolorc                 C   r   )zReturn the face color.rv   r   rI   rI   rJ   get_facecolorQ  r   zPatch.get_facecolorc                 C   r   )z Return the line width in points.)r:   r   rI   rI   rJ   rV   U  r   zPatch.get_linewidthc                 C   r   )zReturn the linestyle.)
_linestyler   rI   rI   rJ   get_linestyleY  r   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)r0   r1   r   stale)rE   r   rI   rI   rJ   r?   ]  s   

zPatch.set_antialiasedc                 C   s\   d}|d u rt jd s| jr| jrt jd }nd}d}t|| j| _|r)| j| _d| _	d S )NTzpatch.force_edgecolorzpatch.edgecolornoneF)
r0   r1   r5   _edge_defaultr   r/   _alpharu   r2   r   )rE   r&   set_hatch_colorrI   rI   rJ   _set_edgecolorj  s   

zPatch._set_edgecolorc                 C      || _ | | dS )z{
        Set the patch edge color.

        Parameters
        ----------
        color : :mpltype:`color` or None
        N)rw   r   rE   r&   rI   rI   rJ   r8   y     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)r0   r1   r5   r   r   r/   rv   r   )rE   r&   alpharI   rI   rJ   _set_facecolor  s
   

zPatch._set_facecolorc                 C   r   )z{
        Set the patch face color.

        Parameters
        ----------
        color : :mpltype:`color` or None
        N)rx   r   r   rI   rI   rJ   r9     r   zPatch.set_facecolorc                 C   s   |  | | | dS )a  
        Set both the edgecolor and the facecolor.

        Parameters
        ----------
        c : :mpltype:`color`

        See Also
        --------
        Patch.set_facecolor, Patch.set_edgecolor
            For setting the edge or face color individually.
        N)r9   r8   )rE   crI   rI   rJ   r7     s   
zPatch.set_colorc                    s(   t  | | | j | | j d S rZ   )r+   	set_alphar   rx   r   rw   )rE   r   rG   rI   rJ   r     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)	r0   r1   floatr:   mlines_scale_dashesr;   r<   r   rE   wrI   rI   rJ   r>     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_patternr;   r   r:   r<   r   )rE   r   rI   rI   rJ   r=     s   

zPatch.set_linestylec                 C   s,   t || _| | j | | j d| _dS )zh
        Set whether to fill the patch.

        Parameters
        ----------
        b : bool
        TN)r4   r5   r   rx   r   rw   r   rE   brI   rI   rJ   set_fill  s   

zPatch.set_fillc                 C   r   )z#Return whether the patch is filled.)r5   r   rI   rI   rJ   get_fill  r   zPatch.get_fillc                 C      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   )rE   scsrI   rI   rJ   rA        
zPatch.set_capstylec                 C      | j jS )zReturn the capstyle.)r   namer   rI   rI   rJ   get_capstyle     zPatch.get_capstylec                 C   r   )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   )rE   r   jsrI   rI   rJ   rB   	  r   zPatch.set_joinstylec                 C   r   )zReturn the joinstyle.)r   r   r   rI   rI   rJ   get_joinstyle  r   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.

        Parameters
        ----------
        hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
        TN)mhatch_validate_hatch_patternry   r   )rE   r   rI   rI   rJ   r@     s   

zPatch.set_hatchc                 C   r   )zReturn the hatching pattern.)ry   r   rI   rI   rJ   	get_hatch;  r   zPatch.get_hatchc                 C   
   || _ dS )zSet the hatch linewidth.Nr3   )rE   r   rI   rI   rJ   set_hatch_linewidth?     
zPatch.set_hatch_linewidthc                 C   r   )zReturn the hatch linewidth.r   r   rI   rI   rJ   get_hatch_linewidthC  r   zPatch.get_hatch_linewidthc                 C   sR  | d|   | }|j| jdd | j}| jd dks#| jdkr%d}|| |j| j	  |
| j || j || j | | || j ||   || j | jro|| j || j || j |  dur||j|    |  rd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)isRGBArR   r   r   N)PathEffectRendererF)&
open_groupget_gidnew_gcset_foregroundru   r:   r   r>   
set_dashesr<   rA   r   rB   r   r?   r   _set_gc_clipset_url_urlset_snapget_snapr   r   ry   r@   r   r2   r   r3   get_sketch_paramsset_sketch_paramsget_path_effectsmatplotlib.patheffectsr   	draw_pathrestoreclose_groupr   )rE   rendererdraw_path_args_listgcr   r   draw_path_argsrI   rI   rJ   "_draw_paths_with_artist_propertiesG  s:   



z(Patch._draw_paths_with_artist_propertiesc                 C   sV   |   sd S |  }|  }||}| }| |||| jd r$| jnd fg d S )NrR   )get_visiblerL   rK   transform_path_non_affine
get_affiner   rv   )rE   r   rO   	transformtpathaffinerI   rI   rJ   drawy  s   
z
Patch.drawc                 C      t d)zReturn the path of this patch.Derived must overrideNotImplementedErrorr   rI   rI   rJ   rL     r   zPatch.get_pathc                 C   r   rZ   r   rE   r   rI   rI   rJ   get_window_extent  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)rE   xyr\   r]   rI   rI   rJ   _convert_xy_units  s   zPatch._convert_xy_unitsrZ   )5__name__
__module____qualname____doc__zorderr   r,   rQ   rY   ro   r[   rr   rt   r   rK   r{   r   r   rU   r   rV   r   r?   r   r8   r   r9   r7   r   r>   r=   r   r   propertyr'   r   interpdrA   r   rB   r   r@   r   r   r   r   r	   allow_rasterizationr   rL   r   r   __classcell__rI   rI   rG   rJ   r%      st    	5

4
>)#


2

r%   c                       sT   e Zd Zdd Zejdd fdd
Zdd Zd	d
 Zdd Z	 fddZ
  ZS )Shadowc                 C   s   d| j  dS )NzShadow()r   r   rI   rI   rJ   __str__  s   zShadow.__str__gffffff?)shadec             	      s   t    || _||| _| _t | _| | j d|  kr'dks,t	d t	d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. The darkness can be controlled by *shade*.

        Parameters
        ----------
        patch : `~matplotlib.patches.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.
        shade : float, default: 0.7
            How the darkness of the shadow relates to the original color. If 1, the
            shadow is black, if 0, the shadow has the same color as the *patch*.

            .. versionadded:: 3.8

        **kwargs
            Properties of the shadow patch. Supported keys are:

            %(Patch:kwdoc)s
        r   r   zshade must be between 0 and 1.      ?)r"   r!   r   r   N)r+   r,   r   _ox_oyr   r   _shadow_transformrt   
ValueErrorrf   asarrayr   to_rgbr   update	nextafterr   inf)rE   r   oxoyr   rF   r&   rG   rI   rJ   r,     s   



zShadow.__init__c                 C   s.   | | j}| | j}| j || d S rZ   )points_to_pixelsr   r   r   clear	translate)rE   r   r  r  rI   rI   rJ   _update_transform  s   zShadow._update_transformc                 C   s
   | j  S rZ   )r   rL   r   rI   rI   rJ   rL        
zShadow.get_pathc                 C   s   | j  | j S rZ   )r   r   r   r   rI   rI   rJ   r     s   zShadow.get_patch_transformc                    s   |  | t | d S rZ   )r  r+   r   r   rG   rI   rJ   r     s   
zShadow.draw)r   r   r   r   r   r   r,   r  rL   r   r   r   rI   rI   rG   rJ   r     s    'r   c                       s   e Zd ZdZdd Zejdd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,d- Zd.d/ Zd0d1 ZeeeZ  ZS )2	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rE   parsfmtrI   rI   rJ   r        zRectangle.__str__        r   )r  rotation_pointc                   sT   t  jd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 : `~matplotlib.patches.Patch` properties
            %(Patch:kwdoc)s
        r   r         ?NrI   )r+   r,   r	  r
  r  r  r   r  r  _aspect_ratio_correction_convert_units)rE   r   widthheightr  r  rF   rG   rI   rJ   r,     s   


zRectangle.__init__c                 C   r   )z%Return the vertices of the rectangle.)r   unit_rectangler   rI   rI   rJ   rL     r   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  )rE   x0y0x1y1rI   rI   rJ   r    s
   zRectangle._convert_unitsc                 C   s   |   }| jdkr%|j|j |j|j }}|j|d  |j|d  f}n| jdkr1|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  )rE   bboxr  r  r  rI   rI   rJ   r      s    


zRectangle.get_patch_transformc                 C   r   )z The rotation point of the patch.)_rotation_pointr   rI   rI   rJ   r  5     zRectangle.rotation_pointc                 C   sL   |dv st |tr"t|dkr"t |d tr"t |d tr"|| _d S td)N)r  r      r   r   zC`rotation_point` must be one of {'xy', 'center', (number, number)}.)rS   tuplerC   r   r%  r   )rE   valuerI   rI   rJ   r  :  s   
c                 C   r   )z,Return the left coordinate of the rectangle.)r	  r   rI   rI   rJ   get_xE  r   zRectangle.get_xc                 C   r   )z.Return the bottom coordinate of the rectangle.)r
  r   rI   rI   rJ   get_yI  r   zRectangle.get_yc                 C      | j | jfS )z>Return the left and bottom coords of the rectangle as a tuple.)r	  r
  r   rI   rI   rJ   get_xyM     zRectangle.get_xyc                 C      |   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   rI   rI   rJ   get_cornersQ  s   zRectangle.get_cornersc                 C   s   |   dS )z#Return the centre of the rectangle.)r   r   r4  r   rI   rI   rJ   
get_centerY  s   zRectangle.get_centerc                 C   r   z"Return the width of the rectangle.r  r   rI   rI   rJ   	get_width]  r   zRectangle.get_widthc                 C   r   z#Return the height of the rectangle.r  r   rI   rI   rJ   
get_heighta  r   zRectangle.get_heightc                 C   r   )z"Get the rotation angle in degrees.r  r   rI   rI   rJ   	get_anglee  r   zRectangle.get_anglec                 C      || _ d| _dS )z)Set the left coordinate of the rectangle.TN)r	  r   rE   r\   rI   rI   rJ   set_xi     
zRectangle.set_xc                 C   r?  )z+Set the bottom coordinate of the rectangle.TN)r
  r   rE   r]   rI   rI   rJ   set_yn  rB  zRectangle.set_yc                 C   r?  )zs
        Set the rotation angle in degrees.

        The rotation is performed anti-clockwise around *xy*.
        TN)r  r   rE   r  rI   rI   rJ   	set_angles  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   rE   r   rI   rI   rJ   set_xy|  s   
zRectangle.set_xyc                 C   r?  )zSet the width of the rectangle.TNr  r   r   rI   rI   rJ   	set_width  rB  zRectangle.set_widthc                 C   r?  )z Set the height of the rectangle.TNr  r   rE   hrI   rI   rJ   
set_height  rB  zRectangle.set_heightc                 G   L   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)rC   r	  r
  r  r  r   rE   argslr   r   rM  rI   rI   rJ   
set_bounds  s   
zRectangle.set_boundsc                 C   s   t jj|   S zReturn the `.Bbox`.)r   Bboxfrom_extentsr  r   rI   rI   rJ   r     s   zRectangle.get_bbox) r   r   r   r   r   r   r   r,   rL   r  r   r   r  setterr*  r+  r-  r5  r6  r9  r<  r>  rA  rD  rF  rH  rJ  rN  rS  r   r   r   rI   rI   rG   rJ   r    s<    '


	r  c                       sF   e Zd ZdZdd Zej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   numverticesrW   orientationrE   r   rI   rI   rJ   r     s   zRegularPolygon.__str__   r   rW   rZ  c                   sD   || _ || _|| _|| _t|| _t | _	t
 jd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
        NrI   )r   rY  rZ  rW   r   unit_regular_polygon_pathr   r   _patch_transformr+   r,   )rE   r   numVerticesrW   rZ  rF   rG   rI   rJ   r,     s   
zRegularPolygon.__init__c                 C   r   rZ   r_  r   rI   rI   rJ   rL        zRegularPolygon.get_pathc                 C   s"   | j  | j| jj| j S rZ   )r`  r  r"  rW   rotaterZ  r  r   r   rI   rI   rJ   r     s
   z"RegularPolygon.get_patch_transform)r   r   r   r   r   r   r   r,   rL   r   r   rI   rI   rG   rJ   rX    s    rX  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   )rC   r_  re   r(  r[  rI   rI   rJ   r     s   $zPathPatch.__str__c                    s   t  jdi | || _dS )zl
        *path* is a `.Path` object.

        Valid keyword arguments are:

        %(Patch:kwdoc)s
        NrI   )r+   r,   r_  )rE   rO   rF   rG   rI   rJ   r,     s   	
zPathPatch.__init__c                 C   r   rZ   rb  r   rI   rI   rJ   rL     rc  zPathPatch.get_pathc                 C   s
   || _ d S rZ   rb  )rE   rO   rI   rI   rJ   set_path  r  zPathPatch.set_path)r   r   r   r   r   r   r   r   r,   rL   rf  r   rI   rI   rG   rJ   re    s    re  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   )rZ  baselinec                   sX   || _ t|| _t|| _|durt|nd| _|   t j| j	fi | dS )a1  
        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.

        **kwargs
            `Patch` properties:

            %(Patch:kwdoc)s
        N)
rZ  rf   r   _edges_values	_baseline_update_pathr+   r,   r_  )rE   valuesedgesrZ  ri  rF   rG   rI   rJ   r,     s   zStepPatch.__init__c           
      C   s  t t | jrtd| jjd | jjkr&td| jj d| jj dt dgt jdtj	dg}}t | j}| j
d urI|t | j
O }t| D ]\}}t | j||d  d	}t | j|| d	}| j
d u rt |d d ||d
d  g}nU| j
jdkrt | j
g|| j
gg}nB| 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    qOt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` specifiedrh  )rf   isnansumrj  r   sizerk  emptyr   	code_typerl  r
   contiguous_regionsrepeatconcatenatendimrZ  column_stackappendrh   LINETOrC   r_  )
rE   vertsrd   	_nan_maskidx0idx1r\   r]   baser   rI   rI   rJ   rm  '  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   rk  rj  rl  )rE   r  rI   rI   rJ   get_dataK  s   
zStepPatch.get_dataNc                 C   sn   |du r|du r|du rt d|durt|| _|dur$t|| _|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   rf   r   rk  rj  rl  rm  r   )rE   rn  ro  ri  rI   rI   rJ   set_dataP  s   
zStepPatch.set_data)NNN)r   r   r   r   r   r   r   r,   rm  r  r  r   rI   rI   rG   rJ   rg    s    "$rg  c                       sj   e Zd ZdZdd Zej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   s4   t | jjrd}|t | jjg| jjd R  S dS )NzPolygon%d((%g, %g) ...)r   z
Polygon0())rC   r_  re   r[  rI   rI   rJ   r   j  s    zPolygon.__str__Tclosedc                   s&   t  jdi | || _| | dS )z
        Parameters
        ----------
        xy : (N, 2) array

        closed : bool, default: True
            Whether the polygon is closed (i.e., has identical start and end
            points).

        **kwargs
            %(Patch:kwdoc)s
        NrI   )r+   r,   _closedrH  )rE   r   r  rF   rG   rI   rJ   r,   q  s   zPolygon.__init__c                 C   r   )zGet the `.Path` of the polygon.rb  r   rI   rI   rJ   rL     r   zPolygon.get_pathc                 C   r   )z%Return whether the polygon is closed.)r  r   rI   rI   rJ   
get_closed  r   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)r  r4   rH  r-  r   )rE   r  rI   rI   rJ   
set_closed  s
   	

zPolygon.set_closedc                 C   r   )z
        Get the vertices of the path.

        Returns
        -------
        (N, 2) array
            The coordinates of the vertices.
        )r_  re   r   rI   rI   rJ   r-    r   zPolygon.get_xyc                 C   s   t |}|j\}}| jr*|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`, 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   rr  r'  Nr  T)
rf   r   shaper  rk   rz  allr   r_  r   )rE   r   nverts_rI   rI   rJ   rH    s   

$
zPolygon.set_xyz+The vertices of the path as a (N, 2) array.)doc)r   r   r   r   r   r   r   r,   rL   r  r  r-  rH  r   r   r   rI   rI   rG   rJ   r  g  s    !r  c                       sl   e Zd ZdZdd Zej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  rI   rI   rJ   r     s
   zWedge.__str__Nr  c                   sJ   t  jd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
        NrI   )r+   r,   r  r  r  r  r  r   r   r`  _recompute_path)rE   r  r  r  r  r  rF   rG   rI   rJ   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rX|j}|jd d d | j	| j  | j	 }t
||dgg}g |j||jdd  tj}nt
|jddgg}g |j|tj}t|| j	 | j || _d S )Nh  g-q=)r   r  rr  r0  r   )absr  r  r   rh   r~  arcr  re   r  rf   rz  rd   	CLOSEPOLYr  r_  )	rE   r  r  	connectorr  v1v2vr   rI   rI   rJ   r    s   
"$zWedge._recompute_pathc                 C      d | _ || _d| _d S NT)r_  r  r   )rE   r  rI   rI   rJ   
set_center     
zWedge.set_centerc                 C   r  r  )r_  r  r   rE   rW   rI   rI   rJ   
set_radius  r  zWedge.set_radiusc                 C   r  r  )r_  r  r   )rE   r  rI   rI   rJ   
set_theta1  r  zWedge.set_theta1c                 C   r  r  )r_  r  r   )rE   r  rI   rI   rJ   
set_theta2  r  zWedge.set_theta2c                 C   r  r  )r_  r  r   rE   r  rI   rI   rJ   rJ    r  zWedge.set_widthc                 C      | j d u r	|   | j S rZ   r_  r  r   rI   rI   rJ   rL        
zWedge.get_path)r   r   r   r   r   r   r   r,   r  r  r  r  r  rJ  rL   r   rI   rI   rG   rJ   r    s    r  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	d	d fdd
Z
dd Zdd ZdddZ  ZS )ArrowzAn arrow patch.c                 C      dS )NzArrow()rI   r   rI   rI   rJ   r   $     zArrow.__str__r  皙?g皙?g333333ӿr  333333?r  c                   s(   t  jdi | | ||||| 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.
        NrI   )r+   r,   r  )rE   r\   r]   dxdyr  rF   rG   rI   rJ   r,   +  s   zArrow.__init__c                 C   r   rZ   rb  r   rI   rI   rJ   rL   L  rc  zArrow.get_pathc                 C   r   rZ   )r`  r   rI   rI   rJ   r   O  rc  zArrow.get_patch_transformNc                 C   s   |dur|| _ |dur|| _|dur|| _|dur|| _|dur#|| _t t	| j| j| j
t| j| j| j | j | _dS )a  
        Set `.Arrow` x, y, dx, dy and width.
        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.
        N)_x_y_dx_dyr  r   r   r"  rf   hypotrd  arctan2r  frozenr`  )rE   r\   r]   r  r  r  rI   rI   rJ   r  R  s    zArrow.set_data)NNNNN)r   r   r   r   r   r   _create_closedr_  r   r   r,   rL   r   r  r   rI   rI   rG   rJ   r  !  s     r  c                	       sf   e Zd ZdZdZdd Zejdddd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   r  )NzFancyArrow()rI   r   rI   rI   rJ   r   {  r  zFancyArrow.__str__gMbP?FNfullr   )r  length_includes_head
head_widthhead_lengthr  overhanghead_starts_at_zeroc                   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
        r  TN)r  r  r  r  r  _length_includes_head_head_width_head_length_shape	_overhang_head_starts_at_zero_make_vertsr+   r,   r  )rE   r\   r]   r  r  r  r  r  r  r  r  r  rF   rG   rI   rJ   r,   ~  s   *zFancyArrow.__init__)r\   r]   r  r  r  r  r  c                C   sz   |dur|| _ |dur|| _|dur|| _|dur|| _|dur#|| _|dur*|| _|dur1|| _|   | | 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  rH  r  )rE   r\   r]   r  r  r  r  r  rI   rI   rJ   r    s    zFancyArrow.set_datac                 C   s  | j d u rd| j }n| j }| jd u rd| }n| j}t| j| j}| jr)|}n|| }|s9tddg| _	d S ||}}| j
| j}}tddg| | d g| d|  | d g| | d g| dgg}	| jss|	|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rt|	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 )NrR   g      ?r   r'  r  r   leftrr  rightr  zGot unknown shape: r3  )r  r  r  rf   r  r  r  r  rv  r  r  arrayr  r  rz  r   dotr  r  )rE   r  r  distancelengthhwhlhsr   left_half_arrowcoordsright_half_arrowcxsxMrI   rI   rJ   r    sX   










zFancyArrow._make_verts)r   r   r   r   r   r   r   r   r,   r  r  r   rI   rI   rG   rJ   r  t  s    
7(r  
r   r'  )r  c                       s6   e Zd ZdZdd Zej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   rW   rY  r[  rI   rI   rJ   r   %  s    zCirclePolygon.__str__r\     )
resolutionc                   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   r]  Nr+   r,   )rE   r   rW   r  rF   rG   rI   rJ   r,   )  s   
zCirclePolygon.__init__r\  )	r   r   r   r   r   r   r   r,   r   rI   rI   rG   rJ   r  "  s    r  c                       s   e Zd ZdZdd Zej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d d! 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  rI   rI   rJ   r   >  s
   zEllipse.__str__r   r=  c                   sJ   t  jd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  NrI   )r+   r,   r  r  r  _angler   unit_circler_  r  r   r   r`  )rE   r   r  r  r  rF   rG   rI   rJ   r,   D  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`  )rE   r  r  r  rI   rI   rJ   _recompute_transformg  s   	
zEllipse._recompute_transformc                 C   r   )zReturn the path of the ellipse.rb  r   rI   rI   rJ   rL   z  r   zEllipse.get_pathc                 C   s   |    | jS rZ   )r  r`  r   rI   rI   rJ   r   ~  s   zEllipse.get_patch_transformc                 C   r?  )zs
        Set the center of the ellipse.

        Parameters
        ----------
        xy : (float, float)
        TN)r  r   rG  rI   rI   rJ   r       
zEllipse.set_centerc                 C   r   )z!Return the center of the ellipse.r  r   rI   rI   rJ   r6    r   zEllipse.get_centerc                 C   r?  )zl
        Set the width of the ellipse.

        Parameters
        ----------
        width : float
        TNrI  r  rI   rI   rJ   rJ    r  zEllipse.set_widthc                 C   r   )z2
        Return the width of the ellipse.
        r8  r   rI   rI   rJ   r9    s   zEllipse.get_widthc                 C   r?  )zn
        Set the height of the ellipse.

        Parameters
        ----------
        height : float
        TNrK  )rE   r  rI   rI   rJ   rN    r  zEllipse.set_heightc                 C   r   )z!Return the height of the ellipse.r;  r   rI   rI   rJ   r<    r   zEllipse.get_heightc                 C   r?  )zl
        Set the angle of the ellipse.

        Parameters
        ----------
        angle : float
        TN)r  r   rE  rI   rI   rJ   rF    r  zEllipse.set_anglec                 C   r   )z Return the angle of the ellipse.r  r   rI   rI   rJ   r>    r   zEllipse.get_anglec                 C   r/  )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.
        ))rr  rr  )r   rr  r2  )rr  r   r4  r   rI   rI   rJ   r5    s   zEllipse.get_cornersc                 C   @   | j | jk r|  ddg}n	|  ddg}dd |D S )z
        Return the vertices coordinates of the ellipse.

        The definition can be found `here <https://en.wikipedia.org/wiki/Ellipse>`_

        .. versionadded:: 3.8
        r3  r   rr  r1  rr  r   c                 S      g | ]}t |qS rI   r(  r^   r\   rI   rI   rJ   
<listcomp>      z(Ellipse.get_vertices.<locals>.<listcomp>r  r  r   r   rE   retrI   rI   rJ   get_vertices     zEllipse.get_verticesc                 C   r  )z
        Return the co-vertices coordinates of the ellipse.

        The definition can be found `here <https://en.wikipedia.org/wiki/Ellipse>`_

        .. versionadded:: 3.8
        r1  r  r3  r  c                 S   r  rI   r  r  rI   rI   rJ   r    r  z+Ellipse.get_co_vertices.<locals>.<listcomp>r  r  rI   rI   rJ   get_co_vertices  r  zEllipse.get_co_vertices)r   r   r   r   r   r   r   r,   r  rL   r   r  r6  r   r  rJ  r9  r  rN  r<  r  rF  r>  r  r5  r  r  r   rI   rI   rG   rJ   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d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
        NrI   )r+   r,   	set_radiir  r  r  r_  )rE   r   r  r  r  rF   rG   rI   rJ   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  rE   r  rI   rI   rJ   r     s   zAnnulus.__str__c                 C      || _ d| _d| _dS )zs
        Set the center of the annulus.

        Parameters
        ----------
        xy : (float, float)
        NT)r  r_  r   rG  rI   rI   rJ   r       
zAnnulus.set_centerc                 C   r   )z!Return the center of the annulus.r  r   rI   rI   rJ   r6  *  r   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 to semi-minor axisNT)minr  r   r   r  r_  r   r  rI   rI   rJ   rJ  0  s   

zAnnulus.set_widthc                 C   r   )z1Return the width (thickness) of the annulus ring.r8  r   rI   rI   rJ   r9  B  r   zAnnulus.get_widthc                 C   r  )zq
        Set the tilt angle of the annulus.

        Parameters
        ----------
        angle : float
        NT)r  r_  r   rE  rI   rI   rJ   rF  H  r  zAnnulus.set_anglec                 C   r   )z Return the angle of the annulus.r  r   rI   rI   rJ   r>  T  r   zAnnulus.get_anglec                 C      t || _d| _d| _dS )zv
        Set the semi-major axis *a* of the annulus.

        Parameters
        ----------
        a : float
        NT)r   r  r_  r   )rE   r  rI   rI   rJ   set_semimajorZ     

zAnnulus.set_semimajorc                 C   r  )zv
        Set the semi-minor axis *b* of the annulus.

        Parameters
        ----------
        b : float
        NT)r   r   r_  r   r   rI   rI   rJ   set_semiminorf  r  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'  rI   z(Parameter 'r' must be one or two floats.NT)rf   r  r  r   r   r   r_  r   r  rI   rI   rJ   r  r  s   
zAnnulus.set_radiic                 C   r,  )z:Return the semi-major and semi-minor radii of the annulus.)r  r   r   rI   rI   rJ   	get_radii  r.  zAnnulus.get_radiic                 C   s4   t  j| ||f | jj| | j |S rZ   )	r   r   r"  r   r#  r  r  r  r   )rE   r  r  r   rI   rI   rJ   _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   r  rr  r0  r   )r   r  r  r   r  r  re   rf   vstackhstackrd   rh   r  r_  )	rE   r  r  r   r   r  r  r  r   rI   rI   rJ   r    s   "zAnnulus._recompute_pathc                 C   r  rZ   r  r   rI   rI   rJ   rL     r  zAnnulus.get_pathr  )r   r   r   r   r   r   r,   r   r  r6  r   r  rJ  r9  r  rF  r>  r  r  r   r  r  radiir  r  rL   r   rI   rI   rG   rJ   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  rW   r  rI   rI   rJ   r     r  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,   rW   )rE   r   rW   rF   rG   rI   rJ   r,     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  rI   rI   rJ   r    s   
zCircle.set_radiusc                 C   s
   | j d S )z Return the radius of the circle.r  r  r   rI   rI   rJ   
get_radius  r   zCircle.get_radiusr  )r   r   r   r   r   r   r   r,   r  r  r   rW   r   rI   rI   rG   rJ   r    s    r  c                       sV   e Zd ZdZdd Z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  r  r  r  rI   rI   rJ   r     s
   zArc.__str__r  g     v@)r  r  r  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 : `~matplotlib.patches.Patch` properties
            Most `.Patch` properties are supported as keyword arguments,
            except *fill* and *facecolor* because filling is not supported.

        %(Patch:kwdoc)s
        r'   FzArc objects cannot be filledr  N)
setdefaultr   r+   r,   r  r  _theta_stretch_theta1_theta2_stretched_width_stretched_heightr   r  r_  )	rE   r   r  r  r  r  r  rF   r'   rG   rI   rJ   r,     s   $zArc.__init__c                    s  |   sdS |   |   |  }|| j| jf|d \}}d}||k r2||k r2t| |S dd   fdd}t	
| jpF| jdd	j|   }t |}t }	t|jdd
 |jdd D ].\}
}|g |
|R  }|j\}}tt||d d }|	|| j|k || jk @   qft|	| jg }	| j}t| j}|t|t |f}| j!}|	D ]}|rt"||d| _!t| | d}nd}|}q|| _!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`.
        Nr0  g\!Ac                 S   s   ||  }|| }|| ||  }| | ||  }|| }|| }	|	dkrdt d|}
t |	}t || |
| |  | | | t||  | g|| |
| |  | | | t||  | ggS t dS )Nr  r   rp  )rf   copysignsqrtr  r  rv  )r  r  r  r  r  r  dr2DD2discrimsign_dysqrt_discrimrI   rI   rJ   line_circle_intersectW  s&   

z'Arc.draw.<locals>.line_circle_intersectc                    s   d}|| k r|| }}n| |}}||k r||}}n||}} | |||}	|	j \}
}|	|| |
k |
|| k @ || |k @ ||| k @  S )Ng&.>)T)r  r  r  r  epsilonx0ex1ey0ey1exysxsysr  rI   rJ   segment_circle_intersecti  s    




z*Arc.draw.<locals>.segment_circle_intersectFrootrr  r   r     T)#r   r  rm  r{   r   r  r  r%   r   r   r!  axes
get_figurer$  rK   r   r  transformedsetzipre   r  rf   rad2degr  r   r  r  sorteddeg2radr[   cossinr_  r  )rE   r   data_to_screen_transpwidthpheight	inv_errorr#  box_path_transformbox_paththetasp0p1r   r\   r]   theta
last_theta
theta1_radrn   path_originalrI   r"  rJ   r     sX   .&

zArc.drawc                 C   s^   |   }tdd t|| j| j| j| jfD r-|\| _| _| _| _t| j| j| _	d S d S )Nc                 s   s    | ]	\}}||kV  qd S rZ   rI   )r^   r  r   rI   rI   rJ   rb     s    z#Arc._update_path.<locals>.<genexpr>)
r  rk   r+  r  r  r  r  r   r  r_  )rE   	stretchedrI   rI   rJ   rm    s   

zArc._update_pathc                 C   s   dd }|  | j}| | j}||kr:| j| jkr$| jd | jd ks:|| j|| }|| j|| }||||fS | j| j||fS )Nc                 S   s@   t | } t | }t | }t t || |}|d d S )Nr  )rf   r.  r/  r0  r,  r  )r:  r"  r\   r]   sthetarI   rI   rJ   theta_stretch  s
   


z)Arc._theta_stretch.<locals>.theta_stretchr  )r   r  r   r  r  r  )rE   r@  r  r  r  r  rI   rI   rJ   r    s   zArc._theta_stretch)r   r   r   r   r   r   r   r,   r	   r   r   rm  r  r   rI   rI   rG   rJ   r	    s    /
 
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  r'   r   clip_on)copypopr  r   r  r  r  r  r  r   r   r   r   )r	   r   propsr'   rA  r$  r  rI   rI   rJ   bbox_artist  s   	



rG  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!   r'   rC  N)r  r8  r  r  rz   r   )r$  r   r&   rN   r  rI   rI   rJ   	draw_bbox  s   
rI  c                   @   sT   e Zd ZdZdd Zdd Zedd Zedd	 Zee	j
d
ddd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   sR   t jjdi | j d|  | j d|  d dtdj| j d i d S )Nz:tablez:table_and_acceptsz

    .. ACCEPTS: [|z '{}' ]rI   )	r   r   registerr   pprint_stylesjoinri   format_style_listclsrI   rI   rJ   __init_subclass__  s   


z_Style.__init_subclass__c           	   
   K   s   | ddd}|d  }z| j| }W n ty* } ztd||d}~ww zdd |d	d D }d
d |D }W n tyS } ztd||d}~ww |d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 )=)rj   )r^   r   rI   rI   rJ   r  	  s    z"_Style.__new__.<locals>.<listcomp>r   c                 S   s   i | ]	\}}|t |qS rI   )r   )r^   rH  r  rI   rI   rJ   
<dictcomp>	  s    z"_Style.__new__.<locals>.<dictcomp>zIncorrect style argument: rI   )replacerj   lowerrQ  KeyErrorr   )	rS  	stylenamerF   _list_name_clserr
_args_pair_argsrI   rI   rJ   __new__	  s(   z_Style.__new__c                 C   r   )z(Return a dictionary of available styles.)rQ  rR  rI   rI   rJ   
get_styles	  r&  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 | ]\}}|j d | d tt|dd pdfqS )z``r   rr  r   )r   strinspect	signature)r^   r   rS  rI   rI   rJ   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 rZ   )rC   )r^   cellrI   rI   rJ   rb   *	      2_Style.pprint_styles.<locals>.<listcomp>.<genexpr>)max)r^   columnrI   rI   rJ   r  *	  s      c                 s   s    | ]}d | V  qdS )rV  NrI   )r^   clrI   rI   rJ   rb   +	  rk  z'_Style.pprint_styles.<locals>.<genexpr>r  r   c                 s       | ]
\}}| |V  qd S rZ   ljustr^   rj  rp  rI   rI   rJ   rb   /	      r   c                    s&   g | ]}d  dd t| D qS )ro  c                 s   rq  rZ   rr  rt  rI   rI   rJ   rb   1	  ru  rl  )rO  r+  )r^   rowcol_lenrI   rJ   r  1	  s    r   Nz    )prefix)rQ  itemsr+  rO  textwrapindent)rS  tabletable_formatstr	rst_tablerI   rw  rJ   rN  	  s(   

	z_Style.pprint_stylesz3.10.0z%This method is never used internally.z6No replacement.  Please open an issue if you use this.)messagealternativec                 C   s.   t || jst| d| j || j|< dS )zRegister a new style.z must be a subclass of N)
issubclass_Baser   rQ  )rS  r   stylerI   rI   rJ   rM  7	  s   z_Style.registerN)r   r   r   r   rT  rb  classmethodrc  rN  r   
deprecatedrM  rI   rI   rI   rJ   rJ    s    

rJ  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   rY  )
style_listrS  r   rI   rI   rJ   r  D	  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	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                   @   "   e Zd ZdZdddZdd ZdS )	zBoxStyle.SquarezA square box.r  c                 C   r   z
            Parameters
            ----------
            pad : float, default: 0.3
                The amount of padding around the original box.
            NrA  rE   rA  rI   rI   rJ   r,   p	     
zBoxStyle.Square.__init__c           	      C   sj   || j  }|d|  |d|  }}|| || }}|| || }}t||f||f||f||fgS Nr'  rA  r   r  )	rE   r  r  r  r  mutation_sizerA  r  r  rI   rI   rJ   __call__y	  s   
zBoxStyle.Square.__call__Nr  r   r   r   r   r,   r  rI   rI   rI   rJ   Squarel	      
	r  c                   @   r  )	zBoxStyle.CirclezA circular box.r  c                 C   r   r  r  r  rI   rI   rJ   r,   	  r  zBoxStyle.Circle.__init__c                 C   s`   || j  }|d|  |d|  }}|| || }}t||d  ||d  ft||d S r  )rA  r   circlerm  )rE   r  r  r  r  r  rA  rI   rI   rJ   r  	  s   
zBoxStyle.Circle.__call__Nr  r  rI   rI   rI   rJ   r  	  r  r  c                   @   r  )	zBoxStyle.EllipsezC
        An elliptical box.

        .. versionadded:: 3.7
        r  c                 C   r   r  r  r  rI   rI   rJ   r,   	  r  zBoxStyle.Ellipse.__init__c           
      C   s   || j  }|d|  |d|  }}|| || }}|td }|td }t ||||d  ||d  }	|	t S r  )	rA  mathr  r   r"  r  transform_pathr   r  )
rE   r  r  r  r  r  rA  r  r   rN   rI   rI   rJ   r  	  s   

zBoxStyle.Ellipse.__call__Nr  r  rI   rI   rI   rJ   r  	  s    
	r  c                   @   r  )	zBoxStyle.LArrowz,A box in the shape of a left-pointing arrow.r  c                 C   r   r  r  r  rI   rI   rJ   r,   	  r  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  rE   r  r  r  r  r  rA  r  r  r  dxxrI   rI   rJ   r  	  s   
 
zBoxStyle.LArrow.__call__Nr  r  rI   rI   rI   rJ   LArrow	  r  r  c                   @      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  r  r  re   )rE   r  r  r  r  r  prI   rI   rJ   r  	  s
   ,zBoxStyle.RArrow.__call__Nr   r   r   r   r  rI   rI   rI   rJ   RArrow	      r  c                   @   r  )	zBoxStyle.DArrowz&A box in the shape of a two-way arrow.r  c                 C   r   r  r  r  rI   rI   rJ   r,   	  r  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 r  r  r  rI   rI   rJ   r  	  s    


zBoxStyle.DArrow.__call__Nr  r  rI   rI   rI   rJ   DArrow	  s    
	r  c                   @   "   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      || _ || _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rA  rounding_sizerE   rA  r  rI   rI   rJ   r,   
     	
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  )rA  r  r   rh   r~  CURVE3r  rE   r  r  r  r  r  rA  drr  r  cpcomrI   rI   rJ   r  
  s<   







zBoxStyle.Round.__call__r  Nr  rI   rI   rI   rJ   Round
      
r  c                   @   r  )	zBoxStyle.Round4zA box with rounded edges.r  Nc                 C   r  )z
            Parameters
            ----------
            pad : float, default: 0.3
                The amount of padding around the original box.
            rounding_size : float, default: *pad*/2
                Rounding of edges.
            Nr  r  rI   rI   rJ   r,   A
  r  zBoxStyle.Round4.__init__c                 C   sV  || 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'  )rA  r  r   rh   CURVE4r  r  rI   rI   rJ   r  M
  s.   
""""
zBoxStyle.Round4.__call__r  r  rI   rI   rI   rJ   Round4=
  r  r  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   r  )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)rA  
tooth_size)rE   rA  r  rI   rI   rJ   r,   r
  r  zBoxStyle.Sawtooth.__init__c                 C   s  || j  }| jd u r| j d | }n| j| }|d }|d|  | }|d|  | }t|| |d  d }	t|| |d  d }
|| | || | }}|| || }}|gt|| || d|	 d ||| ||| g|
 d d|
 d  |t|| || d|	 d ||| ||| g|
 d d|
 d  }g ||| ||| g|	 d d|	 d  |t|| || d|
 d ||| ||| g|	 d d|	 d  |t|| || d|
 d }g t|||d |d fS )Nr   r'  r   r   )rA  r  roundrf   linspacer+  )rE   r  r  r  r  r  rA  r  hszdsx_ndsy_nr  r  r   r!  rI   rI   rJ   _get_sawtooth_vertices~
  sJ   


&&&&z(BoxStyle.Sawtooth._get_sawtooth_verticesc                 C   s   |  |||||}t|ddS )NTr  )r  r   )rE   r  r  r  r  r  saw_verticesrI   rI   rJ   r  
  s   
zBoxStyle.Sawtooth.__call__r  )r   r   r   r   r,   r  r  rI   rI   rI   rJ   Sawtoothn
  s
    
&r  c                   @   r  )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'  )r  rf   rz  r   rh   r  rC   r  )rE   r  r  r  r  r  r  rd   rI   rI   rJ   r  
  s   
zBoxStyle.Roundtooth.__call__Nr  rI   rI   rI   rJ   
Roundtooth
  r  r  N)r   r   r   r   rQ  r  r  r  r  r  r  r  r  r  r  r  rI   rI   rI   rJ   r  L	  s.    	$90: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 a 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                   @   s,   e Zd Z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    fddS )zw
            Return a predicate function testing whether a point *xy* is
            contained in *patch*.
            c                    s     t| d | d dd S )Nr   r   )r\   r]   )ro   r   )r   r   rI   rJ   <lambda>
  s
    z1ConnectionStyle._Base._in_patch.<locals>.<lambda>rI   )rE   r   rI   r   rJ   	_in_patch
  r   zConnectionStyle._Base._in_patchc                 C   s\   |rz	t ||\}}W n	 ty   Y nw |r,z
t ||\}}W |S  ty+   Y |S w |S )a$  
            Clip *path* at its start by the region where *in_start* returns
            True, and at its stop by the region where *in_stop* returns True.

            The original path is assumed to start in the *in_start* region and
            to stop in the *in_stop* region.
            )r   r   )rE   rO   in_startin_stopr  rI   rI   rJ   _clip
  s   zConnectionStyle._Base._clipr  Nc                 C   s   |  ||}| ||r| |nd|r| |nd}| ||r,tg |jd |R  nd|r>tg |jd |R  }|S d}|S )z
            Call the *connect* method to create a path between *posA* and
            *posB*; then clip and shrink the path.
            Nr   rr  )connectr  r  r   re   )rE   posAposBshrinkAshrinkBpatchApatchBrO   rI   rI   rJ   r  	  s   zConnectionStyle._Base.__call__)r  r  NN)r   r   r   r   r  r  r  rI   rI   rI   rJ   r  
  s    r  c                   @   r  )	zConnectionStyle.Arc3uN  
        Creates a simple quadratic Bézier 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   r   )zy
            Parameters
            ----------
            rad : float
              Curvature of the curve.
            N)rad)rE   r  rI   rI   rJ   r,   &  r  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   rh   r  )rE   r  r  r  r  x2y2x12y12r  r  fr  cyre   rd   rI   rI   rJ   r  /  s   
zConnectionStyle.Arc3.connectNr  r   r   r   r   r,   r  rI   rI   rI   rJ   Arc3  s    
	r  c                   @   s"   e Zd ZdZd	ddZdd ZdS )
zConnectionStyle.Angle3u  
        Creates a simple quadratic Bézier curve between two points. The middle
        control point 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   r  )z
            Parameters
            ----------
            angleA : float
              Starting angle of the path.

            angleB : float
              Ending angle of the path.
            N)angleAangleB)rE   r  r  rI   rI   rJ   r,   K  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 rZ   )
r  r/  radiansr  r0  r  r   r   rh   r  )rE   r  r  r  r  r  r  cosAsinAcosBsinBr  r  re   rd   rI   rI   rJ   r  Y  s   

zConnectionStyle.Angle3.connectN)r  r   r  rI   rI   rI   rJ   Angle3B  s    
r  c                   @   s"   e Zd ZdZd
ddZdd Zd	S )zConnectionStyle.Angleu]  
        Creates a piecewise continuous quadratic Bézier 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*.
        r  r   r  c                 C   s   || _ || _|| _dS )a  
            Parameters
            ----------
            angleA : float
              Starting angle of the path.

            angleB : float
              Ending angle of the path.

            rad : float
              Rounding radius of the edge.
            N)r  r  r  )rE   r  r  r  rI   rI   rJ   r,   t  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rU|
||f |
tj nQ|| || }}t||}| j	| }|| || }}t||}| j	| }||||  |||  f||f|||  |||  fg |tjtjtjg |
||f |
tj t||S )Nr  )r  r/  r  r  r0  r  r   r   rh   r  r}  r~  rf   r  extendr  )rE   r  r  r  r  r  r  r  r  r  r  r  r  re   rd   dx1dy1d1f1dx2dy2d2f2rI   rI   rJ   r    s8   





zConnectionStyle.Angle.connectN)r  r   r  r  rI   rI   rI   rJ   Anglej  s    
r  c                   @   s"   e Zd ZdZd	ddZdd ZdS )
zConnectionStyle.Arcu?  
        Creates a piecewise continuous quadratic Bézier 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 )a  
            Parameters
            ----------
            angleA : float
              Starting angle of the path.

            angleB : float
              Ending angle of the path.

            armA : float or None
              Length of the starting arm.

            armB : float or None
              Length of the ending arm.

            rad : float
              Rounding radius of the edges.
            N)r  r  armAarmBr  )rE   r  r  r  r  r  rI   rI   rJ   r,     s
   
zConnectionStyle.Arc.__init__c                 C   sr  |\}}|\}}||fg}g }t jg}	| jrOtt| j}
tt| j}| j| j }|	|||
  |||  f | j}|	|||
  |||  f | j
rtt| j}tt| j}|| j
|  || j
|  }}|r|d \}}|| || }}|| ||  d }|	|| j| |  || j| |  f || |	t jt jt jg n|d \}}|| || }}|| ||  d }|| j }||| |  ||| |  f||fg}|r'|d \}}|| || }}|| ||  d }|	|| j| |  || j| |  f || |	t jt jt jg |	||f |		t j t ||	S )Nrr  r   )r   rh   r  r  r/  r  r  r0  r  r}  r  r  r  r~  r  )rE   r  r  r  r  r  r  re   roundedrd   r  r  dr  r  x_armBy_armBxpypr  r  ddrI   rI   rJ   r    sd   




zConnectionStyle.Arc.connect)r   r   NNr  r  rI   rI   rI   rJ   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)r  r  fractionr  )rE   r  r  r  r  rI   rI   rJ   r,     s   
zConnectionStyle.Bar.__init__c                 C   s  |\}}| \}}\}}t || || }	|| || }
}|
|
 ||  d }|
| || }}| j| j}}| jd urt| 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   )r  atan2r  r  r  rf   r.  r0  r/  rm  r  r   rh   r~  )rE   r  r  r  r  x20y20r  r  r  r  r  r  ddxddyr  r  theta0dthetadldLdd2armr  cx1cy1cx2cy2re   rd   rI   rI   rJ   r  )  s@   
&

zConnectionStyle.Bar.connect)r  r  r  Nr  rI   rI   rI   rJ   Bar
  s    
r  N)r   r   r   r   rQ  r  r  r  r  r  r	  r  rI   rI   rI   rJ   r  
  s    $;%'?_r  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   rI   )
r  r  r  r  r  r  r  ffr  r  rI   rI   rJ   _point_along_a_lineS  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
ArrowStyleaF  
    `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`.

    An 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

    For an overview of the visual appearance, see
    :doc:`/gallery/text_labels_and_annotations/fancyarrow_demo`.

    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.

    Notes
    -----
    *angleA* and *angleB* specify the orientation of the bracket, as either a
    clockwise or counterclockwise angle depending on the arrow type. 0 degrees
    means perpendicular to the line connecting the arrow's head and tail.

    .. plot:: gallery/text_labels_and_annotations/angles_on_bracket_arrows.py
    c                   @   s0   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r"tdg |d d |d d S )uR  
            Some ArrowStyle classes only works with a simple quadratic
            Bézier curve (created with `.ConnectionStyle.Arc3` or
            `.ConnectionStyle.Angle3`). This static method checks if the
            provided path is a simple quadratic Bézier curve and returns its
            control points if true.
            r'  r   r   z,'path' is not a valid quadratic Bezier curve)listiter_segmentsrC   r   rh   r  r   )rO   segmentsrI   rI   rJ   ensure_quadratic_bezier  s   	z(ArrowStyle._Base.ensure_quadratic_bezierc                 C   r   )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 the same length.
            r   r   )rE   rO   r  r$   rI   rI   rJ   	transmute  s   zArrowStyle._Base.transmuter  c           
         sn    dur0|j d g }t||j}| |||\}}t|r, fdd|D }	|	|fS ||fS | |||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   re   rd   )r^   r  aspect_ratiorI   rJ   r    s    z-ArrowStyle._Base.__call__.<locals>.<listcomp>)re   r   rd   r  rf   iterable)
rE   rO   r  r$   r  re   path_shrunkpath_mutatedfillable	path_listrI   r  rJ   r    s   

zArrowStyle._Base.__call__N)r  )r   r   r   r   staticmethodr
  r  r  rI   rI   rI   rJ   r    s    
r  c                       sL   e Zd Zd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 start
        point and at the end point. The arrow heads can be either open
        or closed.
        -F皙?皙?r  r   Nc                    s  ||| _ | _||| _| _||| _| _||| _| _|	|
| _| _	d| _
d| _d| _d| _d| jvr8td| jdd\}}|dkrLd| _
d| _n|dkrZd| _
d| _d| _n
|dv rdd| _
d| _|d	krod| _d| _n|d
kr}d| _d| _d| _n
|dv rd| _d| _t   dS )a  
            Parameters
            ----------
            head_length : float, default: 0.4
                Length of the arrow head, relative to *mutation_size*.
            head_width : float, default: 0.2
                Width of the arrow head, relative to *mutation_size*.
            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
                Orientation of the bracket, as a counterclockwise angle.
                0 degrees means perpendicular to the line.
            scaleA, scaleB : float, default: *mutation_size*
                The scale of the brackets.
            Fr  z-arrow must have the '-' between the two headsr   <Tz<|)rL  rK  >z|>)[rK  N)r  r  widthAwidthBlengthAlengthBr  r  scaleAscaleB_beginarrow_head_beginarrow_bracket_endarrow_head_endarrow_bracketarrowr   rj   	fillbeginfillendr+   r,   )rE   r  r  r  r  r  r  r  r  r  r  
beginarrowendarrowrG   rI   rJ   r,     sB   
zArrowStyle._Curve.__init__c	                 C   s  || || }	}
t |	|
}d| | }|dkrd}||	 | }||
 | }|	| | }	|
| | }
||	 ||
  | |	 ||
  }}||	 ||
  ||	 ||
  }}|| | || | 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   )rf   r  r   rh   r~  )rE   r  r  r  r  	head_distcos_tsin_tr$   r  r  cp_distancepad_projectedr  r  r  r  r  r  vertices_arrowcodes_arrowrI   rI   rJ   _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}|rTt |||}|	|}||fS )Nr   )get_normal_points)
r   matplotlib.bezierr1  r   rh   r~  r   r   rotate_deg_aroundr   )rE   r  r  r  r  r  r  r  r*  r+  r1  r  r  r  r  r.  r/  rN   rI   rI   rJ   _get_bracketL  s$   
zArrowStyle._Curve._get_bracketc              
   C   s  | j s| jr| j| }| j| }t||}|| || }}| jd u r&|n| j}	| jd u r0|n| j}
|jd \}}|jd \}}| j oK||f||fk}|rZ| 	||||||||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r|t
g |dg |t
j |d nA|t
|| |d n3| jr|jd \}}|jd \}}| ||||| j|	 | j|	 | j\}}|t
|| |d |rG| jr6|d |t
g |dg |t
j ||fS |d |t
|| ||fS | jrz|jd \}}|jd \}}| ||||| j|
 | j|
 | j\}}|t
|| |d ||fS )Nr   r   r  rr  Fr0  T)r   r"  r  r  rf   r  r  r  re   r0  r   rz  rd   r%  r}  r  r!  r4  r  r  r  r&  r#  r  r  r  )rE   rO   r  r$   r  r  r)  r*  r+  r  r  r  r  r  r  has_begin_arrow	verticesAcodesAddxAddyAr  r  x3y3has_end_arrow	verticesBcodesBddxBddyBpathsfillsrI   rI   rJ   r  f  s   





	



zArrowStyle._Curve.transmute)
r  r  r  r  r  r  r   r   NN)r   r   r   r   r$  r%  r&  r,   r0  r4  r  r   rI   rI   rG   rJ   _Curve  s    >*rC  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   rG   rI   rJ   r,     s   zArrowStyle.Curve.__init__)r   r   r   r   r,   r   rI   rI   rG   rJ   Curve  s    rD  <-c                   @      e Zd ZdZdZdS )zArrowStyle.CurveAz(An arrow with a head at its start point.rE  Nr   r   r   r   r$  rI   rI   rI   rJ   CurveA      rH  ->c                   @   rF  )zArrowStyle.CurveBz&An arrow with a head at its end point.rJ  NrG  rI   rI   rI   rJ   CurveB  rI  rK  <->c                   @   rF  )zArrowStyle.CurveABz8An arrow with heads both at the start and the end point.rL  NrG  rI   rI   rI   rJ   CurveAB  rI  rM  <|-c                   @   rF  )zArrowStyle.CurveFilledAz0An arrow with filled triangle head at the start.rN  NrG  rI   rI   rI   rJ   CurveFilledA  rI  rO  -|>c                   @   rF  )zArrowStyle.CurveFilledBz.An arrow with filled triangle head at the end.rP  NrG  rI   rI   rI   rJ   CurveFilledB  rI  rQ  <|-|>c                   @   rF  )zArrowStyle.CurveFilledABz1An arrow with filled triangle heads at both ends.rR  NrG  rI   rI   rI   rJ   CurveFilledAB  rI  rS  ]-c                       &   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.rT  r  r  r   c                       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  r  Nr  rE   r  r  r  rG   rI   rJ   r,        zArrowStyle.BracketA.__init__r  r  r   r   r   r   r   r$  r,   r   rI   rI   rG   rJ   BracketA      r\  -[c                       rU  )	zArrowStyle.BracketBz3An arrow with an outward square bracket at its end.r^  r  r  r   c                    rV  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  r  Nr  rE   r  r  r  rG   rI   rJ   r,     rY  zArrowStyle.BracketB.__init__rZ  r[  rI   rI   rG   rJ   BracketB  r]  ra  ]-[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.rb  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  r  r  r  r  Nr  )rE   r  r  r  r  r  r  rG   rI   rJ   r,     s   
zArrowStyle.BracketAB.__init__)r  r  r   r  r  r   r[  rI   rI   rG   rJ   	BracketAB  s    rd  |-|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.re  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   rc  Nr  )rE   r  r  r  r  rG   rI   rJ   r,   #  s   

zArrowStyle.BarAB.__init__)r  r   r  r   r[  rI   rI   rG   rJ   BarAB  r]  rf  ]->c                       rU  )	zArrowStyle.BracketCurveze
        An arrow with an outward square bracket at its start and a head at
        the end.
        rg  r  r  Nc                    rV  rW  r  rX  rG   rI   rJ   r,   8  rY  z ArrowStyle.BracketCurve.__init__r  r  Nr[  rI   rI   rG   rJ   BracketCurve0      ri  <-[c                       rU  )	zArrowStyle.CurveBracketze
        An arrow with an outward square bracket at its end and a head at
        the start.
        rk  r  r  Nc                    rV  r_  r  r`  rG   rI   rJ   r,   N  rY  z ArrowStyle.CurveBracket.__init__rh  r[  rI   rI   rG   rJ   CurveBracketF  rj  rl  c                       *   e Zd ZdZd fdd	Zdd Z  ZS )	zArrowStyle.Simpleu:   A simple arrow. Only works with a quadratic Bézier curve.r   r  c                    $   |||| _ | _| _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,   rE   r  r  rp  rG   rI   rJ   r,   `     zArrowStyle.Simple.__init__c                 C   s  |  |\}}}}}}	| j| }
t||	|
}||f||f||	fg}z	t||\}}W n- tyW   t||	|||
\}}d||  d||	  }}||f||f||	fg}d }Y nw | 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}n&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  wmr   r   r'  c                 S      g | ]\}}|qS rI   rI   r^   r   r  rI   rI   rJ   r    r  z/ArrowStyle.Simple.transmute.<locals>.<listcomp>c                 S      g | ]\}}|qS rI   rI   rv  rI   rI   rJ   r    r  T)r
  r  r   r   r   r  r  r   rp  r   r   rh   r  r~  r  )rE   rO   r  r$   r  r  r  r  r  r  r  in_f
arrow_path	arrow_outarrow_inx1ny1nr  	head_left
head_rightrp  	tail_left
tail_right
patch_pathrI   rI   rJ   r  q  sZ   


	

zArrowStyle.Simple.transmute)r   r   r  r   r   r   r   r,   r  r   rI   rI   rG   rJ   Simple\      r  c                       s*   e Zd ZdZd fdd	Zdd Z  ZS )zArrowStyle.Fancyu9   A fancy arrow. Only works with a quadratic Bézier curve.r  c                    rn  )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.
            Nro  rq  rG   rI   rJ   r,     rr  zArrowStyle.Fancy.__init__c                 C   s  |  |\}}}}}}	| j| }
||f||f||	fg}t||	|
}z	t||\}}W n- tyW   t||	|||
\}}d||  d||	  }}||f||f||	fg}|}Y nw |}t||	|
d }t||\}}|}| j| }t||d dd\}}| j| }t||d dddd\}}t|||d }t||\}}|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  g333333?rs  r  r  )w1rt  w2rr  r   r   r'  c                 S   ru  rI   rI   rv  rI   rI   rJ   r    r  z.ArrowStyle.Fancy.transmute.<locals>.<listcomp>c                 S   rw  rI   rI   rv  rI   rI   rJ   r    r  T)r
  r  r   r   r   r  r  r   rp  r   rh   r~  r  r  )rE   rO   r  r$   r  r  r  r  r  r  r  ry  rx  path_outpath_inr|  r}  	path_head	path_tailr  head_lhead_rrp  r  r  
tail_startr  r~  r  rI   rI   rJ   r    sj   





zArrowStyle.Fancy.transmute)r  r  r  r  rI   rI   rG   rJ   Fancy  r  r  c                       rm  )	zArrowStyle.Wedgeu   
        Wedge(?) shape. Only works with a quadratic Bézier curve.  The
        start 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*x*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)rp  shrink_factorr+   r,   )rE   rp  r  rG   rI   rJ   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  rs  r   r   r'  c                 S   ru  rI   rI   rv  rI   rI   rJ   r  +  r  z.ArrowStyle.Wedge.transmute.<locals>.<listcomp>c                 S   rw  rI   rI   rv  rI   rI   rJ   r  +  r  T)	r
  r   rp  r  r   rh   r  r~  r  )rE   rO   r  r$   r  r  r  r  r  r  ry  b_plusb_minusr  rI   rI   rJ   r    s"   
zArrowStyle.Wedge.transmute)r  r   r  rI   rI   rG   rJ   r    s    r  N)r   r   r   r   rQ  r  rC  r  rD  rH  rK  rM  rO  rQ  rS  r\  ra  rd  rf  ri  rl  r  r  r  rI   rI   rI   rJ   r  _  sL    .G 
d











NWr  c                       s   e Zd ZdZdZdd Zejd-ddd fdd	Zejd.ddZ	dd Z
dd Zdd Zdd Zdd Zdd Zdd Z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  ZS )/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))rH   r   r  r  r  r  r[  rI   rI   rJ   r   <  s   zFancyBboxPatch.__str__r  r   )mutation_scalemutation_aspectc                   sJ   t  jdi | |\| _| _|| _|| _| | || _|| _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 : `~matplotlib.patches.Patch` properties

        %(Patch:kwdoc)s
        TNrI   )
r+   r,   r  r  r  r  set_boxstyle_mutation_scale_mutation_aspectr   )rE   r   r  r  boxstyler  r  rF   rG   rI   rJ   r,   @  s   +

zFancyBboxPatch.__init__Nc                 K   :   |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  rN  rS   rg  _bbox_transmuterr   )rE   r  rF   rI   rI   rJ   r  t     !
zFancyBboxPatch.set_boxstylec                 C   r   )zReturn the boxstyle object.)r  r   rI   rI   rJ   get_boxstyle  r   zFancyBboxPatch.get_boxstylec                 C   r?  zf
        Set the mutation scale.

        Parameters
        ----------
        scale : float
        TNr  r   rE   r"  rI   rI   rJ   set_mutation_scale  r  z!FancyBboxPatch.set_mutation_scalec                 C   r   )zReturn the mutation scale.r  r   rI   rI   rJ   get_mutation_scale  r   z!FancyBboxPatch.get_mutation_scalec                 C   r?  zz
        Set the aspect ratio of the bbox mutation.

        Parameters
        ----------
        aspect : float
        TNr  r   rE   aspectrI   rI   rJ   set_mutation_aspect  r  z"FancyBboxPatch.set_mutation_aspectc                 C      | j dur| j S dS z-Return the aspect ratio of the bbox mutation.Nr   r  r   rI   rI   rJ   get_mutation_aspect     z"FancyBboxPatch.get_mutation_aspectc                 C   sJ   |   }|  }|| j| j| | j| j| |  }t|jd|g |j	S )z)Return the mutated path of the rectangle.r   )
r  r  r  r  r  r  r  r   re   rd   )rE   r  m_aspectrO   rI   rI   rJ   rL     s   zFancyBboxPatch.get_pathc                 C   r   )z'Return the left coord of the rectangle.)r  r   rI   rI   rJ   r*    r   zFancyBboxPatch.get_xc                 C   r   )z)Return the bottom coord of the rectangle.)r  r   rI   rI   rJ   r+    r   zFancyBboxPatch.get_yc                 C   r   r7  r8  r   rI   rI   rJ   r9    r   zFancyBboxPatch.get_widthc                 C   r   r:  r;  r   rI   rI   rJ   r<    r   zFancyBboxPatch.get_heightc                 C   r?  )zo
        Set the left coord of the rectangle.

        Parameters
        ----------
        x : float
        TN)r  r   r@  rI   rI   rJ   rA    r  zFancyBboxPatch.set_xc                 C   r?  )zq
        Set the bottom coord of the rectangle.

        Parameters
        ----------
        y : float
        TN)r  r   rC  rI   rI   rJ   rD    r  zFancyBboxPatch.set_yc                 C   r?  )zc
        Set the rectangle width.

        Parameters
        ----------
        w : float
        TNrI  r   rI   rI   rJ   rJ    r  zFancyBboxPatch.set_widthc                 C   r?  )zd
        Set the rectangle height.

        Parameters
        ----------
        h : float
        TNrK  rL  rI   rI   rJ   rN    r  zFancyBboxPatch.set_heightc                 G   rO  )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)rC   r  r  r  r  r   rP  rI   rI   rJ   rS    s   
zFancyBboxPatch.set_boundsc                 C   s   t j| j| j| j| jS rT  )r   rU  from_boundsr  r  r  r  r   rI   rI   rJ   r   !  s   zFancyBboxPatch.get_bbox)r  rZ   )r   r   r   r   r   r   r   r   r,   r  r  r  r  r  r  rL   r*  r+  r9  r<  rA  rD  rJ  rN  rS  r   r   rI   rI   rG   rJ   r  0  s4    	3'r  c                       s   e Zd ZdZdZdd Zejd)dddddd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ejd*ddZdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Z  ZS )+FancyArrowPatcha  
    A fancy arrow patch.

    It draws an arrow using the `ArrowStyle`. It is primarily used by the
    `~.axes.Axes.annotate` method.  For most purposes, use the annotate method for
    drawing arrows.

    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   sd   | j d ur&| j \\}}\}}t| j d|dd|dd|dd|dd
S t| j d| j dS )Nz((gz, z)->(z))(r   )
_posA_posBtyper   _path_original)rE   r  r  r  r  rI   rI   rJ   r   5  s   
0zFancyArrowPatch.__str__Nsimplearc3r'  r   )	rO   
arrowstyleconnectionstyler  r  r  r  r  r  c       	            s   | dtj | dtj t jdi | |dur4|dur4|du r4||g| _|du r.d}| | n|du rD|du rD|durDd| _ntd|| _	|| _
|| _|	| _|| _| | |
| _|| _d| _dS )a
  
        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 : `~matplotlib.patches.Patch`, default: None
            Head and tail patches, respectively.

        shrinkA, shrinkB : float, default: 2
            Shrink amount, in points, 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 : `~matplotlib.patches.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"``.
        r)   r(   Nr  z.Either posA and posB, or path need to providedr  rI   )r
  r   r  r   r+   r,   r  set_connectionstyler   r  r  r  r  r  set_arrowstyler  r  _dpi_cor)rE   r  r  rO   r  r  r  r  r  r  r  r  rF   rG   rI   rJ   r,   <  s(   F


zFancyArrowPatch.__init__c                 C   s.   |dur	|| j d< |dur|| j d< d| _dS )a  
        Set the start 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   )rE   r  r  rI   rI   rJ   set_positions  s
   



zFancyArrowPatch.set_positionsc                 C   r?  )zn
        Set the tail patch.

        Parameters
        ----------
        patchA : `.patches.Patch`
        TN)r  r   )rE   r  rI   rI   rJ   
set_patchA  r  zFancyArrowPatch.set_patchAc                 C   r?  )zn
        Set the head patch.

        Parameters
        ----------
        patchB : `.patches.Patch`
        TN)r  r   )rE   r  rI   rI   rJ   
set_patchB  r  zFancyArrowPatch.set_patchBc                 K   r  )aZ  
        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)r  rN  rS   rg  
_connectorr   )rE   r  rF   rI   rI   rJ   r    r  z#FancyArrowPatch.set_connectionstylec                 C   r   )z"Return the `ConnectionStyle` used.)r  r   rI   rI   rJ   get_connectionstyle  r   z#FancyArrowPatch.get_connectionstylec                 K   r  )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  rN  rS   rg  _arrow_transmuterr   )rE   r  rF   rI   rI   rJ   r    r  zFancyArrowPatch.set_arrowstylec                 C   r   )zReturn the arrowstyle object.)r  r   rI   rI   rJ   get_arrowstyle  r   zFancyArrowPatch.get_arrowstylec                 C   r?  r  r  r  rI   rI   rJ   r    r  z"FancyArrowPatch.set_mutation_scalec                 C   r   )z\
        Return the mutation scale.

        Returns
        -------
        scalar
        r  r   rI   rI   rJ   r  *  s   z"FancyArrowPatch.get_mutation_scalec                 C   r?  r  r  r  rI   rI   rJ   r  4  r  z#FancyArrowPatch.set_mutation_aspectc                 C   r  r  r  r   rI   rI   rJ   r  ?  r  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_displaycoordrf   r  r   make_compound_pathrK   invertedr  )rE   r_  r  rI   rI   rJ   rL   D  s   

zFancyArrowPatch.get_pathc                 C   s   | j }| jdur8| | 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   r  r  r  r  )r  r  r   rK   r   r  r  r  r  r  r  r  r  r  rV   r  )rE   dpi_corr  r  r_  r  rI   rI   rJ   r  M  s&   



z)FancyArrowPatch._get_path_in_displaycoordc                    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 )rR   Nr   )r^   r  r  r   rE   rI   rJ   r  x  s    "z(FancyArrowPatch.draw.<locals>.<listcomp>)
r   r  r  r  rf   r  r   r   r   r+  )rE   r   rO   r  rI   r  rJ   r   f  s   
zFancyArrowPatch.draw)NNrZ   )r   r   r   r   r   r   r   r   r,   r  r  r  r  r  r  r  r  r  r  r  rL   r  r   r   rI   rI   rG   rJ   r  '  s4    d''
	r  c                       s   e Zd ZdZdd Zejddddddddd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   rI   rI   rJ   r     s   "zConnectionPatch.__str__Nr  r  r  g      $@F)axesAaxesBr  r  r  r  r  r  r  r  rC  c                   sd   |du r|}|| _ || _|| _|| _|| _|| _t jddd|||	|
|||||d| d| _dS )aN  
        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 the Axes
        'axes pixels'        pixels from lower left corner of the 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 :ref:`constrained layout
           <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)

        Nr0  r2  )r  r  r  r  r  r  r  r  r  r  rC  rI   )	r  r  coords1coords2r  r  r+   r,   _annotation_clip)rE   xyAxyBcoordsAcoordsBr  r  r  r  r  r  r  r  r  r  rC  rF   rG   rI   rJ   r,     s(   Q

zConnectionPatch.__init__c                 C   s  |}|du r	| j }t|d }t|d }| jdd}|dv r6||j d }||j d }|dd	}n|d
kr>|j}n|dkrF|j}n|dkrM|j}|dkrm|j	}t
|j|}t
|j|}|||fS |dkr| jdkr}| | jdS | | j| j|| jddj d  S |dkr||}	}
|
t|	 }|
t|	 }|j	}|||fS |dkr| jddj}|dkr|j| n|j| }|dkr|j| n|j| }||fS |dkr| jddj}|dkr|j| n|j| }|dkr|j| n|j| }||fS |dkr2|j}|dkr|j| n|j| }|dkr)|j| n|j| }||fS t|tjr>||S t| d)z,Calculate the pixel position of given point.Nr   r   Fr$  )zfigure pointszaxes pointsH   rs   pixelszfigure fractionzsubfigure fractionzaxes fractiondatazoffset pointsTpolarzfigure pixelszsubfigure pixelszaxes pixelsz) is not a valid coordinate transformation)r'  rf   r  r(  dpirX  transFiguretransSubfigure	transAxes	transDatar
   _to_unmasked_float_arrayxaxisconvert_unitsyaxisr   xycoords_get_xyr   r/  r0  figbboxr  r  r  r  r$  rS   r   	Transformr   )rE   r   r   r'  s0r\   r]   figrN   r:  r  bbrI   rI   rJ   r    sh   




zConnectionPatch._get_xyc                 C   r?  )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   rI   rI   rJ   set_annotation_clip)  s   
z#ConnectionPatch.set_annotation_clipc                 C   r   )zx
        Return the clipping behavior.

        See `.set_annotation_clip` for the meaning of the return value.
        )r  r   rI   rI   rJ   get_annotation_clip9  s   z#ConnectionPatch.get_annotation_clipc                 C   s   | j }| | j| j| j}| | j| j| j}|  ||| j	| j
| j| | j| d}|  ||  | |  | |  \}}||fS )r  r  )r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rV   r  )rE   r  r  r  rO   r  rI   rI   rJ   r  A  s   

z)ConnectionPatch._get_path_in_displaycoordc                 C   s   |   }|s|du r,| jdkr,| | j| j| j}| jdu r"| j}n| j}||s,dS |s7|du rT| jdkrT| | j| j| j	}| j	du rJ| j}n| j	}||sTdS dS )z/Check whether the annotation needs to be drawn.Nr  FT)
r  r  r  r  r  r'  r[   r  r  r  )rE   r   r   xy_pixelr'  rI   rI   rJ   	_check_xyS  s    



zConnectionPatch._check_xyc                    s&   |   r	| |sd S t | d S rZ   )r   r  r+   r   r   rG   rI   rJ   r   l  s   zConnectionPatch.drawrZ   )r   r   r   r   r   r   r   r,   r  r  r  r  r  r   r   rI   rI   rG   rJ   r  |  s,    
g>r  r  )rH  NrZ   )Mr   r  rh  r  numbersr   r   r{  typesr   collectionsr   matplotlib.transformsr   numpyrf   
matplotlibr0   r   r   r	   r
   r   r   r   r   r   r   r   bezierr   r   r   r   r   r   r   r   rO   r   _enumsr   r   r   define_aliasesr   r%   r   r  rX  re  rg  r  r  r  r  rM  rO  getdocr,   
splitlinesr  r  r  r  r	  rG  rI  rJ  r  r  r  r  r  r  r  r  rI   rI   rI   rJ   <module>   s    ((    y< Z1mcWS * 5 <* 
w
V  n        U x  W