
    ^jgX                         d dl mZ d dlZd dlmZ d dlZd dlmZm	Z	 d dl
mZ ddlmZmZmZ ddlmZmZ  G d	 d
      Z e	j(                  ed      Z G d d      Z G d de      ZeZy)    )NumberN)
MethodType)_apicbook)SubplotSpec   )SizeSubplotDividerDivider)AxesSimpleAxisArtistc                   $     e Zd Z fdZd Z xZS )CbarAxesBasec                2    || _         t        |   |i | y N)orientationsuper__init__)selfr   argskwargs	__class__s       l/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/mpl_toolkits/axes_grid1/axes_grid.pyr   zCbarAxesBase.__init__   s    &$)&)    c                 b     | j                  d      j                  |f| | j                  d|S )NFroot)caxlocation)
get_figurecolorbarr   )r   mappabler   s      r   r!   zCbarAxesBase.colorbar   sA    3tE*33E)9)9E=CE 	Er   )__name__
__module____qualname__r   r!   __classcell__r   s   @r   r   r      s    *Er   r   zCbar{}c            	           e Zd ZdZeZ ej                  ddd      	 	 	 dddddddd	d
       Zd Z	d Z
 ed       Z  ej                  d       ed             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)GridaL  
    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                V   |\  | _         | _        || j                   | j                  z  }n9d|cxk  r&| j                   | j                  z  k  st        d       t        d      t        t        j
                  t        j                  |d            \  | _        | _	        t        j                  ddg|       || _        || j                  }n1t        |t        t         f      r|\  }}t#        j$                  |fi |}t'        g g |      }t        |t(        t*        f      rt-        ||fi || _        nOt1        |      d	k(  rt-        |g|i || _        n,t1        |      d
k(  rt3        ||fi || _        nt5        d      | j.                  j7                         }t        j8                  | j                   | j                  fdt:              }t=        |      D ]G  }| j?                  |      \  }}|r|d   x}}n|r|d|f   nd}|	r||df   nd} |||||      |||f<   I |jA                  | j                  dk(  rdnd      jC                         d| | _"        |D cg c]  }|D cg c]  }|s|	 c} c}}| _#        |jH                  D cg c]  }|D cg c]  }|s|	 c} c}}| _%        | jJ                  d   d   | _&        | jO                          | jD                  D ]  }|jQ                  |        | jS                  |
       yc c}w c c}}w c c}w c c}}w )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verticalr2         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_ncolsr+   r7   axes_padr-   r.   r/   r0   r1   r2   clsr   kw
axes_arrayicolr6   r=   r>   axs                          r   r   zGrid.__init__<   s   t $/ T[>[[4;;.Fv:t{{!:: MO O ; MO O 58JJ!4561d1 	He,	B#//J
T5M2$KC"**39&9JR"V<dV[12*3;;DMY!^*3<<<DMY!^#C44DM344}}))+WWdkk4;;7VL
v 	9A((+HC",T"22/6AsF+D/6CF+D#-T&$9JsCx 	9 #((E1#s ) <<BFHWfN=GHcs1b"1H@JM#4BR4M((+B/-- 	BLL	 	J' 2H4Ms<   %	L.L6L:L	L% L (L ,L%L L%c           	         | j                   j                  t        j                  d      | j                  g| j
                  dz
  z  t        j                  d      gz          | j                   j                  t        j                  d      | j                  g| j                  dz
  z  t        j                  d      gz          t        | j                        D ]e  }| j                  |      \  }}| j                  |   j                  | j                   j                  d|z  d| j                  dz
  |z
  z               g y )Nr   r4   nxny)rU   set_horizontalr	   ScaledrJ   rD   set_verticalrK   rC   r[   r+   r\   r_   set_axes_locatornew_locator)r   rn   ro   r6   s       r   rd   zGrid._init_locators   s   $$[[^T112dkk!mDTUGWW	Y""[[^T001T[[]Ct{{ST~FVV	Xt{{# 	WA((+HCMM!--))QWdkkAoPS>S9T)UW	Wr   c                     | j                   dk(  rt        || j                        \  }}||fS t        || j                        \  }}||fS )Nr5   )rM   divmodrC   rD   )r   nro   r6   s       r   r\   zGrid._get_col_row   sL    ??h&a-HC Cx a-HCCxr   c                 ,    t        | j                        S r   rV   r_   r   s    r   <lambda>zGrid.<lambda>   s    3t}}#5 r   c                 ,    t        | j                        S r   r~   r   s    r   r   zGrid.<lambda>   s    3t}};M r   c                 ,    t        | j                        S r   r~   r   s    r   __len__zGrid.__len__   s    4==!!r   c                      | j                   |   S r   )r_   )r   rn   s     r   __getitem__zGrid.__getitem__   s    }}Qr   c                 2    | j                   | j                  fS )zV
        Return the number of rows and columns of the grid as (nrows, ncols).
        )rC   rD   r   s    r   get_geometryzGrid.get_geometry   s     {{DKK''r   c                 T    |d   | j                   _        |d   | j                  _        y)z
        Set the padding between the axes.

        Parameters
        ----------
        axes_pad : (float, float)
            The padding (horizontal pad, vertical pad) in inches.
        r   r   NrJ   
fixed_sizerK   )r   rj   s     r   set_axes_padzGrid.set_axes_pad   s(     +31+')1!&r   c                 Z    | j                   j                  | j                  j                  fS )z
        Return the axes padding.

        Returns
        -------
        hpad, vpad
            Padding (horizontal pad, vertical pad) in inches.
        r   r   s    r   get_axes_padzGrid.get_axes_pad   s,     $$//##..0 	0r   c                 :    | j                   j                  |       y)z%Set the aspect of the SubplotDivider.N)rU   
set_aspect)r   r2   s     r   r   zGrid.set_aspect   s      (r   c                 6    | j                   j                         S )z(Return the aspect of the SubplotDivider.)rU   
get_aspectr   s    r   r   zGrid.get_aspect   s    }}''))r   c                     t        j                  g d|       |dk(  ryt        j                  | j                  | j
                        D ]!  \  }}	 | j                  |   |   }t        |j                  t              rIt        |j                  d|j                  d         }t        |j                  d|j                  d         }n|j                  d   }|j                  d   }|dk(  r|| j                  dz
  k(  n|d	k(  r|| j                  dz
  k(  xr |d
k(  nd}|dk(  r|d
k(  n|d	k(  r|| j                  dz
  k(  xr |d
k(  nd}|j                  ||       |j                  ||       $ y# t        $ r Y 2w xY w)a  
        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.
        )allr,   1keep)moder   Nr   bottomleftr,   r   r   T)
ticklabelslabel)r   rL   rH   ndindexrC   rD   r`   
IndexErrorrO   axisr   r   xaxisspinesyaxistoggle)	r   r   rn   jrp   bottom_axis	left_axisdisplay_at_bottomdisplay_at_lefts	            r   rf   zGrid.set_label_mode   sq    	44@6>JJt{{DKK8 	PDAq]]1%a( "'':..rxxBIIh<OP,RXXq"))F:KL	 ggh/GGFO	9=dkkAo!5DHCKdkkAo!5!@!q&!%  *.qAvBF#+qDKK!O3>Q#  *;CTUO%	P  s   E00	E=<E=c                     | j                   S r   )rU   r   s    r   get_dividerzGrid.get_divider  s    }}r   c                 :    | j                   j                  |       y r   )rU   set_locator)r   locators     r   rx   zGrid.set_axes_locator  s    !!'*r   c                 6    | j                   j                         S r   )rU   get_locatorr   s    r   get_axes_locatorzGrid.get_axes_locator  s    }}((**r   Nr6   g{Gz?)r#   r$   r%   __doc__r   rN   r   rename_parameterr   rd   r\   propertyr+   
deprecatedr*   r   r   r   r   r   r   r   rf   r   rx   r    r   r   r)   r)      s    < T68X6  o( ! o( 7o(bW 56F$_T__V$X.M%NOF" (
5
0)*$PL++r   r)   c                   F     e Zd ZdZ	 	 	 ddddddddddd	 fd	Zd
 Z xZS )	ImageGridaR  
    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.
    NFTr,   rightz5%)	r-   r2   r0   	cbar_modecbar_locationcbar_pad	cbar_sizecbar_set_caxr1   c       	            t        j                  g d|
       t        j                  g d|       |
| _        || _        || _        || _        t        |   |||||||dd||	|       | j                  D ]  }|j                  |        |r| j                  dk(  r&| j                  D ]  }| j                  d   |_         y| j                  d	k(  rit        | j                        D ]P  \  }}| j                  |      \  }}| j                  d
v r| j                  |   |_        =| j                  |   |_        R yt        | j                  | j                        D ]  \  }}||_         yy)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)r7   rj   r-   r.   r/   r2   r0   r1   r   r   r   r   r   N)r   rL   _colorbar_mode_colorbar_location_colorbar_pad_colorbar_sizer   r   	cbar_axesre   r_   r   	enumerater\   zip)r   rg   rh   ri   r+   r7   rj   r-   r2   r0   r   r   r   r   r   r1   rp   indexro   r6   r   r   s                        r   r   zImageGrid.__init__*  sr   N 	;%.	0=)6	8'"/%' 	{F(tF!j	 	 	: .. 	BLL	 ""h.-- /B!^^A.BF/$$.!*4==!9 5IE2#007HC..2CC!%!4!%!45  #4==$..A !GB BF! r   c                    | j                   E| j                  dv r| j                  j                  | _         n| j                  j                  | _         t        | j                        D cg c]_  } t        | j                        | j                  d   j                  d      | j                  j                         | j                        a c}| _        | j                  }| j                  }g }g }g }g }|dk(  r|dv r|dk(  r| j                  t!        j"                  | j$                        z  }|j'                  t!        j(                  | j*                  |             |j'                  t!        j(                  | j                   |             | j                  j-                  ddd	
      }	n|dk(  r| j.                  t!        j0                  | j$                        z  }|j'                  t!        j(                  | j*                  |             |j'                  t!        j(                  | j                   |             | j                  j-                  dd	d      }	t        | j                        D ]   }
| j                  |
   j3                  d       " | j                  d   j5                  	       | j                  d   j3                  d       t7        | j8                  d         D ]  \  }}|dk7  r|j'                  | j                         |r&t!        j"                  |d| j                  d         }n2t!        j"                  | j                  d   d| j                  d         }|dk(  r|dk(  s
|dk(  r}|dk(  rx|j'                  t;        |             |j'                  t!        j(                  | j*                  |             |j'                  t!        j(                  | j                   |             |j'                  t;        |             |j'                  |       |dk(  s?|dk(  s|dk(  sK|| j.                  dz
  k(  s_|j'                  t!        j(                  | j                   |             |j'                  t;        |             |j'                  t!        j(                  | j*                  |              g }g }t7        | j<                  d   d d d	         D ]  \  }}|dk7  r|j'                  | j                         |r&t!        j0                  |d| j                  d         }n2t!        j0                  | j                  d   d| j                  d         }|dk(  r|dk(  s
|dk(  r}|dk(  rx|j'                  t;        |             |j'                  t!        j(                  | j*                  |             |j'                  t!        j(                  | j                   |             |j'                  t;        |             |j'                  |       |dk(  s?|dk(  s|dk(  sK|| j                  dz
  k(  s_|j'                  t!        j(                  | j                   |             |j'                  t;        |             |j'                  t!        j(                  | j*                  |              t        | j                        D ]  }
| j?                  |
      \  }}| j                  j-                  ||   || j                  dz
  |z
           }	| j                  |
   j5                  |	       |dk(  r|dv r4| j                  j-                  ||   || j                  dz
  |z
           }	n7|dv r3| j                  j-                  ||   || j                  dz
  |z
           }	| j                  |
   j5                  |	       |dk(  s|dk(  r|dk(  s|dk(  re|| j.                  dz
  k(  rS| j                  j-                  |d   || j                  dz
  |z
           }	| j                  |   j5                  |	       w|dk(  r|| j                  dz
  k(  s|dk(  s|dk(  s| j                  j-                  ||   |d         }	| j                  |   j5                  |	        |dk(  r|dk(  r| j                  t!        j"                  | j$                        z  }|j'                  t!        j(                  | j                   |             |j'                  t!        j(                  | j*                  |             | j                  j-                  ddd	
      }	n|dk(  r| j.                  t!        j0                  | j$                        z  }|j'                  t!        j(                  | j                   |             |j'                  t!        j(                  | j*                  |             | j                  j-                  dd	d      }	|dv rt        | j                        D ]   }
| j                  |
   j3                  d       " | j                  d   j5                  	       | j                  d   j3                  d       n%|dk(  r9t        | j                        D ]   }
| j                  |
   j3                  d       " n|dk(  r|dv r| j                  }n| j.                  }t        |      D ]   }
| j                  |
   j3                  d       " t        
dz   | j                        D ]   }| j                  |   j3                  d       " nZt        | j                        D ]B  }
| j                  |
   j3                  d       | j                  |
   jA                  g dd       D | j                  jC                  |       | j                  jE                  |       y c c}w )Nr   r   Fr   )r   r   )r   r   r   rB   )rs   rt   ny1r   )rs   nx1rt   Taxes)r2   ref_axr   r   r   r   r   rr   )r   r   )r   r   )r   r   )      ?r   MbP?r   active)which)#r   r   rJ   r   rK   r[   r+   _cbaraxes_class_factoryrN   r_   r    rU   rX   r   r   rC   r	   AxesXrc   appendfrom_anyr   ry   rD   AxesYset_visiblerx   r   r`   rV   rb   r\   set_positionru   rw   )r   _cb_modecb_locationhvh_ax_posh_cb_posszr   rn   ro   rp   v_ax_posv_cb_posr6   countr   s                     r   rd   z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;;' 5q!--e45NN1..w7NN1))$/ q!12 	AGC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	A6  !1!1!!4TrT!:; 	A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	A6 t{{# 	BA((+HCmm//8C=3;DKKM#<M3N 0 PGMM!--g6& "33"mm77#C=XdkkAo6K-L 8 NG !$55"mm77#C=XdkkAo6K-L 8 NG q!227;F"6)cQh&'1cT[[1_6L"mm77#A;8DKK!Oc4I+J 8 LGNN3'88A!X-#q2H$-#("mm778C=;CA; 8 HGNN3'88A5	B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{{+ 9ANN1%11%89q!227;q!--d34;;' 4q!--d34//5\ 4q!--d341q5$++. 5q!--e45 4;;' ?q!--e4q!../E5= / ??
 	$$Q'""1%k)s   )A$o*r   )r#   r$   r%   r   r   rd   r&   r'   s   @r   r   r      sC      g! !&" g!R^&r   r   )numbersr   rR   typesr   numpyrH   
matplotlibr   r   matplotlib.gridspecr   axes_dividerr	   r
   r   mpl_axesr   r   r   _make_class_factoryr   r)   r   AxesGridr   r   r   <module>r      sf        " + 7 7 ,E E 4%33L(K B+ B+JQ& Q&h r   