
    h@                     j   S r SSKrSSKrSSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SSKJrJr   " S	 S
5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S5      r " S S5      r " S S5      r " S S\5      r " S S\R6                  5      r " S S\5      r\r\rg)a  
Axislines includes modified implementation of the Axes class. The
biggest difference is that the artists responsible for drawing the axis spine,
ticks, ticklabels and axis labels are separated out from Matplotlib's Axis
class. Originally, this change was motivated to support curvilinear
grid. Here are a few reasons that I came up with a new axes class:

* "top" and "bottom" x-axis (or "left" and "right" y-axis) can have
  different ticks (tick locations and labels). This is not possible
  with the current Matplotlib, although some twin axes trick can help.

* Curvilinear grid.

* angled ticks.

In the new axes class, xaxis and yaxis is set to not visible by
default, and new set of artist (AxisArtist) are defined to draw axis
line, ticks, ticklabels and axis label. Axes.axis attribute serves as
a dictionary of these artists, i.e., ax.axis["left"] is a AxisArtist
instance responsible to draw left y-axis. The default Axes.axis contains
"bottom", "left", "top" and "right".

AxisArtist can be considered as a container artist and has the following
children artists which will draw ticks, labels, etc.

* line
* major_ticks, major_ticklabels
* minor_ticks, minor_ticklabels
* offsetText
* label

Note that these are separate artists from `matplotlib.axis.Axis`, thus most
tick-related functions in Matplotlib won't work. For example, color and
markerwidth of the ``ax.axis["bottom"].major_ticks`` will follow those of
Axes.xaxis unless explicitly specified.

In addition to AxisArtist, the Axes will have *gridlines* attribute,
which obviously draws grid lines. The gridlines needs to be separated
from the axis as some gridlines can never pass any axis.
    N)_api)Path)mpl_axes   )AxislineStyle)
AxisArtistGridlinesCollectionc                   0    \ rS rSrSrS rS rS rS rSr	g)	_AxisArtistHelperBase5   a  
Base class for axis helper.

Subclasses should define the methods listed below.  The *axes*
argument will be the ``.axes`` attribute of the caller artist. ::

    # Construct the spine.

    def get_line_transform(self, axes):
        return transform

    def get_line(self, axes):
        return path

    # Construct the label.

    def get_axislabel_transform(self, axes):
        return transform

    def get_axislabel_pos_angle(self, axes):
        return (x, y), angle

    # Construct the ticks.

    def get_tick_transform(self, axes):
        return transform

    def get_tick_iterators(self, axes):
        # A pair of iterables (one for major ticks, one for minor ticks)
        # that yield (tick_position, tick_angle, tick_label).
        return iter_major, iter_minor
c                     Xl         g N	nth_coord)selfr   s     S/var/www/html/env/lib/python3.13/site-packages/mpl_toolkits/axisartist/axislines.py__init___AxisArtistHelperBase.__init__W   s    "    c                     g r    r   axess     r   
update_lim _AxisArtistHelperBase.update_limZ   s    r   c                     U R                   $ r   r   r   s    r   get_nth_coord#_AxisArtistHelperBase.get_nth_coord]       ~~r   c                     U R                   S:X  a)  [        R                  " [        R                  " X5      SS9$ U R                   S:X  a)  [        R                  " [        R                  " X!5      SS9$ [	        S5      e)a  
Create a (*values.shape, 2)-shape array representing (x, y) pairs.

The other coordinate is filled with the constant *const*.

Example::

    >>> self.nth_coord = 0
    >>> self._to_xy([1, 2, 3], const=0)
    array([[1, 0],
           [2, 0],
           [3, 0]])
r   axisr   zUnexpected nth_coord)r   npstackbroadcast_arrays
ValueError)r   valuesconsts      r   _to_xy_AxisArtistHelperBase._to_xy`   s`     >>Q88B//>RHH^^q 88B//>RHH344r   r   N)
__name__
__module____qualname____firstlineno____doc__r   r   r   r+   __static_attributes__r   r   r   r   r   5   s    B#5r   r   c                   z   ^  \ rS rSrSr\R                  " SS5      SU 4S jj5       rS rS r	S r
S	 rS
 rSrU =r$ )_FixedAxisArtistHelperBasev   z7Helper class for a fixed (in the axes coordinate) axis.3.9r   c           	         > [         TU ]  [        R                  " SSSSS.US95        Xl        SSSSS.U   U l        [        U R                  SU R
                  S95      U l        g)z5``nth_coord = 0``: x-axis; ``nth_coord = 1``: y-axis.r   r   bottomtopleftright)locr   r   r*   N)	superr   r   check_getitem_loc_posr   r+   _path)r   r=   r   	__class__s      r   r   #_FixedAxisArtistHelperBase.__init__y   sf     	++A:E 	F	 AB3G	$++fDII+>?
r   c                     U R                   $ r   )rD   r   s     r   get_line#_FixedAxisArtistHelperBase.get_line   s    zzr   c                     UR                   $ r   	transAxesr   s     r   get_line_transform-_FixedAxisArtistHelperBase.get_line_transform   r    r   c                     UR                   $ r   rK   r   s     r   get_axislabel_transform2_FixedAxisArtistHelperBase.get_axislabel_transform   r    r   c                 4    [        SSSSS9U R                     $ )t
Return the label reference position in transAxes.

get_label_transform() returns a transform of (transAxes+offset)
))              ?Z   ))      ?rU   rV   ))rU   rT   r   ))rU   rW   r   )r;   r<   r9   r:   )dictrB   r   s     r   get_axislabel_pos_angle2_FixedAxisArtistHelperBase.get_axislabel_pos_angle   s*     ))&( )-		3 	3r   c                 \    UR                  5       UR                  5       /U R                     $ r   )get_xaxis_transformget_yaxis_transformr   r   s     r   get_tick_transform-_FixedAxisArtistHelperBase.get_tick_transform   s(    ((*D,D,D,FGWWr   )rB   rD   rC   r   )r-   r.   r/   r0   r1   r   delete_parameterr   rH   rM   rP   rY   r^   r2   __classcell__rE   s   @r   r4   r4   v   sG    A	5+.@ /@
	3X Xr   r4   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )_FloatingAxisArtistHelperBase   c                 0   > X l         [        TU ]	  U5        g r   )_valuer@   r   )r   r   valuerE   s      r   r   &_FloatingAxisArtistHelperBase.__init__   s    #r   c                     [        S5      e)Nz6get_line method should be defined by the derived class)RuntimeErrorr   s     r   rH   &_FloatingAxisArtistHelperBase.get_line   s    STTr   )rg   )r-   r.   r/   r0   r   rH   r2   ra   rb   s   @r   rd   rd      s    $U Ur   rd   c                   ^   ^  \ rS rSr\R
                  " SS5      SU 4S jj5       rS rSrU =r	$ ) FixedAxisArtistHelperRectilinear   r6   r   c                 x   > [         TU ]  U5        UR                  UR                  /U R                     U l        g)zj
nth_coord = along which coordinate value varies
in 2D, nth_coord = 0 ->  x axis, nth_coord = 1 -> y axis
N)r@   r   xaxisyaxisr   r$   )r   r   r=   r   rE   s       r   r   )FixedAxisArtistHelperRectilinear.__init__   s/     	ZZ,T^^<	r   c                   ^ ^	^
^ SSS.T R                      u  m	m
T R                  R                  nUR                  5       nUR                  R                  U5      nT R                  R                  nUR                  5       nUR                  R                  U5      nT R                  U5      UR                  -
  mU	U
U U4S jnU" X45      U" Xg5      4$ ) tick_loc, tick_angle, tick_labelrV   r   r   rV   r>   c              3     >#    [        X5       Hl  u  p#TR                  UTR                  S9nT	R                  U5      n[        R
                  R                  SUTR                     5      (       d  Md  UTTU4v   Mn     g 7f)Nr?   r>   )zipr+   rC   	transformmpl
transforms_interval_contains_closer   )
locslabelsr=   labelcc2angle_normalangle_tangentr   tick_to_axess
         r   _f?FixedAxisArtistHelperRectilinear.get_tick_iterators.<locals>._f   sl     !$/
KK499K5!++A.>>::62dnnCUVV\=%?? 0s   A,B 3B )	r   r$   majorlocator	formatterformat_ticksminorr^   rL   )r   r   r   
major_locsmajor_labelsr   
minor_locsminor_labelsr   r   r   r   s   `        @@@r   get_tick_iterators3FixedAxisArtistHelperRectilinear.get_tick_iterators   s    *1g&>t~~&N#m		]]_
33J?		]]_
33J?..t4t~~E	@ 	@ *+R
-IIIr   r#   r   )
r-   r.   r/   r0   r   r`   r   r   r2   ra   rb   s   @r   rn   rn      s.    	5+.= /=J Jr   rn   c                   R   ^  \ rS rSr S
U 4S jjrS rS rS rS rS r	S r
S	rU =r$ )#FloatingAxisArtistHelperRectilinear   c                    > [         TU ]  X#5        X@l        UR                  UR                  /U R
                     U l        g r   )r@   r   _axis_directionrq   rr   r   r$   )r   r   r   passingthrough_pointaxis_directionrE   s        r   r   ,FloatingAxisArtistHelperRectilinear.__init__   s3    9-ZZ,T^^<	r   c                     SU R                   -
  nUR                  UR                  -
  nUR                  U R                  U R                  /5      n[        U R                  SXB   S95      $ )Nr   r>   r?   )r   	transDatarL   rz   rg   r   r+   )r   r   fixed_coorddata_to_axesps        r   rH   ,FloatingAxisArtistHelperRectilinear.get_line   sY    $..(~~6""DKK#=>DKKanK=>>r   c                     UR                   $ r   rK   r   s     r   rM   6FloatingAxisArtistHelperRectilinear.get_line_transform   r    r   c                     UR                   $ r   rK   r   s     r   rP   ;FloatingAxisArtistHelperRectilinear.get_axislabel_transform   r    r   c                    SS/U R                      nSU R                   -
  nUR                  UR                  -
  nUR                  U R                  U R                  /5      nU R                  SXS   S9nSXc   s=::  a  S::  a  O  OXb4$ S$ )rS   r   rV   r   rU   r?   )NN)r   r   rL   rz   rg   r+   )r   r   angler   r   r   vertss          r   rY   ;FloatingAxisArtistHelperRectilinear.get_axislabel_pos_angle   s     B'$..(~~6""DKK#=>Cq~6!"e&8!=A!=~O<Or   c                     UR                   $ r   )r   r   s     r   r^   6FloatingAxisArtistHelperRectilinear.get_tick_transform   r    r   c                   ^ ^	^
^ SSS.T R                      u  m	m
T R                  R                  nUR                  5       nUR                  R                  U5      nT R                  R                  nUR                  5       nUR                  R                  U5      nUR                  UR                  -
  mU	U
UU 4S jnU" X45      U" Xg5      4$ )ru   rv   rw   r>   c              3      >#    [        X5       H`  u  p#T
R                  UT
R                  S9nT	R                  U5      u  pVSUs=::  a  S::  d  MA  O  ME  SUs=::  a  S::  d  MT  O  MX  UTTU4v   Mb     g 7f)Nr?   r   r   )ry   r+   rg   rz   )r~   r   r=   r   r   c1r   r   r   r   r   s          r   r   BFloatingAxisArtistHelperRectilinear.get_tick_iterators.<locals>._f  sg     !$/
KK4;;K7%//2<a<<ALqLL\=%??	 0s   A	A4A4#A4)	r   r$   r   r   r   r   r   r   rL   )r   r   r   r   r   r   r   r   r   r   r   r   s   `        @@@r   r   6FloatingAxisArtistHelperRectilinear.get_tick_iterators   s    *1g&>t~~&N#m		]]_
33J?		]]_
33J?~~6	@ 	@ *+R
-IIIr   )r   r$   r9   )r-   r.   r/   r0   r   rH   rM   rP   rY   r^   r   r2   ra   rb   s   @r   r   r      s3     7?=?PJ Jr   r   c                       \ rS rSr\r\rSrg)AxisArtistHelperi  r   N)	r-   r.   r/   r0   r4   Fixedrd   Floatingr2   r   r   r   r   r     s    &E,Hr   r   c                       \ rS rSr\r\rSrg)AxisArtistHelperRectlineari  r   N)	r-   r.   r/   r0   rn   r   r   r   r2   r   r   r   r   r     s    ,E2Hr   r   c                   :   ^  \ rS rSrU 4S jrS rS rS rSrU =r	$ )GridHelperBasei  c                 0   > S U l         [        TU ]	  5         g r   )_old_limitsr@   r   )r   rE   s    r   r   GridHelperBase.__init__  s    r   c                     UR                  5       u  p#UR                  5       u  pEU R                  X#XE4:w  a  U R                  X$X55        X#XE4U l        g g r   )get_xlimget_ylimr   _update_grid)r   r   x1x2y1y2s         r   r   GridHelperBase.update_lim  sQ    //bb- "/D 0r   c                     g)z>Cache relevant computations when the axes limits have changed.Nr   )r   r   r   r   r   s        r   r   GridHelperBase._update_grid#  s    r   c                     / $ )z
Return list of grid lines as a list of paths (list of points).

Parameters
----------
which : {"both", "major", "minor"}
axis : {"both", "x", "y"}
r   )r   whichr$   s      r   get_gridlinesGridHelperBase.get_gridlines&  s	     	r   )r   )
r-   r.   r/   r0   r   r   r   r   r2   ra   rb   s   @r   r   r     s    0M	 	r   r   c                   r   ^  \ rS rSrU 4S jr\R                  " SSSS9 SS j5       rSS jrSS	 jr	S
r
U =r$ )GridHelperRectlineari2  c                 .   > [         TU ]  5         Xl        g r   )r@   r   r   )r   r   rE   s     r   r   GridHelperRectlinear.__init__4  s    	r   r6   r   z''nth_coord' is now inferred from 'loc'.)addendumc                 ~    Uc"  [         R                  " S5        U R                  nUc  Un[        U[	        XQ5      XCS9$ )Nz6'new_fixed_axis' explicitly requires the axes keyword.)offsetr   )r   warn_externalr   r   rn   )r   r=   r   r   r   r   s         r   new_fixed_axis#GridHelperRectlinear.new_fixed_axis8  sK     <HJ99D! N$ @ K!'H 	Hr   c                    Uc"  [         R                  " S5        U R                  n[        XAX#5      n[	        XEUS9nUR
                  R                  S5        UR
                  R                  UR                  R                  5        U$ )Nz9'new_floating_axis' explicitly requires the axes keyword.)r   T)	r   r   r   r   r   lineset_clip_onset_clip_boxbbox)r   r   rh   r   r   helperaxislines          r   new_floating_axis&GridHelperRectlinear.new_floating_axisE  sp    <KM99D4U4d>J!!$'""8==#5#56r   c                   ^^^^ [         R                  " / SQUS9  [         R                  " / SQUS9  / nUS;   a  / nU R                  R                  5       u  mmUS;   a=  UR	                  U R                  R
                  R                  R                  5       5        US;   a=  UR	                  U R                  R
                  R                  R                  5       5        UR	                  UU4S jU 5       5        US	;   Ga  U R                  R                  5       u  mm/ nU R                  R                  R                  S
   (       a=  UR	                  U R                  R                  R                  R                  5       5        U R                  R                  R                  S
   (       a=  UR	                  U R                  R                  R                  R                  5       5        UR	                  UU4S jU 5       5        U$ )z
Return list of gridline coordinates in data coordinates.

Parameters
----------
which : {"both", "major", "minor"}
axis : {"both", "x", "y"}
)bothr   r   )r   )r   xyr#   )r   r   )r   r   )r   r   c              3   2   >#    U  H  oU/TT//v   M     g 7fr   r   ).0r   r   r   s     r   	<genexpr>5GridHelperRectlinear.get_gridlines.<locals>.<genexpr>e  s     >A!fr2h/   )r   r   gridOnc              3   2   >#    U  H  nTT/X//v   M     g 7fr   r   )r   r   r   r   s     r   r   r   n  s     >Ar2h/r   )r   check_in_listr   r   extendrq   r   r   r   r   rr   _major_tick_kw_minor_tick_kw)	r   r   r$   	gridlinesr~   r   r   r   r   s	        @@@@r   r   "GridHelperRectlinear.get_gridlinesQ  sj    	5UC-D9	= DYY'')FB))DIIOO1199;<))DIIOO1199;<>>>= YY'')FBDyy--h7DIIOO1199;<yy--h7DIIOO1199;<>>>r   )r   )NNNN)r9   N)r   r   )r-   r.   r/   r0   r   r   r`   r   r   r   r2   ra   rb   s   @r   r   r   2  sI     
{%NP OS	HP	H
 r   r   c                      ^  \ rS rSrSS.U 4S jjrSS jr\S 5       rU 4S jrS r	SU 4S	 jjr
U 4S
 jrSS jrSS jrSrU =r$ )Axesis  N)grid_helperc                   > SU l         U(       a  UO
[        U 5      U l        [        TU ]  " U0 UD6  U R                  S5        g )NT)_axisline_onr   _grid_helperr@   r   toggle_axisline)r   r   argskwargsrE   s       r   r   Axes.__init__u  s>     +6K<PQU<V$)&)T"r   c                    Uc  U R                   (       + nU(       a\  SU l         U R                  S S  R                  S5        U R                  R                  S5        U R                  R                  S5        g SU l         U R                  S S  R                  S5        U R                  R                  S5        U R                  R                  S5        g )NTF)r   spinesset_visiblerq   rr   )r   bs     r   r   Axes.toggle_axisline{  s    9%%%A $DKKN&&u-JJ""5)JJ""5) %DKKN&&t,JJ""4(JJ""4(r   c                     U R                   $ r   )
_axislinesr   s    r   r$   	Axes.axis  s    r   c                 ,  > [        / [        R                  S   [        R                  S   [        R                  S   S9=U l        nU R	                  U5        UR                  U R                  5       5        [        TU ]!  5         UR                  U R                  R                  5        [        R                  R                  U 5      U l        U R                  5       R                   nU R                  R#                  S Vs0 s H
  nX2" X0US9_M     sn5        U R                  S   U R                  S   4 HT  nUR$                  R'                  S	5        UR(                  R'                  S	5        UR*                  R'                  S	5        MV     g s  snf )
Nz
grid.colorzgrid.linestylezgrid.linewidth)colors
linestyles
linewidthsr8   )r=   r   r   r:   r<   F)r	   r{   rcParamsr   _set_artist_propsset_grid_helperget_grid_helperr@   clearset_clip_pathr   patchr   r   AxisDictr   r   updater   r   major_ticklabelsminor_ticklabels)r   r   r   r=   r   rE   s        r   r	  
Axes.clear  sQ    &9<<-||$45||$45	&7 	7
 	y)!!$"6"6"89 			0 #--006--/>>9 ;9 C3GG9 ; 	< /1IJHNN&&u-%%11%8%%11%8 K ;s   Fc                     U R                   $ r   )r   r   s    r   r  Axes.get_grid_helper  s       r   c                   > [         TU ]  " U4X#S.UD6  U R                  (       d  gUc  U R                  R                  R
                  S   =(       dw    U R                  R                  R                  S   =(       dM    U R                  R                  R
                  S   =(       d#    U R                  R                  R                  S   nU R                  R                  X#US9  U R                  R                  " S0 UD6  g)zG
Toggle the gridlines, and optionally set the properties of the lines.
)r   r$   Nr   )r   r$   visibler   )
r@   gridr   r   rq   r   r   rr   r   set)r   r  r   r$   r   rE   s        r   r  	Axes.grid  s     	W?E??  ?yy55h? C))//88BC))//88BC ))//88B  	7C$V$r   c                    > U R                   (       a)  / U R                  R                  5       QU R                  PnO/ nUR	                  [
        TU ]  5       5        U$ r   )r   r   r)   r   r   r@   get_children)r   childrenrE   s     r   r  Axes.get_children  sJ    B//1B4>>BHH,./r   c                 >    U R                  5       R                  XU S9$ )N)r   r   )r  r   )r   r=   r   s      r   r   Axes.new_fixed_axis  s!    ##%44Sd4SSr   c                 >    U R                  5       R                  XX0S9$ )N)r   r   )r  r   )r   r   rh   r   s       r   r   Axes.new_floating_axis  s*    ##%77^ 8 H 	Hr   )r   r   r   r   r   )Nr   r   r   )r-   r.   r/   r0   r   r   propertyr$   r	  r  r  r  r   r   r2   ra   rb   s   @r   r   r   s  sO    *. # #)  98!%$TH Hr   r   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )AxesZeroi  c           
      X  > [         TU ]  5         U R                  5       R                  nU R                  R                  U" SSSU S9U" SSSU S9S9  S HS  nU R                  U   R                  R                  U R                  5        U R                  U   R                  S5        MU     g )	Nr   rT   r9   )r   rh   r   r   r   r;   )xzeroyzeroF)
r@   r	  r  r   r   r  r   r
  r  r   )r   r   krE   s      r   r	  AxesZero.clear  s     002DD#2hTK#2f4I 	 	
 $AOOA##11$**=OOA**51 $r   r   )r-   r.   r/   r0   r	  r2   ra   rb   s   @r   r"  r"    s    2 2r   r"  )r1   numpyr%   
matplotlibr{   r   matplotlib.axesr   maxesmatplotlib.pathr   mpl_toolkits.axes_grid1r   axisline_styler   axis_artistr   r	   r   r4   rd   rn   r   r   r   r   r   r   r"  SubplotSubplotZeror   r   r   <module>r2     s   'R       , ) 8>5 >5B(X!6 (XVU$9 U#J'A #JL9J*G 9Jx- -
3 3
 8>> >BXH5:: XHv2t 2  r   