
    P/PhHW                         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dS )    )NumberN)
MethodType)_apicbook)SubplotSpec   )SizeSubplotDividerDivider)AxesSimpleAxisArtistc                   $     e Zd Z fdZd Z xZS )CbarAxesBasec                H    || _          t                      j        |i | d S N)orientationsuper__init__)selfr   argskwargs	__class__s       a/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mpl_toolkits/axes_grid1/axes_grid.pyr   zCbarAxesBase.__init__   s-    &$)&)))))    c                 V     |                      d          j        |f| | j        d|S )NFroot)caxlocation)
get_figurecolorbarr   )r   mappabler   s      r   r!   zCbarAxesBase.colorbar   sJ    3tE**3E)9E E=CE E 	Er   )__name__
__module____qualname__r   r!   __classcell__r   s   @r   r   r      sN        * * * * *E E E E E E Er   r   zCbar{}c                       e Zd ZdZeZ	 	 	 ddddddddd	Zd
 Zd Zd Z	d Z
d Zd Zd Zd Zd Zd Zd Zd Zd ZdS )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.
    ngrids : int
        Number of Axes in the grid.
    Nrow{Gz?FTL)	share_allshare_xshare_y
label_mode
axes_classaspectc                   |\  | _         | _        || j         | j        z  }n+d|cxk     r| j         | j        z  k    sn t          d          || _        t	          t
          j        t          j        |d                    \  | _	        | _
        t          j        ddg|           || _        || j        }n3t          |t           t"          f          r|\  }}t%          j        |fi |}t)          g g |          }t          |t*          t,          f          rt/          ||fi || _        n_t3          |          d	k    rt/          |g|R i || _        n6t3          |          d
k    rt5          ||fi || _        nt7          d          | j                                        }t          j        | j         | j        fdt<                    }t?          | j                  D ]W}|                      |          \  }}|r|d         x}}n|r
|d|f         nd}|	r
||df         nd} |||||          |||f<   X|!                    | j        dk    rdnd          "                                | _#        |j$        "                                | _%        |"                                | _&        | j%        d         d         | _'        | (                                 | j#        D ]}|)                    |           | *                    |
           dS )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.
        ngrids : int or None, default: None
            If not None, only the first *ngrids* 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   z7ngrids must be positive and not larger than nrows*ncols   columnr*   )	direction)
horizontalverticalr2         zIncorrect rect format)dtype)r   r   )sharexshareyCF)order)+_nrows_ncols
ValueErrorngrids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Taxes_columnaxes_rowaxes_llc_init_locatorsadd_axesset_label_mode)r   figrectnrows_ncolsrE   r6   axes_padr-   r.   r/   r0   r1   r2   clsr   kw
axes_arrayicolr*   r<   r=   axs                          r   r   zGrid.__init__<   sY   r $/ T[>[4;.FFv::::t{!::::: MO O O 47J!4456 561d1 	He,	BBBB#/JJ
T5M22 	:$KC"*399&99JR"V<<<dV[122 	5*3;;;;DMMYY!^^*3<<<<<<DMMYY!^^#C4444DMM3444}))++Wdk4;7VLLL
t{## 	9 	9A((++HC A",T"22/6@AsF++D/6@CF++D#-:T&$9 $9 $9JsCx  "((E11##s ) < <<BFHH 	%<..00"))++(+B/- 	 	BLLJ'''''r   c           	      J   | j                             t          j        d          | j        g| j        dz
  z  t          j        d          gz              | j                             t          j        d          | j        g| j        dz
  z  t          j        d          gz              t          | j
                  D ]e}|                     |          \  }}| j        |                             | j                             d|z  d| j        dz
  |z
  z                       fd S )Nr   r4   nxny)rU   set_horizontalr	   ScaledrJ   rC   set_verticalrK   rB   r[   rE   r\   r_   set_axes_locatornew_locator)r   rn   ro   r*   s       r   rd   zGrid._init_locators   s-   $$[^^T12dk!mDTUGWW	Y 	Y 	Y""[^^T01T[]Ct{ST~~FVV	X 	X 	Xt{## 	W 	WA((++HCM!--))QWdkAoPS>S9T)UUW W W W	W 	Wr   c                     | j         dk    rt          || j                  \  }}nt          || j                  \  }}||fS )Nr5   )rM   divmodrB   rC   )r   nro   r*   s       r   r\   zGrid._get_col_row   sD    ?h&&a--HCa--HCCxr   c                 *    t          | j                  S r   )rV   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                     | j         | j        fS )zV
        Return the number of rows and columns of the grid as (nrows, ncols).
        )rB   rC   r~   s    r   get_geometryzGrid.get_geometry   s     {DK''r   c                 N    |d         | j         _        |d         | j        _        dS )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                 2    | 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                             |           dS )z%Set the aspect of the SubplotDivider.N)rU   
set_aspect)r   r2   s     r   r   zGrid.set_aspect   s      (((((r   c                 4    | 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|           t          j        d| j        d| j        f         | j        dz
  ggdgggk    \  }}|dk    r$t          j        | j        | j        fd          x}}n|dk    r|}|}n|d	k    r||z  x}}ndS t          | j                  D ]}t          | j                  D ]}| j        |         |         }t          |j
        t                    rCt          |j        d|j        d
                   }	t          |j        d|j        d                   }
n|j
        d
         }	|j
        d         }
|	                    |||f         |||f                    |
                    |||f         |||f                    یdS )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)modeNr   r   r   Tr,   r   bottomleft)
ticklabelslabel)r   rL   rH   mgridrB   rC   rY   r[   rb   rO   axisr   r   xaxisspinesyaxistoggle)r   r   is_last_rowis_first_colr   r   rn   jrp   bottom_axis	left_axiss              r   rf   zGrid.set_label_mode   s    	4444@@@@H\dk\<DK</0t{Q6G5HA3%4PP 	"\5==GT[$+$>EEEFTTS[[ FDDS[[',66FTTFt{## 
	J 
	JA4;'' 	J 	J]1%a(bgz22 0"228Q	(@S"T"TK 01bi>O P PII"$'("3K "I""fQTl&A,"OOO  DAJd1a4j IIII	J
	J 
	Jr   c                     | j         S r   )rU   r~   s    r   get_dividerzGrid.get_divider  s
    }r   c                 :    | j                             |           d S r   )rU   set_locator)r   locators     r   rx   zGrid.set_axes_locator  s    !!'*****r   c                 4    | j                                         S r   )rU   get_locatorr~   s    r   get_axes_locatorzGrid.get_axes_locator  s    }((***r   Nr*   r+   )r#   r$   r%   __doc__r   rN   r   rd   r\   r   r   r   r   r   r   r   rf   r   rx   r    r   r   r)   r)      s4        < 
  q( ! q( q( q( q( q(fW W W  " " "     ( ( (
5 
5 
5
0 
0 
0) ) )* * *%J %J %JN  + + ++ + + + +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.
    Nr*   r+   FTr,   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 ]}|	                    |           |r| j        dk    r| j
        D ]}| j        d         |_        dS | j        d	k    rbt          | j
                  D ]K\  }}|                     |          \  }}| j        d
v r| j        |         |_        9| j        |         |_        LdS t          | j
        | j                  D ]\  }}||_        dS dS )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.
        ngrids : int or None, default: None
            If not None, only the first *ngrids* 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: None
        )eachsingleedgeN)r   )r   r   r   top)r   T)r6   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   rE   r6   rj   r-   r2   r0   r   r   r   r   r   r1   rp   indexro   r*   r   r   s                        r   r   zImageGrid.__init__)  s   N 	;;;%.	0 	0 	0 	0===)6	8 	8 	8 	8'"/%' 	{F(tF!j	 	 	: 	: 	: . 	 	BLL 	!"h..- / /B!^A.BFF/ /$..!*4=!9!9 5 5IE2#0077HC.2CCC!%!4!%!45 5  #4=$.AA ! !GB BFF	! 	!! !r   c                      j         , j        dv r j        j         _         n j        j         _          fdt           j                  D              _         j        } j        }g }g }g }g }|dk    r|dv r|dk    r j	        t          j         j                  z  }|                    t          j         j        |                     |                    t          j         j         |                      j                            ddd          }n|d	k    r j        t          j         j                  z  }|                    t          j         j        |                     |                    t          j         j         |                      j                            ddd
          }t           j                  D ]"}	 j        |	                             d           # j        d                             |            j        d                             d           t-           j        d                   D ]\  }
}|
dk    r|                     j                   |r#t          j        |d j        d                   }n-t          j         j        d         d j        d                   }|dk    r|dk    s|dk    r|
dk    r||                    t3          |                     |                    t          j         j        |                     |                    t          j         j         |                     |                    t3          |                     |                    |           |dk    r|dk    s|dk    r|
 j        dz
  k    r||                    t          j         j         |                     |                    t3          |                     |                    t          j         j        |                     g }g }t-           j        d         d d d                   D ]\  }}|dk    r|                     j                   |r#t          j        |d j        d                   }n-t          j         j        d         d j        d                   }|d	k    r|dk    s|dk    r|dk    r||                    t3          |                     |                    t          j         j        |                     |                    t          j         j         |                     |                    t3          |                     |                    |           |dk    r|dk    s|dk    r| j	        dz
  k    r||                    t          j         j         |                     |                    t3          |                     |                    t          j         j        |                     t           j                  D ]}	                     |	          \  }
} j                            ||
         | j	        dz
  |z
                     } j        |	                             |           |dk    r|dv r4 j                            ||
         | j	        dz
  |z
                     }n7|dv r3 j                            ||
         | j	        dz
  |z
                     } j        |	                             |           |dk    r|dk    r|
dk    s|dk    rc|
 j        dz
  k    rU j                            |d         | j	        dz
  |z
                     } j        |                             |           |d	k    r| j	        dz
  k    s|dk    rN|dk    rH j                            ||
         |d                   } j        |
                             |           |dk    r|dk    r j	        t          j         j                  z  }|                    t          j         j         |                     |                    t          j         j        |                      j                            ddd          }n|dk    r j        t          j         j                  z  }|                    t          j         j         |                     |                    t          j         j        |                      j                            ddd
          }|dv rwt           j                  D ]"}	 j        |	                             d           # j        d                             |            j        d                             d           n |dk    r8t           j                  D ]"}	 j        |	                             d           #n|dk    r|dv r j	        }n j        }t          |          D ]"}	 j        |	                             d           #t          |	dz    j                  D ]"} j        |                             d           #n[t           j                  D ]F}	 j        |	                             d            j        |	                             g dd           G j                            |            j                            |           d S )Nr   c                     g | ]]} t          j                  j        d                              d          j                                        j                  ^S )r   Fr   )r   )_cbaraxes_class_factoryrN   r_   r    rU   rX   r   ).0_r   s     r   
<listcomp>z,ImageGrid._init_locators.<locals>.<listcomp>  sy     ) ) )  <#D$:;;a +++779S9S9U9U 35 5 5) ) )r   r   )r   r   r   r   rA   )rs   rt   ny1r   )rs   nx1rt   FT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[   rE   r   r   rB   r	   AxesXrc   appendfrom_anyr   rU   ry   rC   AxesYset_visiblerx   r   rb   r_   rV   ra   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_posr*   countr   s   `                r   rd   zImageGrid._init_locators  s    %&*;;;%)%9%D""%)%8%C") ) ) ) 4;''	) ) ) %-h;2D#D#Df$$[4:dm#<#<<t':B??@@@t'92>>???-33qQB3GG(([4:dm#<#<<t':B??@@@t'92>>???-33qbQ3GG4;'' 5 5q!--e4444N1..w777N1))$/// q!122 	A 	AGCaxx-... HZ6$-:JKKKZa 0'-dmA6FH H H v%% F**$..3!88A'''t':B??@@@t'92>>???OOCFF###HHRLLLw&& F**$..3$+/3I3It'92>>???A'''t':B??@@@ !1!!4TTrT!:;; 	A 	AGCaxx,--- HZ6$-:JKKKZa 0'-dmA6FH H H x'' F**$..3!88A'''t':B??@@@t'92>>???OOCFF###HHRLLLu$$ F**$..3$+/3I3It'92>>???A'''t':B??@@@t{## 	B 	BA((++HCm//8C=3;DKM#<M3N 0 P PGM!--g666&  "333"m77#C=XdkAo6K-L 8 N NGG !$555"m77#C=XdkAo6K-L 8 N NG q!227;;;;F""6))cQhh&'11cT[1_6L6L"m77#A;8DK!Oc4I+J 8 L LGN3'88AAAA!X--#q2H2H$--#(("m778C=;CA; 8 H HGN3'88AAAhg%%[4:dm#<#<<t'92>>???t':B??@@@-33raR3HH%%[4:dm#<#<<t'92>>???t':B??@@@-33qbR3HH...t{++ 9 9AN1%11%8888q!227;;;q!--d3334;'' 4 4q!--d33334///5\\ 4 4q!--d33331q5$+.. 5 5q!--e44445 4;'' ? ?q!--e444q!../E/E/E5= / ? ? ? ? 	$$Q'''""1%%%%%r   r   )r#   r$   r%   r   r   rd   r&   r'   s   @r   r   r     s           g! !&" g! g! g! g! g! 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      sW                       " " " " " " " " + + + + + + 7 7 7 7 7 7 7 7 7 7 , , , , , , , ,E E E E E E E E 4%3L(KK A+ A+ A+ A+ A+ A+ A+ A+HQ& Q& Q& Q& Q& Q& Q& Q&h r   