
    hT                         S SK Jr  S SKrS SKrS SKrS SKJrJr  S SK	J
r
  S SKJr  S SKJr  S SKJr   " S S\R(                  5      r " S S5      r " S	 S
\5      rg)    )MutableMappingN)_api
_docstring)allow_rasterizationc                     ^  \ rS rSrSrS r\R                  U 4S j5       rS r	S r
S rS rU 4S	 jrSU 4S
 jjrS rS rS rS rS rS r\U 4S j5       rS rS rS rSS jrS r\S 5       r\S 5       r\S 5       rS r Sr!U =r"$ )Spine   aM  
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                     g)Nr    selfs    C/var/www/html/env/lib/python3.13/site-packages/matplotlib/spines.py__str__Spine.__str__    s        c                   > [         TU ]  " S0 UD6  Xl        U R                  U R                  R	                  SS95        X l        U R                  S5        U R                  [        R                  S   5        U R                  [        R                  S   5        U R                  S5        SU l        U R                  S5        U R                  U R                  R                  5        SU l        SU l        [$        R&                  " [(        R*                  US	9  X0l        S
U l        [0        R2                  " 5       U l        g)aB  
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   Spine.__init__#   s    & 	"6"			,,%,89$6"3<<(89:3<<(89:,'	499../
 ejjt4
 " !, = = ?r   c                     SU l         Xl        US-  U l        US-  U l        X0l        X@l        [        R                  R                  X45      U l	        U R                  U R                  R                  5        SU l        g)zSet the spine to be arc-like.arc   TN)r/   _center_width_height_theta1_theta2r,   r-   r7   r.   r'   r   	transAxesstale)r   centerradiustheta1theta2s        r   set_patch_arcSpine.set_patch_arcX   sb     qjzZZ^^F3
499../
r   c                     SU l         Xl        US-  U l        US-  U l        U R	                  U R
                  R                  5        SU l        g)zSet the spine to be circular.circler8   TN)r/   r9   r:   r;   r'   r   r>   r?   )r   r@   rA   s      r   set_patch_circleSpine.set_patch_circlee   sD    #qjz499../
r   c                      SU l         SU l        g)zSet the spine to be linear.r   TN)r/   r?   r   s    r   set_patch_lineSpine.set_patch_lineo   s    !
r   c                    U R                   S;   d   eU R                  U R                  S   5      U R                  U R                  S   5      4nU R                  U R                  5      nU R                  U R
                  5      n[        R                  " 5       R                  US-  US-  5      R                  " U6 U l
        g)z
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.
r7   rG   r            ?N)r/   convert_xunitsr9   convert_yunitsr:   r;   r0   Affine2Dscale	translater2   )r   r@   widthheights       r   _recompute_transformSpine._recompute_transformu   s     #4444%%dll1o6%%dll1o68##DKK0$$T\\2 + 4 4 6U53;-Y!! r   c                 x   > U R                   S;   a  U R                  5         U R                  $ [        TU ]  5       $ )NrN   )r/   rX   r2   r   get_patch_transform)r   r4   s    r   r[   Spine.get_patch_transform   s8    00%%'(((7.00r   c                 4  > U R                  5         [        TU ]	  US9nU R                  b  U R                  R	                  5       (       d  U$ U/nU R                  R                  5       n[        [        1 Uk1 U R                  R                  k-  5      S5      n[        [        1 Uk1 U R                  R                  k-  5      S5      nXV4 GH  nUc  M	  UR                  5       nUR                  n	UR                  n
U
S:X  a  SnSnOU
S:X  a  SnSnOSnSnU R                  SS	9R                  nX-  S
-  U-  nX-  S
-  U-  nUR                  R	                  5       (       aq  U R                   S:X  a)  UR"                  U-
  Ul        UR$                  U-   Ul        O8U R                   S:X  a(  UR&                  U-
  Ul        UR(                  U-   Ul        UR*                  R	                  5       (       aq  U R                   S:X  a)  UR$                  U-   Ul        UR"                  U-
  Ul        O8U R                   S:X  a(  UR(                  U-   Ul        UR&                  U-
  Ul        UR-                  U5        GM     [.        R0                  R3                  U5      $ )z
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outrO   r   inrP   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appendr0   Bboxunion)r   r^   bbbboxesdrawn_ticks
major_tick
minor_ticktickbb0tickltickdirpadoutpadinrq   r4   s                 r   rg   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^b(3.FMB&,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                     U R                   $ N)r.   r   s    r   get_pathSpine.get_path       zzr   c                 d    U R                   c#  SU l         U R                  U R                   5        g g )N)outward        )r*   set_positionr   s    r   _ensure_position_is_setSpine._ensure_position_is_set   s*    >>!-DNdnn- "r   c                     Xl         SU l        g)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_axisSpine.register_axis   s     	
r   c                 t    U R                  5         U R                  b  U R                  R                  5         gg)zClear the current spine.N)_clearr%   clearr   s    r   r   Spine.clear   s(    99 IIOO !r   c                     SU l         g)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   Spine._clear   s     r   c                     U R                   S:X  a  gU R                  b  U R                  u  pO~U R                   S;   a#  U R                  R                  R                  u  pOKU R                   S;   a#  U R                  R                  R
                  u  pO[        SU R                    35      eU R                  S:X  Ga$  U R                   S;   a   U R                  R                  5       n U R                  R                  5       nX-  U-   nX#-  U-   nX:  a  X!p![        R                  R                  [        R                  " U5      [        R                  " U5      5      U l        U R                   S
:X  aS  U R                  R                  R                  u  pV U R                  R#                  5       nXW-
  Xg-
  -  nXl        Xl        gg[        SU R                   -  5      eU R                   R(                  n	U	R*                  S:X  d   S5       eU R                   S;   a	  XS'   X)S'   gU R                   S;   a	  XS'   X)S'   g[        SU R                   -  5      e! [         a    Sn GNf = f! [         a    S	n GNwf = f! [         a    Un Nf = f)z4Automatically set spine bounds to the view interval.rG   Nrb   rd   re   rc   unknown spine spine_type: r7   rc   re   rO   r   rc   z#unable to set bounds for spine "%s")r8   r8   zunexpected vertices shaper   rO   )rO   rO   )r   r   rO   r   )r   r)   r   viewLim	intervaly	intervalx
ValueErrorr/   get_theta_directionAttributeErrorget_theta_offsetr,   r-   r7   nprad2degr.   get_roriginr;   r:   verticesshape)
r   lowhigh	directionoffsetrminrmaxroriginscaled_diameterv1s
             r   rf   Spine._adjust_location   sV    ??h&<<#IC__ 11		))33IC__ 11		))33IC9$//9JKLLu$"33" $		 = = ?I!YY779F o.'&0: $"ZZ^^BJJsORZZ=MN
??h.!%!2!2!<!<JD'"&))"7"7"9 (,~$.&IO#2L"1K / !!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(+I;:I;>JJc                 T   > U R                  5         [        TU ]	  U5      nSU l        U$ )NF)rf   r   drawr?   )r   r^   retr4   s      r   r   
Spine.draw%  s)    gl8$

r   c                    US;   a  O.[        U5      S:w  a  [        S5      eUS   S;  a  [        S5      eXl        U R                  U R	                  5       5        U R
                  b  U R
                  R                  5         SU l        g)	aA  
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@   zeror8   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   Spine.set_position,  s    * ))8}! !IJJ{"==  "6 7 7!4335699 II!!#
r   c                 :    U R                  5         U R                  $ )zReturn the spine position.)r   r*   r   s    r   get_positionSpine.get_positionO  s    $$&~~r   c                    U R                  5         U R                  n[        U[        5      (       a  US:X  a  SnOUS:X  a  Sn[	        U5      S:X  d   S5       eUu  p#[
        R                  " / SQUS9  U R                  S	;   a  U R                  R                  S
S9nOCU R                  S;   a  U R                  R                  S
S9nO[        SU R                  < 35      eUS:X  aj  US:X  a  U$ SSSSS.U R                     nU[        R                  " U5      -  S-  nU[        R                  " / UQU R!                  SS9R"                  P76 -   $ US:X  ao  U R                  S	;   a'  [        R$                  R'                  SSSSUS5      U-   $ U R                  S;   a'  [        R$                  R'                  SSSSSU5      U-   $ gUS:X  Ga   U R                  S;   a  US-  nU R                  S	;   ae  [        R(                  " [        R$                  " 5       R+                  US5      U R                  R,                  -   U R                  R,                  5      $ U R                  S;   ae  [        R(                  " U R                  R,                  [        R$                  " 5       R+                  SU5      U R                  R,                  -   5      $ gg)zReturn the spine transform.r@   )r   rP   r   )r   r   r8   zposition should be 2-tuple)r   r   r   )position_typer   grid)whichr   r   r   r   )r   r   )r   r   r   )rb   rd   rc   re   ra   Fr   r   rO   r   r   )rd   re   N)r   r*   
isinstancestrr   r   check_in_listr   r   get_yaxis_transformget_xaxis_transformr   r   arrayr0   ScaledTranslationr   dpi_scale_transrS   from_valuesblended_transform_factoryrU   r(   )r   r   r   amountbase_transform
offset_vecoffset_dotss          r   r   Spine.get_spine_transformT  s   $$&>>h$$8#(V#&8}!?#??! (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                     U R                   S:X  a  [        S5      eUc  [        R                  " U5      (       a  Uu  pU R	                  5       =(       d    Su  p4Uc  UnUc  UnX4U l        SU l        g)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.
rG   z5set_bounds() method incompatible with circular spinesNNNT)r   r   r   iterable
get_boundsr)   r?   )r   r   r   old_lowold_highs        r   
set_boundsSpine.set_bounds  st    " ??h&GI I<BKK,,IC OO-=;C<D{
r   c                     U R                   $ )zGet the bounds of the spine.)r)   r   s    r   r   Spine.get_bounds  s    ||r   c                 x   US:X  a  [         R                  " SS/5      nOkUS:X  a  [         R                  " SS/5      nOLUS:X  a  [         R                  " SS/5      nO-US:X  a  [         R                  " SS/5      nO[        S	U-  5      eU " XU40 UD6nUR                  [        R
                  S
U 3   5        U$ )z#Create and return a linear `Spine`.rb   )r   +?rd   )      ?r   rc   )r   r   re   )r   r   z"unable to make path for spine "%s"zaxes.spines.)r,   r-   r   set_visibler!   r"   )clsr   r   r3   r   results         r   linear_spineSpine.linear_spine  s     ::|\:;D7"::|\:;D8#::|\:;D5 ::|\:;DAJNOOTt6v63<<,zl(CDEr   c                 |    [         R                  R                  XV5      nU " XU40 UD6n	U	R                  X4XV5        U	$ )z!Create and return an arc `Spine`.)r,   r-   r7   rD   )
r   r   r   r@   rA   rB   rC   r3   r   r   s
             r   	arc_spineSpine.arc_spine  s<     zz~~f-Tt6v6VV<r   c                 |    [         R                  R                  5       nSnU " XU40 UD6nUR                  X#5        U$ )z%Create and return a circular `Spine`.rG   )r,   r-   unit_circlerH   )r   r   r@   rA   r3   r   r   r   s           r   circular_spineSpine.circular_spine  s?     zz%%'
Tt6v6/r   c                 4    U R                  U5        SU l        g)a  
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_colorSpine.set_color  s     	1
r   )r)   r9   r;   r2   r/   r.   r*   r<   r=   r:   r   r%   r   r?   r   r   )#__name__
__module____qualname____firstlineno____doc__r   r   interpdr   rD   rH   rK   rX   r[   rg   r   r   r   r   r   rf   r   r   r   r   r   r   r   classmethodr   r   r   r   __static_attributes____classcell__)r4   s   @r   r   r      s    " 2@ 2@h $18.t.	82t  !F
9+v<  $     r   r   c                   *    \ rS rSrSrS rS rS rSrg)SpinesProxyi  aO  
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                     Xl         g r   _spine_dict)r   
spine_dicts     r   r   SpinesProxy.__init__  s    %r   c                 H   U R                   R                  5        Vs/ s H  n[        X!5      (       d  M  UPM     nnUS:w  a  UR                  S5      (       a  U(       d  [	        SU S35      eS n[
        R                  " XCU5      nUS   R                  Ul        U$ s  snf )Nsetset_z''SpinesProxy' object has no attribute ''c                 8    U  H  n[        XA5      " U0 UD6  M     g r   )getattr)_targets	_funcnameargsr3   spines        r   x"SpinesProxy.__getattr__.<locals>.x  s    !)4:6: "r   r   )r  valueshasattr
startswithr   	functoolspartialr   )r   namer  broadcast_targetsr  s        r   __getattr__SpinesProxy.__getattr__  s    040@0@0G0G0I 60Iu ' 4 #0I 6EM$//&"9"9BS 9$qAC C	; aD9%a(00	6s
   BBc                     / nU R                   R                  5        H$  nUR                  S [        U5       5       5        M&     [	        [        [        U5      5      5      $ )Nc              3   T   #    U  H  oR                  S 5      (       d  M  Uv   M      g7f)r
  N)r  ).0r  s     r   	<genexpr>&SpinesProxy.__dir__.<locals>.<genexpr>  s#      L%/T??63J %/s   (	()r  r  extenddirlistsortedr	  )r   namesr  s      r   __dir__SpinesProxy.__dir__  sV    %%,,.ELL L%(ZL L / F3u:&''r   r  N)	r   r   r   r   r   r   r  r'  r   r   r   r   r  r    s    &(r   r  c                   ^    \ rS rSrSrS r\S 5       rS rS r	S r
S rS	 rS
 rS rS rSrg)Spinesi  a  
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                     Xl         g r   _dict)r   r3   s     r   r   Spines.__init__"  s    
r   c                     U " S0 UD6$ Nr   r   )r   ds     r   	from_dictSpines.from_dict%  s    xQxr   c                     U R                   $ r   r,  r   s    r   __getstate__Spines.__getstate__)  r   r   c                 (    U R                   " S0 UD6  g r0  )r   )r   states     r   __setstate__Spines.__setstate__,  s    r   c                 \     U R                   U   $ ! [         a    [        SU S35      ef = f)Nz$'Spines' object does not contain a 'z' spine)r-  KeyErrorr   )r   r  s     r   r  Spines.__getattr__/  sC    	F::d## 	F 6tfGDF F	Fs    +c                 ^   [        U[        5      (       a  U Vs/ s H  o"U R                  ;  d  M  UPM     nnU(       a  [        SR	                  U5      5      e[        U R                  R                  5        VVs0 s H  u  p$X!;   d  M  X$_M     snn5      $ [        U[        5      (       a  [        S5      e[        U[        5      (       aG  UR                  c/  UR                  c"  UR                  c  [        U R                  5      $ [        S5      eU R                  U   $ s  snf s  snnf )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__Spines.__getitem__6  s    c4  '*Bs!tzz.AAsLBtyy6771A1A1C  -1C#$8 !%1C  - . .c5!!NOOc5!!yy SXX%5#((:J"4::.. ;< < zz# C -s   D$D$<D)
D)
c                      X R                   U'   g r   r,  )r   rF  values      r   __setitem__Spines.__setitem__H  s    

3r   c                     U R                   U	 g r   r,  )r   rF  s     r   __delitem__Spines.__delitem__L  s    JJsOr   c                 ,    [        U R                  5      $ r   )rk   r-  r   s    r   __iter__Spines.__iter__P  s    DJJr   c                 ,    [        U R                  5      $ r   )r   r-  r   s    r   __len__Spines.__len__S  s    4::r   r,  N)r   r   r   r   r   r   r   r2  r5  r9  r  rJ  rN  rQ  rT  rW  r   r   r   r   r*  r*    sI    ,  F$  r   r*  )collections.abcr   r  numpyr   
matplotlibr!   r   r   matplotlib.artistr   matplotlib.transforms
transformsr0   matplotlib.patchespatchesmpatchesmatplotlib.pathr   r,   Patchr   r  r*  r   r   r   <module>rd     sL    *    ' 1 + % WHNN Wt (  (FI^ Ir   