
    \cgHW                         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       \/var/www/html/bid-api/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	 	 	 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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.
    ngrids : int
        Number of Axes in the grid.
    NFTL)	share_allshare_xshare_y
label_mode
axes_classaspectc                   |\  | _         | _        || 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 || _        nOt3        |      d	k(  rt/        |g|i || _        n,t3        |      d
k(  rt5        ||fi || _        nt7        d      | j0                  j9                         }t        j:                  | j                   | j                  fdt<              }t?        | j                        D ]G  }| jA                  |      \  }}|r|d   x}}n|r|d|f   nd}|	r||df   nd} |||||      |||f<   I |jC                  | j                  dk(  rdnd      jE                         | _#        |jH                  jE                         | _%        |jE                         | _&        | jJ                  d   d   | _'        | jQ                          | jF                  D ]  }|jS                  |        | jU                  |
       y)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   columnrow)	direction)
horizontalverticalr0         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_ncolsrD   r5   axes_padr+   r,   r-   r.   r/   r0   clsr   kw
axes_arrayicolr4   r;   r<   axs                          r   r   zGrid.__init__<   s   r $/ T[>[[4;;.Fv:t{{!:: MO O ; MO O 47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
t{{#A((+HC",T"22/6AsF+D/6CF+D#-T&$9JsCx  $ #((E1#s ) <<BFH 	%<<..0"))+((+B/--BLL   	J'r   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   r2   nxny)rT   set_horizontalr	   ScaledrI   rB   set_verticalrJ   rA   rZ   rD   r[   r^   set_axes_locatornew_locator)r   rm   rn   r4   s       r   rc   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{{#A((+HCMM!--))QWdkkAoPS>S9T)UW $r   c                     | j                   dk(  rt        || j                        \  }}||fS t        || j                        \  }}||fS )Nr3   )rL   divmodrA   rB   )r   nrn   r4   s       r   r[   zGrid._get_col_row   sL    ??h&a-HC Cx a-HCCxr   c                 ,    t        | j                        S r   )rU   r^   r   s    r   __len__zGrid.__len__   s    4==!!r   c                      | j                   |   S r   )r^   )r   rm   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).
        )rA   rB   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rI   
fixed_sizerJ   )r   ri   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)rT   
set_aspect)r   r0   s     r   r   zGrid.set_aspect   s      (r   c                 6    | j                   j                         S )z(Return the aspect of the SubplotDivider.)rT   
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yt        | j                        D ]  }t        | j
                        D ]  }| j                  |   |   }t        |j                  t              rIt        |j                  d|j                  d
         }	t        |j                  d|j                  d         }
n|j                  d
   }	|j                  d   }
|	j!                  |||f   |||f          |
j!                  |||f   |||f            y)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   rK   rG   mgridrA   rB   rX   rZ   ra   rN   axisr   r   xaxisspinesyaxistoggle)r   r   is_last_rowis_first_colr   r   rm   jro   bottom_axis	left_axiss              r   re   zGrid.set_label_mode   s    	44@HH\dkk\<DKK</0t{{Q6G5HA3%4PP 	"\5=GGT[[$++$>EEFTS[ FDS[',66FTt{{#A4;;']]1%a(bggz2"2288Q		(@S"TK 01bii>O PI"$''("3K "I""fQTl&A,"O  DAJd1a4j I ( $r   c                     | j                   S r   )rT   r}   s    r   get_dividerzGrid.get_divider  s    }}r   c                 :    | j                   j                  |       y r   )rT   set_locator)r   locators     r   rw   zGrid.set_axes_locator  s    !!'*r   c                 6    | j                   j                         S r   )rT   get_locatorr}   s    r   get_axes_locatorzGrid.get_axes_locator  s    }}((**r   Nr4   g{Gz?)r#   r$   r%   __doc__r   rM   r   rc   r[   r~   r   r   r   r   r   r   re   r   rw   r    r   r   r)   r)      s    < 
  q( ! q(fW" (
5
0)*%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.
    NFTr*   rightz5%)	r+   r0   r.   	cbar_modecbar_locationcbar_pad	cbar_sizecbar_set_caxr/   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.
        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)r5   ri   r+   r,   r-   r0   r.   r/   r   r   r   r   r   N)r   rK   _colorbar_mode_colorbar_location_colorbar_pad_colorbar_sizer   r   	cbar_axesrd   r^   r   	enumerater[   zip)r   rf   rg   rh   rD   r5   ri   r+   r0   r.   r   r   r   r   r   r/   ro   indexrn   r4   r   r   s                        r   r   zImageGrid.__init__)  s_   N 	;%.	0=)6	8'"/%' 	{F(tF!j	 	 	: ..BLL ! ""h.--B!^^A.BF ($$.!*4==!9IE2#007HC..2CC!%!4!%!4 ":  #4==$..AGB BF  B 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   r@   )rr   rs   ny1r   )rr   nx1rs   Taxes)r0   ref_axr   r   r   r   r   rq   )r   r   )r   r   )r   r   )      ?r   MbP?r   active)which)#r   r   rI   r   rJ   rZ   rD   _cbaraxes_class_factoryrM   r^   r    rT   rW   r   r   rA   r	   AxesXrb   appendfrom_anyr   rx   rB   AxesYset_visiblerw   r   ra   rU   r`   r[   set_positionrt   rv   )r   _cb_modecb_locationhvh_ax_posh_cb_posszr   rm   rn   ro   v_ax_posv_cb_posr4   countr   s                     r   rc   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;;'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//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 $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$o*r   )r#   r$   r%   r   r   rc   r&   r'   s   @r   r   r     sC      g! !&" g!R^&r   r   )numbersr   rQ   typesr   numpyrG   
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 A+ A+HQ& Q&h r   