
    
3jgX                         S SK Jr  S SKrS SKJr  S SKrS SKJrJ	r	  S SK
Jr  SSKJrJrJr  SSKJrJr   " S	 S
5      r\	R(                  " \S5      r " S S5      r " S S\5      r\rg)    )NumberN)
MethodType)_apicbook)SubplotSpec   )SizeSubplotDividerDivider)AxesSimpleAxisArtistc                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )CbarAxesBase   c                2   > Xl         [        TU ]  " U0 UD6  g N)orientationsuper__init__)selfr   argskwargs	__class__s       [/home/wildlama/miniconda3/lib/python3.13/site-packages/mpl_toolkits/axes_grid1/axes_grid.pyr   CbarAxesBase.__init__   s    &$)&)    c                 Z    U R                  SS9R                  " U4X R                  S.UD6$ )NFroot)caxlocation)
get_figurecolorbarr   )r   mappabler   s      r   r#   CbarAxesBase.colorbar   s=    E*33E)9)9E=CE 	Er   r   )__name__
__module____qualname____firstlineno__r   r#   __static_attributes____classcell__r   s   @r   r   r      s    *E Er   r   zCbar{}c            	       
   \ rS rSrSr\r\R                  " SSS5         SSSSS	SSS
.S jj5       r	S r
S r\" S 5      r\R                  " S5      " \" S 5      5      rS rS rS rS rS rS rS rS rS rS rS rSrg)Grid   a  
A grid of Axes.

In Matplotlib, the Axes location (and size) is specified in normalized
figure coordinates. This may not be ideal for images that needs to be
displayed with a given aspect ratio; for example, it is difficult to
display multiple images of a same size with some fixed padding between
them.  AxesGrid can be used in such case.

Attributes
----------
axes_all : list of Axes
    A flat list of Axes. Note that you can also access this directly
    from the grid. The following is equivalent ::

        grid[i] == grid.axes_all[i]
        len(grid) == len(grid.axes_all)

axes_column : list of list of Axes
    A 2D list of Axes where the first index is the column. This results
    in the usage pattern ``grid.axes_column[col][row]``.
axes_row : list of list of Axes
    A 2D list of Axes where the first index is the row. This results
    in the usage pattern ``grid.axes_row[row][col]``.
axes_llc : Axes
    The Axes in the lower left corner.
n_axes : int
    Number of Axes in the grid.
z3.11ngridsn_axesNFTL)	share_allshare_xshare_y
label_mode
axes_classaspectc                   Uu  U l         U l        Uc  U R                   U R                  -  nO1SUs=:  a  U R                   U R                  -  ::  d  O  [        S5      e[        [        R
                  [        R                  " US5      5      u  U l        U l	        [        R                  " SS/US9  XPl        Uc  U R                  nO6[        U[        [         45      (       a  Uu  p["        R$                  " U40 UD6n['        / / US9n[        U[(        [*        45      (       a  [-        X40 UD6U l        OP[1        U5      S	:X  a  [-        U/UQ70 UD6U l        O,[1        U5      S
:X  a  [3        X40 UD6U l        O[5        S5      eU R.                  R7                  5       n[        R8                  " U R                   U R                  4S[:        S9n[=        U5       HS  nU R?                  U5      u  nnU(       a  US   =nnO U(       a  USU4   OSnU	(       a  UUS4   OSnU" XUUS9UUU4'   MU     URA                  U R                  S:X  a  SOSS9RC                  5       SU U l"        U VVs/ s H  nU Vs/ s H  nU(       d  M  UPM     snPM!     snnU l#        URH                   VVs/ s H  nU Vs/ s H  nU(       d  M  UPM     snPM!     snnU l%        U RJ                  S   S   U l&        U RO                  5         U RD                   H  nURQ                  U5        M     U RS                  U
5        gs  snf s  snnf s  snf s  snnf )a  
Parameters
----------
fig : `.Figure`
    The parent figure.
rect : (float, float, float, float), (int, int, int), int, or     `~.SubplotSpec`
    The axes position, as a ``(left, bottom, width, height)`` tuple,
    as a three-digit subplot position code (e.g., ``(1, 2, 1)`` or
    ``121``), or as a `~.SubplotSpec`.
nrows_ncols : (int, int)
    Number of rows and columns in the grid.
n_axes : int, optional
    If given, only the first *n_axes* axes in the grid are created.
direction : {"row", "column"}, default: "row"
    Whether axes are created in row-major ("row by row") or
    column-major order ("column by column").  This also affects the
    order in which axes are accessed using indexing (``grid[index]``).
axes_pad : float or (float, float), default: 0.02
    Padding or (horizontal padding, vertical padding) between axes, in
    inches.
share_all : bool, default: False
    Whether all axes share their x- and y-axis.  Overrides *share_x*
    and *share_y*.
share_x : bool, default: True
    Whether all axes of a column share their x-axis.
share_y : bool, default: True
    Whether all axes of a row share their y-axis.
label_mode : {"L", "1", "all", "keep"}, default: "L"
    Determines which axes will get tick labels:

    - "L": All axes on the left column get vertical tick labels;
      all axes on the bottom row get horizontal tick labels.
    - "1": Only the bottom left axes is labelled.
    - "all": All axes are labelled.
    - "keep": Do not do anything.

axes_class : subclass of `matplotlib.axes.Axes`, default: `.mpl_axes.Axes`
    The type of Axes to create.
aspect : bool, default: False
    Whether the axes aspect ratio follows the aspect ratio of the data
    limits.
Nr   z7n_axes must be positive and not larger than nrows*ncols   columnrow)	direction)
horizontalverticalr9         zIncorrect rect format)dtype)r   r   )sharexshareyCF)order)*_nrows_ncols
ValueErrormapr	   Fixednpbroadcast_to_horiz_pad_size_vert_pad_sizer   check_in_list
_direction_defaultAxesClass
isinstancelisttuple	functoolspartialdictr   r   r
   _dividerlenr   	TypeErrorget_positionfullobjectrange_get_col_rowraveltolistaxes_allaxes_rowTaxes_columnaxes_llc_init_locatorsadd_axesset_label_mode)r   figrectnrows_ncolsr2   r>   axes_padr4   r5   r6   r7   r8   r9   clsr   kw
axes_arrayicolr=   rD   rE   axs                          r   r   Grid.__init__<   s   t $/ T[>[[4;;.Fv:t{{!:: MO O 58JJ!4561d1 	He,	B#//J
T5M22$KC"**39&9JR"V<dV[122*3;;DMY!^*3<<<DMY!^#C44DM344}}))+WWdkk4;;7VL
vA((+HC",T"22/6AsF+D/6CF+D#-&$9JsCx   #((E1#s ) <<BFHWfN=GHZcs1sb"s1ZH@JM#4#BR#4M((+B/--BLL   	J' 2H4Ms<   -
L<7L7L7L<+
M5MM
M7L<Mc           	         U R                   R                  [        R                  " S5      U R                  /U R
                  S-
  -  [        R                  " S5      /-   5        U R                   R                  [        R                  " S5      U R                  /U R                  S-
  -  [        R                  " S5      /-   5        [        U R                  5       Hb  nU R                  U5      u  p#U R                  U   R                  U R                   R                  SU-  SU R                  S-
  U-
  -  S95        Md     g )Nr   r;   nxny)r\   set_horizontalr	   ScaledrQ   rK   set_verticalrR   rJ   rb   r2   rc   rf   set_axes_locatornew_locator)r   ru   rv   r=   s       r   rk   Grid._init_locators   s    $$[[^T112dkk!mDTUGWW	Y""[[^T001T[[]Ct{{ST~FVV	Xt{{#A((+HCMM!--))QWdkkAoPS>S9T)UW $r   c                     U R                   S:X  a  [        XR                  5      u  p#X#4$ [        XR                  5      u  p2X#4$ )Nr<   )rT   divmodrJ   rK   )r   nrv   r=   s       r   rc   Grid._get_col_row   s@    ??h&a-HC x a-HCxr   c                 ,    [        U R                  5      $ r   r]   rf   r   s    r   <lambda>Grid.<lambda>   s    3t}}#5r   c                 ,    [        U R                  5      $ r   r   r   s    r   r   r      s    3t}};Mr   c                 ,    [        U R                  5      $ r   r   r   s    r   __len__Grid.__len__   s    4==!!r   c                      U R                   U   $ r   )rf   )r   ru   s     r   __getitem__Grid.__getitem__   s    }}Qr   c                 2    U R                   U R                  4$ )zF
Return the number of rows and columns of the grid as (nrows, ncols).
)rJ   rK   r   s    r   get_geometryGrid.get_geometry   s     {{DKK''r   c                 T    US   U R                   l        US   U R                  l        g)z
Set the padding between the axes.

Parameters
----------
axes_pad : (float, float)
    The padding (horizontal pad, vertical pad) in inches.
r   r   NrQ   
fixed_sizerR   )r   rq   s     r   set_axes_padGrid.set_axes_pad   s(     +31+')1!&r   c                 Z    U R                   R                  U R                  R                  4$ )zl
Return the axes padding.

Returns
-------
hpad, vpad
    Padding (horizontal pad, vertical pad) in inches.
r   r   s    r   get_axes_padGrid.get_axes_pad   s,     $$//##..0 	0r   c                 :    U R                   R                  U5        g)z%Set the aspect of the SubplotDivider.N)r\   
set_aspect)r   r9   s     r   r   Grid.set_aspect   s      (r   c                 6    U R                   R                  5       $ )z(Return the aspect of the SubplotDivider.)r\   
get_aspectr   s    r   r   Grid.get_aspect   s    }}''))r   c                    [         R                  " / SQUS9  US:X  a  g[        R                  " U R                  U R
                  5       GH)  u  p# U R                  U   U   n[        UR                  [        5      (       aI  [        UR                  SUR                  S   5      n[        UR                  SUR                  S   5      nOUR                  S   nUR                  S   nUS:X  a  X R                  S-
  :H  O$US	:X  a  X R                  S-
  :H  =(       a    US
:H  OSnUS:X  a  US
:H  O$US	:X  a  X R                  S-
  :H  =(       a    US
:H  OSnUR                  XwS9  UR                  XS9  GM,     g! [         a     GM=  f = f)ah  
Define which axes have tick labels.

Parameters
----------
mode : {"L", "1", "all", "keep"}
    The label mode:

    - "L": All axes on the left column get vertical tick labels;
      all axes on the bottom row get horizontal tick labels.
    - "1": Only the bottom left axes is labelled.
    - "all": All axes are labelled.
    - "keep": Do not do anything.
)allr3   1keep)moder   Nr   bottomleftr3   r   r   T)
ticklabelslabel)r   rS   rO   ndindexrJ   rK   rg   
IndexErrorrV   axisr   r   xaxisspinesyaxistoggle)	r   r   ru   jrw   bottom_axis	left_axisdisplay_at_bottomdisplay_at_lefts	            r   rm   Grid.set_label_mode   sb    	44@6>JJt{{DKK8DA]]1%a( "'':...rxxBIIh<OP,RXXq"))F:KL	 ggh/GGFO	9=kkAo!5DHCKkkAo!5!@!q&!%  *.qAvBF#+qKK!O3>Q#  *;UO% 9  s   E99
FFc                     U R                   $ r   )r\   r   s    r   get_dividerGrid.get_divider  s    }}r   c                 :    U R                   R                  U5        g r   )r\   set_locator)r   locators     r   r   Grid.set_axes_locator  s    !!'*r   c                 6    U R                   R                  5       $ r   )r\   get_locatorr   s    r   get_axes_locatorGrid.get_axes_locator  s    }}((**r   )
rT   r\   rQ   rK   rJ   rR   rf   ri   rj   rg   Nr=   g{Gz?)r'   r(   r)   r*   __doc__r   rU   r   rename_parameterr   rk   rc   propertyr2   
deprecatedr1   r   r   r   r   r   r   r   rm   r   r   r   r+    r   r   r/   r/      s    < 	68X6  o( ! o( 7o(bW 56F__V$X.M%NOF" (
5
0)*$PL++r   r/   c                   T   ^  \ rS rSrSr   SSSSSSSSSSS	.	U 4S
 jjjrS rSrU =r$ )	ImageGridi   a:  
A grid of Axes for Image display.

This class is a specialization of `~.axes_grid1.axes_grid.Grid` for displaying a
grid of images.  In particular, it forces all axes in a column to share their x-axis
and all axes in a row to share their y-axis.  It further provides helpers to add
colorbars to some or all axes.
NFTr3   rightz5%)	r4   r9   r7   	cbar_modecbar_locationcbar_pad	cbar_sizecbar_set_caxr8   c       	           > [         R                  " / SQU
S9  [         R                  " / SQUS9  Xl        Xl        Xl        Xl        [        TU ]  XX4XVUSSUXS9  U R                   H  nUR                  U5        M     U(       a  U R                  S:X  a(  U R                   H  nU R                  S   Ul        M     gU R                  S	:X  an  [        U R                  5       HT  u  nnU R                  U5      u  nnU R                  S
;   a  U R                  U   Ul        M@  U R                  U   Ul        MV     g[        U R                  U R                  5       H  u  nnUUl        M     gg)a 	  
Parameters
----------
fig : `.Figure`
    The parent figure.
rect : (float, float, float, float) or int
    The axes position, as a ``(left, bottom, width, height)`` tuple or
    as a three-digit subplot position code (e.g., "121").
nrows_ncols : (int, int)
    Number of rows and columns in the grid.
n_axes : int, optional
    If given, only the first *n_axes* axes in the grid are created.
direction : {"row", "column"}, default: "row"
    Whether axes are created in row-major ("row by row") or
    column-major order ("column by column").  This also affects the
    order in which axes are accessed using indexing (``grid[index]``).
axes_pad : float or (float, float), default: 0.02in
    Padding or (horizontal padding, vertical padding) between axes, in
    inches.
share_all : bool, default: False
    Whether all axes share their x- and y-axis.  Note that in any case,
    all axes in a column share their x-axis and all axes in a row share
    their y-axis.
aspect : bool, default: True
    Whether the axes aspect ratio follows the aspect ratio of the data
    limits.
label_mode : {"L", "1", "all"}, default: "L"
    Determines which axes will get tick labels:

    - "L": All axes on the left column get vertical tick labels;
      all axes on the bottom row get horizontal tick labels.
    - "1": Only the bottom left axes is labelled.
    - "all": all axes are labelled.

cbar_mode : {"each", "single", "edge", None}, default: None
    Whether to create a colorbar for "each" axes, a "single" colorbar
    for the entire grid, colorbars only for axes on the "edge"
    determined by *cbar_location*, or no colorbars.  The colorbars are
    stored in the :attr:`!cbar_axes` attribute.
cbar_location : {"left", "right", "bottom", "top"}, default: "right"
cbar_pad : float, default: None
    Padding between the image axes and the colorbar axes.

    .. versionchanged:: 3.10
        ``cbar_mode="single"`` no longer adds *axes_pad* between the axes
        and the colorbar if the *cbar_location* is "left" or "bottom".

cbar_size : size specification (see `!.Size.from_any`), default: "5%"
    Colorbar size.
cbar_set_cax : bool, default: True
    If True, each axes in the grid has a *cax* attribute that is bound
    to associated *cbar_axes*.
axes_class : subclass of `matplotlib.axes.Axes`, default: `.mpl_axes.Axes`
)eachsingleedgeN)r   )r   r   r   top)r   T)r>   rq   r4   r5   r6   r9   r7   r8   r   r   r   r   r   N)r   rS   _colorbar_mode_colorbar_location_colorbar_pad_colorbar_sizer   r   	cbar_axesrl   rf   r    	enumeraterc   zip)r   rn   ro   rp   r2   r>   rq   r4   r9   r7   r   r   r   r   r   r8   rw   indexrv   r=   r    r   s                        r   r   ImageGrid.__init__*  sO   N 	;%.	0=)6	8'"/%' 	{tF!	 	 	: ..BLL ! ""h.--B!^^A.BF ($$.!*4==!9IE2#007HC..2CC!%!4!%!4 ":  #4==$..AGB BF  B r   c           	      B   U R                   cG  U R                  S;   a  U R                  R                  U l         OU R                  R                  U l         [        U R                  5       Vs/ s HZ  n[        U R                  5      " U R                  S   R                  SS9U R                  R                  5       U R                  S9PM\     snU l        U R                  nU R                  n/ n/ n/ n/ nUS:X  Ga  US;   Ga  US:X  a  U R                  [         R"                  " U R$                  5      -  nUR'                  [         R(                  " U R*                  U5      5        UR'                  [         R(                  " U R                   U5      5        U R                  R-                  SSS	S
9n	OUS:X  a  U R.                  [         R0                  " U R$                  5      -  nUR'                  [         R(                  " U R*                  U5      5        UR'                  [         R(                  " U R                   U5      5        U R                  R-                  SS	SS9n	[        U R                  5       H!  n
U R                  U
   R3                  S5        M#     U R                  S   R5                  W	5        U R                  S   R3                  S5        [7        U R8                  S   5       GH  u  pUS:w  a  UR'                  U R                  5        U(       a$  [         R"                  " USU R                  S   S9nO0[         R"                  " U R                  S   SU R                  S   S9nUS:X  a  US:X  d  US:X  a  US:X  az  UR'                  [;        U5      5        UR'                  [         R(                  " U R*                  U5      5        UR'                  [         R(                  " U R                   U5      5        UR'                  [;        U5      5        UR'                  U5        US:X  d  GMH  US:X  d  US:X  d  GMW  XR.                  S-
  :X  d  GMl  UR'                  [         R(                  " U R                   U5      5        UR'                  [;        U5      5        UR'                  [         R(                  " U R*                  U5      5        GM     / n/ n[7        U R<                  S   S S S	2   5       GH  u  pUS:w  a  UR'                  U R                  5        U(       a$  [         R0                  " USU R                  S   S9nO0[         R0                  " U R                  S   SU R                  S   S9nUS:X  a  US:X  d  US:X  a  US:X  az  UR'                  [;        U5      5        UR'                  [         R(                  " U R*                  U5      5        UR'                  [         R(                  " U R                   U5      5        UR'                  [;        U5      5        UR'                  U5        US:X  d  GMH  US:X  d  US:X  d  GMW  XR                  S-
  :X  d  GMl  UR'                  [         R(                  " U R                   U5      5        UR'                  [;        U5      5        UR'                  [         R(                  " U R*                  U5      5        GM     [        U R                  5       GH  n
U R?                  U
5      u  pU R                  R-                  Xk   XR                  S-
  U-
     S9n	U R                  U
   R5                  U	5        US:X  a  US;   a/  U R                  R-                  X{   XR                  S-
  U-
     S9n	O4US;   a.  U R                  R-                  Xk   XR                  S-
  U-
     S9n	U R                  U
   R5                  U	5        M  US:X  d  M  US:X  a  US:X  d  US:X  ab  XR.                  S-
  :X  aP  U R                  R-                  US   XR                  S-
  U-
     S9n	U R                  U   R5                  U	5        GMn  US:X  a  XR                  S-
  :X  d  US:X  d  GM  US:X  d  GM  U R                  R-                  Xk   US   S9n	U R                  U   R5                  U	5        GM     US:X  Ga  US:X  a  U R                  [         R"                  " U R$                  5      -  nUR'                  [         R(                  " U R                   U5      5        UR'                  [         R(                  " U R*                  U5      5        U R                  R-                  SSS	S
9n	OUS:X  a  U R.                  [         R0                  " U R$                  5      -  nUR'                  [         R(                  " U R                   U5      5        UR'                  [         R(                  " U R*                  U5      5        U R                  R-                  SS	SS9n	US;   av  [        U R                  5       H!  n
U R                  U
   R3                  S5        M#     U R                  S   R5                  W	5        U R                  S   R3                  S5        GO.US:X  a;  [        U R                  5       H!  n
U R                  U
   R3                  S5        M#     OUS:X  a  US;   a  U R                  nOU R.                  n[        U5       H!  n
U R                  U
   R3                  S5        M#     [        W
S-   U R                  5       H!  nU R                  U   R3                  S5        M#     OY[        U R                  5       H@  n
U R                  U
   R3                  S5        U R                  U
   RA                  / SQSS9  MB     U R                  RC                  U5        U R                  RE                  U5        g s  snf )Nr   r   Fr   r&   r   )r   r   r   rI   )r{   r|   ny1r   )r{   nx1r|   Taxes)r9   ref_axr   r   r   r   r   rz   )r   r   )r   r   )r   r   )      ?r   MbP?r   active)which)#r   r   rQ   r   rR   rb   r2   _cbaraxes_class_factoryrU   rf   r"   r\   r_   r   r   rJ   r	   AxesXrj   appendfrom_anyr   r   rK   AxesYset_visibler   r   rg   r]   ri   rc   set_positionr}   r   )r   _cb_modecb_locationhvh_ax_posh_cb_posszr   ru   rv   rw   v_ax_posv_cb_posr=   countr   s                     r   rk   ImageGrid._init_locators  s	    %&&*;;%)%9%9%D%D"%)%8%8%C%C"
 4;;'	) ( $D$:$:;a +++79S9S9U 335 (	) %%--h;2D#Df$[[4::dmm#<<t':':B?@t'9'92>?--33qQB3G([[4::dmm#<<t':':B?@t'9'92>?--33qbQ3G4;;'q!--e4 (NN1..w7NN1))$/ q!12GCax--.ZZ6$--:JKZZa 0'-dmmA6FH v% F*$.3!8A't':':B?@t'9'92>?OOCF#HHRLw& F*$.3++/3It'9'92>?A't':':B?@3 36  !1!1!!4TrT!:;GCax,,-ZZ6$--:JKZZa 0'-dmmA6FH x' F*$.3!8A't':':B?@t'9'92>?OOCF#HHRLu$ F*$.3++/3It'9'92>?A't':':B?@3 <6 t{{#A((+HCmm//8=3;KKM#<M3N 0 PGMM!--g6& "33"mm77#=XkkAo6K-L 8 NG !$55"mm77#=XkkAo6K-L 8 NG q!227;F"6)cQh&'1c[[1_6L"mm77#A;8KK!Oc4I+J 8 LGNN3'88A!X-#q2H$-#("mm778=;CA; 8 HGNN3'88A5 $8 hg%[[4::dmm#<<t'9'92>?t':':B?@--33raR3H%[[4::dmm#<<t'9'92>?t':':B?@--33qbR3H..t{{+ANN1%11%8 ,q!227;q!--d34;;'q!--d3 (//5\q!--d3 "1q5$++.q!--e4 / 4;;'q!--e4q!../E5= / ? (
 	$$Q'""1%k)s   ,A!p)r   r   r   r   r   r   )	r'   r(   r)   r*   r   r   rk   r+   r,   r-   s   @r   r   r      sO      g! !&" g! g!R^& ^&r   r   )numbersr   rY   typesr   numpyrO   
matplotlibr   r   matplotlib.gridspecr   axes_dividerr	   r
   r   mpl_axesr   r   r   _make_class_factoryr   r/   r   AxesGridr   r   r   <module>r     sd        " + 7 7 ,E E  33L(K B+ B+JQ& Q&h r   