
    \cgT                         d dl mZ d dlZd dlZd dlZd dlmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ  G d dej(                        Z G d d      Z G d	 d
e      Zy)    )MutableMappingN)_api
_docstring)allow_rasterizationc                       e Zd ZdZd Zej                   fd       Zd Zd Z	d Z
d Z fdZd fd		Zd
 Zd Zd Zd Zd Zd Ze fd       Zd Zd Zd ZddZd Zed        Zed        Zed        Zd Z xZ S )Spineay  
    An axis spine -- the line noting the data area boundaries.

    Spines are the lines connecting the axis tick marks and noting the
    boundaries of the data area. They can be placed at arbitrary
    positions. See `~.Spine.set_position` for more information.

    The default position is ``('outward', 0)``.

    Spines are subclasses of `.Patch`, and inherit much of their behavior.

    Spines draw a line, a circle, or an arc depending on if
    `~.Spine.set_patch_line`, `~.Spine.set_patch_circle`, or
    `~.Spine.set_patch_arc` has been called. Line-like is the default.

    For examples see :ref:`spines_examples`.
    c                      y)Nr    selfs    L/var/www/html/bid-api/venv/lib/python3.12/site-packages/matplotlib/spines.py__str__zSpine.__str__    s        c                    t        |   di | || _        | j                  | j                  j	                  d             || _        | j                  d       | j                  t        j                  d          | j                  t        j                  d          | j                  d       d| _        | j                  d       | j                  | j                  j                         d| _        d| _        t%        j&                  t(        j*                  |	       || _        d
| _        t1        j2                         | _        y)a  
        Parameters
        ----------
        axes : `~matplotlib.axes.Axes`
            The `~.axes.Axes` instance containing the spine.
        spine_type : str
            The spine type.
        path : `~matplotlib.path.Path`
            The `.Path` instance used to draw the spine.

        Other Parameters
        ----------------
        **kwargs
            Valid keyword arguments are:

            %(Patch:kwdoc)s
        Frootnonezaxes.edgecolorzaxes.linewidth
projectingNg      @)pathliner
   )super__init__axes
set_figure
get_figure
spine_typeset_facecolorset_edgecolormplrcParamsset_linewidthset_capstyleaxis
set_zorderset_transform	transData_bounds	_positionr   check_isinstancempathPath_path_patch_typemtransformsIdentityTransform_patch_transform)r   r   r   r   kwargs	__class__s        r   r   zSpine.__init__#   s    & 	"6"			,,%,89$6"3<<(89:3<<(89:,'	499../
 ejjt4
 " !, = = ?r   c                    d| _         || _        |dz  | _        |dz  | _        || _        || _        t        j                  j                  ||      | _	        | j                  | j                  j                         d| _        y)zSet the spine to be arc-like.arc   TN)r-   _center_width_height_theta1_theta2r*   r+   r4   r,   r%   r   	transAxesstale)r   centerradiustheta1theta2s        r   set_patch_arczSpine.set_patch_arcX   sj     qjzZZ^^FF3
499../
r   c                     d| _         || _        |dz  | _        |dz  | _        | j	                  | j
                  j                         d| _        y)zSet the spine to be circular.circler5   TN)r-   r6   r7   r8   r%   r   r;   r<   )r   r=   r>   s      r   set_patch_circlezSpine.set_patch_circlee   sF    #qjz499../
r   c                      d| _         d| _        y)zSet the spine to be linear.r   TN)r-   r<   r   s    r   set_patch_linezSpine.set_patch_lineo   s    !
r   c                    | j                   dv sJ | j                  | j                  d         | j                  | j                  d         f}| j                  | j                        }| j                  | j
                        } t        j                         j                  |dz  |dz        j                  | | _
        y)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.
        r4   rC   r            ?N)r-   convert_xunitsr6   convert_yunitsr7   r8   r.   Affine2Dscale	translater0   )r   r=   widthheights       r   _recompute_transformzSpine._recompute_transformu   s     #4444%%dll1o6%%dll1o68##DKK0$$T\\2! 4 4 6U53;-Y! r   c                 t    | j                   dv r| j                          | j                  S t        |          S )NrH   )r-   rR   r0   r   get_patch_transform)r   r2   s    r   rT   zSpine.get_patch_transform   s8    00%%'(((7.00r   c                    | j                          t        | 	  |      }| j                  | j                  j	                         s|S |g}| j                  j                         }t        t        h |h | j                  j                  z        d      }t        t        h |h | j                  j                  z        d      }||fD ]  }||j                         }|j                  }	|j                  }
|
dk(  rd}d}n|
dk(  rd}d}nd}d}| j                  d	      j                  }||	z  d
z  |z  }||	z  d
z  |z  }|j                  j	                         ro| j                   dk(  r)|j"                  |z
  |_        |j$                  |z   |_        n7| j                   dk(  r(|j&                  |z
  |_        |j(                  |z   |_        |j*                  j	                         ro| j                   dk(  r)|j$                  |z   |_        |j"                  |z
  |_        n7| j                   dk(  r(|j(                  |z   |_        |j&                  |z
  |_        |j-                  |        t.        j0                  j3                  |      S )a  
        Return the window extent of the spines in display space, including
        padding for ticks (but not their labels)

        See Also
        --------
        matplotlib.axes.Axes.get_tightbbox
        matplotlib.axes.Axes.get_window_extent
        )rendererNoutrI   r   inrJ   Tr   H   leftbottomrighttop)_adjust_locationr   get_window_extentr#   get_visible_update_ticksnextiter
majorTicks
minorTicksfrozen_size_tickdirr   dpi	tick1liner   x0x1y0y1	tick2lineappendr.   Bboxunion)r   rV   bbbboxesdrawn_ticks
major_tick
minor_ticktickbb0tickltickdirpadoutpadinri   r2   s                 r   r_   zSpine.get_window_extent   s:    	W&&999DII$9$9$;Iii--/$~~0G$))2F2F0GGH$O
$~~0G$))2F2F0GGH$O
,D|))+CJJEmmG%D//t/,00Ce^b(3.FEMB&,E~~))+??f, VVf_CF VVe^CF__0 VVf_CF VVe^CF~~))+??g- VVf_CF VVe^CF__- VVf_CF VVf_CFMM#E -H %%f--r   c                     | j                   S N)r,   r   s    r   get_pathzSpine.get_path       zzr   c                 b    | j                   #d| _         | j                  | j                          y y )N)outward        )r(   set_positionr   s    r   _ensure_position_is_setzSpine._ensure_position_is_set   s*    >>!-DNdnn- "r   c                      || _         d| _        y)z
        Register an axis.

        An axis should be registered with its corresponding spine from
        the Axes instance. This allows the spine to clear any axis
        properties when needed.
        TN)r#   r<   )r   r#   s     r   register_axiszSpine.register_axis   s     	
r   c                 r    | j                          | j                  | j                  j                          yy)zClear the current spine.N)_clearr#   clearr   s    r   r   zSpine.clear   s(    99 IIOO !r   c                     d| _         y)z
        Clear things directly related to the spine.

        In this way it is possible to avoid clearing the Axis as well when calling
        from library code where it is known that the Axis is cleared separately.
        N)r(   r   s    r   r   zSpine._clear   s     r   c                    | j                   dk(  ry| j                  | j                  \  }}n|| j                   dv r$| j                  j                  j                  \  }}nJ| j                   dv r$| j                  j                  j
                  \  }}nt        d| j                          | j                  dk(  r)| j                   dv r	 | j                  j                         }	 | j                  j                         }||z  |z   }||z  |z   }||kD  r||}}t        j                  j                  t        j                  |      t        j                  |            | _        | j                   d
k(  rp| j                  j                  j                  \  }}	 | j                  j#                         }||z
  ||z
  z  }|| _        || _        yt        d| j                   z        y| j                   j(                  }	|	j*                  dk(  sJ d       | j                   dv r||	d<   ||	d<   y| j                   dv r||	d<   ||	d<   yt        d| j                   z        # t        $ r d}Y w xY w# t        $ r d	}Y zw xY w# t        $ r |}Y w xY w)z4Automatically set spine bounds to the view interval.rC   NrZ   r\   r]   r[   unknown spine spine_type: r4   r[   r]   rI   r   r[   z#unable to set bounds for spine "%s")r5   r5   zunexpected vertices shaper   rI   )rI   rI   )r   r   rI   r   )r   r'   r   viewLim	intervaly	intervalx
ValueErrorr-   get_theta_directionAttributeErrorget_theta_offsetr*   r+   r4   nprad2degr,   get_roriginr8   r7   verticesshape)
r   lowhigh	directionoffsetrminrmaxroriginscaled_diameterv1s
             r   r^   zSpine._adjust_location   sr    ??h&<<#IC__ 11		))33IC__ 11		))33IC9$//9JKLLu$"33" $		 = = ?I!YY779F Io.i'&0: $cC"ZZ^^BJJsORZZ=MN
??h.!%!2!2!<!<JD$'"&))"7"7"9 (,g~$.&IO#2DL"1DK !!F!%"1 2 2 / $$B88v%B'BB%"3344$5544 !F!%"1 2 2I & " !I" & F * '"&'s6   	I $I* I< I'&I'*I98I9<J
	J
c                 T    | j                          t        | 	  |      }d| _        |S )NF)r^   r   drawr<   )r   rV   retr2   s      r   r   z
Spine.draw%  s)    gl8$

r   c                 
   |dv rn+t        |      dk7  rt        d      |d   dvrt        d      || _        | j                  | j	                                | j
                  | j
                  j                          d| _        y)	a  
        Set the position of the spine.

        Spine position is specified by a 2 tuple of (position type,
        amount). The position types are:

        * 'outward': place the spine out from the data area by the specified
          number of points. (Negative values place the spine inwards.)
        * 'axes': place the spine at the specified Axes coordinate (0 to 1).
        * 'data': place the spine at the specified data coordinate.

        Additionally, shorthand notations define a special positions:

        * 'center' -> ``('axes', 0.5)``
        * 'zero' -> ``('data', 0.0)``

        Examples
        --------
        :doc:`/gallery/spines/spine_placement_demo`
        )r=   zeror5   z&position should be 'center' or 2-tupler   )r   r   dataz:position[0] should be one of 'outward', 'axes', or 'data' NT)lenr   r(   r%   get_spine_transformr#   reset_ticksr<   )r   positions     r   r   zSpine.set_position,  s    * ))8}! !IJJ{"==  "6 7 7!4335699 II!!#
r   c                 :    | j                          | j                  S )zReturn the spine position.)r   r(   r   s    r   get_positionzSpine.get_positionO  s    $$&~~r   c                 p   | j                          | j                  }t        |t              r|dk(  rd}n|dk(  rd}t	        |      dk(  sJ d       |\  }}t        j                  g d|       | j                  d	v r| j                  j                  d
      }nC| j                  dv r| j                  j                  d
      }nt        d| j                        |dk(  rj|dk(  r|S ddddd| j                     }|t        j                  |      z  dz  }|t        j                  g || j!                  d      j"                   z   S |dk(  rk| j                  d	v r't        j$                  j'                  dddd|d      |z   S | j                  dv r't        j$                  j'                  ddddd|      |z   S y|dk(  r| j                  dv r|dz  }| j                  d	v rct        j(                  t        j$                         j+                  |d      | j                  j,                  z   | j                  j,                        S | j                  dv rct        j(                  | j                  j,                  t        j$                         j+                  d|      | j                  j,                  z         S yy)zReturn the spine transform.r=   )r   rJ   r   )r   r   r5   zposition should be 2-tuple)r   r   r   )position_typer   grid)whichr   r   r   r   )r   r   )r   r   r   )rZ   r\   r[   r]   rY   Fr   r   rI   r   r   )r\   r]   N)r   r(   
isinstancestrr   r   check_in_listr   r   get_yaxis_transformget_xaxis_transformr   r   arrayr.   ScaledTranslationr   dpi_scale_transrM   from_valuesblended_transform_factoryrO   r&   )r   r   r   amountbase_transform
offset_vecoffset_dotss          r   r   zSpine.get_spine_transformT  s   $$&>>h$8#(V#&8}!?#??! (v6)6	8??//!YY:::HN__ 11!YY:::HN9$//9LMNNI%{%%&-(/  $1
 %rxx
';;b@&%77 W(W*.//u/*E*U*UWW X f$"33#,,88Aq!VQO() *$55#,,88Aq!QO() * 6 f$"22 !"33"<<((*44VQ?ii))*II'') ) $55"<<II''((*44Q?ii))*+ + 6 %r   c                     | j                   dk(  rt        d      |t        j                  |      r|\  }}| j	                         xs d\  }}||}||}||f| _        d| _        y)a  
        Set the spine bounds.

        Parameters
        ----------
        low : float or None, optional
            The lower spine bound. Passing *None* leaves the limit unchanged.

            The bounds may also be passed as the tuple (*low*, *high*) as the
            first positional argument.

            .. ACCEPTS: (low: float, high: float)

        high : float or None, optional
            The higher spine bound. Passing *None* leaves the limit unchanged.
        rC   z5set_bounds() method incompatible with circular spinesNNNT)r   r   r   iterable
get_boundsr'   r<   )r   r   r   old_lowold_highs        r   
set_boundszSpine.set_bounds  sw    " ??h&GI I<BKK,IC OO-=;C<DT{
r   c                     | j                   S )zGet the bounds of the spine.)r'   r   s    r   r   zSpine.get_bounds  s    ||r   c                 j   |dk(  rt        j                  ddg      }ne|dk(  rt        j                  ddg      }nH|dk(  rt        j                  ddg      }n+|dk(  rt        j                  ddg      }nt        d	|z         | |||fi |}|j                  t        j
                  d
|           |S )z#Create and return a linear `Spine`.rZ   )r   +?r\   )      ?r   r[   )r   r   r]   )r   r   z"unable to make path for spine "%s"zaxes.spines.)r*   r+   r   set_visibler   r    )clsr   r   r1   r   results         r   linear_spinezSpine.linear_spine  s     ::|\:;D7"::|\:;D8#::|\:;D5 ::|\:;DAJNOOT:t6v63<<,zl(CDEr   c                     t         j                  j                  ||      } | |||fi |}	|	j                  ||||       |	S )z!Create and return an arc `Spine`.)r*   r+   r4   rA   )
r   r   r   r=   r>   r?   r@   r1   r   r   s
             r   	arc_spinezSpine.arc_spine  sD     zz~~ff-T:t6v6VVVV<r   c                     t         j                  j                         }d} | |||fi |}|j                  ||       |S )z%Create and return a circular `Spine`.rC   )r*   r+   unit_circlerD   )r   r   r=   r>   r1   r   r   r   s           r   circular_spinezSpine.circular_spine  sC     zz%%'
T:t6v6/r   c                 4    | j                  |       d| _        y)aW  
        Set the edgecolor.

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

        Notes
        -----
        This method does not modify the facecolor (which defaults to "none"),
        unlike the `.Patch.set_color` method defined in the parent class.  Use
        `.Patch.set_facecolor` to set the facecolor.
        TN)r   r<   )r   cs     r   	set_colorzSpine.set_color  s     	1
r   r   r   )!__name__
__module____qualname____doc__r   r   interpdr   rA   rD   rF   rR   rT   r_   r   r   r   r   r   r^   r   r   r   r   r   r   r   classmethodr   r   r   r   __classcell__)r2   s   @r   r   r      s    " 2@ 2@h $18.t.	82t  !F
9+v<  $    r   r   c                   "    e Zd ZdZd Zd Zd Zy)SpinesProxyag  
    A proxy to broadcast ``set_*()`` and ``set()`` method calls to contained `.Spines`.

    The proxy cannot be used for any other operations on its members.

    The supported methods are determined dynamically based on the contained
    spines. If not all spines support a given method, it's executed only on
    the subset of spines that support it.
    c                     || _         y r   )_spine_dict)r   
spine_dicts     r   r   zSpinesProxy.__init__  s
    %r   c                     | j                   j                         D cg c]  }t        ||      r| }}|dk7  r|j                  d      r|st	        d| d      d }t        j                  |||      }|d   j                  |_        |S c c}w )Nsetset_z''SpinesProxy' object has no attribute ''c                 6    | D ]  } t        ||      |i |  y r   )getattr)_targets	_funcnameargsr1   spines        r   xz"SpinesProxy.__getattr__.<locals>.x  s"    !)y)4:6: "r   r   )r   valueshasattr
startswithr   	functoolspartialr   )r   namer   broadcast_targetsr   s        r   __getattr__zSpinesProxy.__getattr__  s    040@0@0G0G0I 60Iu 't 4 #0I 6EM$//&"9BS 9$qAC C	; a!2D9%a(00	6s   Bc                     g }| j                   j                         D ]#  }|j                  d t        |      D               % t	        t        t        |                  S )Nc              3   B   K   | ]  }|j                  d       r|  yw)r   N)r   ).0r   s     r   	<genexpr>z&SpinesProxy.__dir__.<locals>.<genexpr>  s$      L%/T4??63J %/s   )r   r   extenddirlistsortedr   )r   namesr   s      r   __dir__zSpinesProxy.__dir__  sV    %%,,.ELL L%(ZL L / F3u:&''r   N)r   r   r   r   r   r   r  r
   r   r   r   r     s    &(r   r   c                   V    e Zd ZdZd Zed        Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zy)Spinesa  
    The container of all `.Spine`\s in an Axes.

    The interface is dict-like mapping names (e.g. 'left') to `.Spine` objects.
    Additionally, it implements some pandas.Series-like features like accessing
    elements by attribute::

        spines['top'].set_visible(False)
        spines.top.set_visible(False)

    Multiple spines can be addressed simultaneously by passing a list::

        spines[['top', 'right']].set_visible(False)

    Use an open slice to address all spines::

        spines[:].set_visible(False)

    The latter two indexing methods will return a `SpinesProxy` that broadcasts all
    ``set_*()`` and ``set()`` calls to its members, but cannot be used for any other
    operation.
    c                     || _         y r   _dict)r   r1   s     r   r   zSpines.__init__"  s	    
r   c                      | di |S Nr
   r
   )r   ds     r   	from_dictzSpines.from_dict%  s    xQxr   c                     | j                   S r   r  r   s    r   __getstate__zSpines.__getstate__)  r   r   c                 (     | j                   di | y r  )r   )r   states     r   __setstate__zSpines.__setstate__,  s    r   c                 Z    	 | j                   |   S # t        $ r t        d| d      w xY w)Nz$'Spines' object does not contain a 'z' spine)r  KeyErrorr   )r   r   s     r   r   zSpines.__getattr__/  sC    	F::d## 	F 6tfGDF F	Fs    *c                    t        |t              ru|D cg c]  }|| j                  vs| }}|rt        dj	                  |            t        | j                  j                         D ci c]  \  }}||v r|| c}}      S t        |t              rt        d      t        |t              rD|j                  -|j                  !|j                  t        | j                        S t        d      | j                  |   S c c}w c c}}w )Nz, z/Multiple spines must be passed as a single listzYSpines does not support slicing except for the fully open slice [:] to access all spines.)r   r  r  r  joinr   itemstupler   slicestartstopstep)r   keykunknown_keysvs        r   __getitem__zSpines.__getitem__6  s    c4 '*Bs!atzz.AAsLBtyy6771A1A1C  -1CA#$8 !"11C  - . .c5!NOOc5!yy SXX%5#((:J"4::.. ;< < zz# C -s   DD-D	
c                 "    || j                   |<   y r   r  )r   r   values      r   __setitem__zSpines.__setitem__H  s    

3r   c                     | j                   |= y r   r  )r   r   s     r   __delitem__zSpines.__delitem__L  s    JJsOr   c                 ,    t        | j                        S r   )rc   r  r   s    r   __iter__zSpines.__iter__P  s    DJJr   c                 ,    t        | j                        S r   )r   r  r   s    r   __len__zSpines.__len__S  s    4::r   N)r   r   r   r   r   r   r  r  r  r   r$  r'  r)  r+  r-  r
   r   r   r	  r	    sI    ,  F$  r   r	  )collections.abcr   r   numpyr   
matplotlibr   r   r   matplotlib.artistr   matplotlib.transforms
transformsr.   matplotlib.patchespatchesmpatchesmatplotlib.pathr   r*   Patchr   r   r	  r
   r   r   <module>r9     sL    *    ' 1 + % WHNN Wt (  (FI^ Ir   