
    hZt                         S r SSKrSSKrSSKJr  SSKrSSKrSSKJ	r	J
r
Jr  SSKJr  \R                  " \5      r " S S5      r " S S	\5      r " S
 S\5      r " S S5      r " S S5      rg)a  
:mod:`~matplotlib.gridspec` contains classes that help to layout multiple
`~.axes.Axes` in a grid-like pattern within a figure.

The `GridSpec` specifies the overall grid structure. Individual cells within
the grid are referenced by `SubplotSpec`\s.

Often, users need not access this module directly, and can use higher-level
methods like `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` and
`~.Figure.subfigures`. See the tutorial :ref:`arranging_axes` for a guide.
    N)Integral)_api_pylab_helpers_tight_layout)Bboxc                       \ rS rSrSrSS jrS r\" S SS9r\" S	 S
S9r	S r
SS jrSS jrS rS rS rS rS r\S 5       rS rSSSSS.S jrSrg)GridSpecBase   za
A base class of GridSpec that specifies the geometry of the grid
that a subplot will be placed.
Nc                    [        U[        5      (       a  US::  a  [        SU< 35      e[        U[        5      (       a  US::  a  [        SU< 35      eXsU l        U l        U R                  U5        U R                  U5        g)a7  
Parameters
----------
nrows, ncols : int
    The number of rows and columns of the grid.
width_ratios : array-like of length *ncols*, optional
    Defines the relative widths of the columns. Each column gets a
    relative width of ``width_ratios[i] / sum(width_ratios)``.
    If not given, all columns will have the same width.
height_ratios : array-like of length *nrows*, optional
    Defines the relative heights of the rows. Each row gets a
    relative height of ``height_ratios[i] / sum(height_ratios)``.
    If not given, all rows will have the same height.
r   z/Number of rows must be a positive integer, not z2Number of columns must be a positive integer, not N)
isinstancer   
ValueError_nrows_ncolsset_height_ratiosset_width_ratios)selfnrowsncolsheight_ratioswidth_ratioss        E/var/www/html/env/lib/python3.13/site-packages/matplotlib/gridspec.py__init__GridSpecBase.__init__    s     %**eqjA%KM M%**eqjDUINP P#( T[}-l+    c                 J   [        [        U R                  5      5      S:w  a  SU R                  < 3OSn[        [        U R                  5      5      S:w  a  SU R                  < 3OSnSR	                  U R
                  R                  U R                  U R                  X-   S9$ )N   z, height_ratios= z, width_ratios=z&{clsname}({nrows}, {ncols}{optionals}))clsnamer   r   	optionals)	lenset_row_height_ratios_col_width_ratiosformat	__class____name__r   r   )r   
height_arg	width_args      r   __repr__GridSpecBase.__repr__9   s    S!8!89:a? ))@)@(CDEG 	 C 6 678A= 't'='=&@ACE 	7>>NN++++++ ,	 ?  	r   c                     U R                   $ N)r   r   s    r   <lambda>GridSpecBase.<lambda>E       $++r   zThe number of rows in the grid.)docc                     U R                   $ r,   )r   r-   s    r   r.   r/   G   r0   r   z"The number of columns in the grid.c                 2    U R                   U R                  4$ )zG
Return a tuple containing the number of rows and columns in the grid.
)r   r   r-   s    r   get_geometryGridSpecBase.get_geometryJ   s     {{DKK''r   c                     g r,    )r   figures     r   get_subplot_paramsGridSpecBase.get_subplot_paramsP   s    r   c                 *    Uu  pEXXB-   2XUU-   24   nU$ )a  
Create and return a `.SubplotSpec` instance.

Parameters
----------
loc : (int, int)
    The position of the subplot in the grid as
    ``(row_index, column_index)``.
rowspan, colspan : int, default: 1
    The number of rows and columns the subplot should span in the grid.
r7   )r   locrowspancolspanloc1loc2subplotspecs          r   new_subplotspecGridSpecBase.new_subplotspecT   s,     
,d<.??@r   c                     Uc  S/U R                   -  nO$[        U5      U R                   :w  a  [        S5      eXl        g)z
Set the relative widths of the columns.

*width_ratios* must be of length *ncols*. Each column gets a relative
width of ``width_ratios[i] / sum(width_ratios)``.
Nr   zTExpected the given number of width ratios to match the number of columns of the grid)r   r    r   r#   )r   r   s     r   r   GridSpecBase.set_width_ratiosd   sF     3,L$++- G H H!-r   c                     U R                   $ )zW
Return the width ratios.

This is *None* if no width ratios have been set explicitly.
)r#   r-   s    r   get_width_ratiosGridSpecBase.get_width_ratiosr   s     %%%r   c                     Uc  S/U R                   -  nO$[        U5      U R                   :w  a  [        S5      eXl        g)z
Set the relative heights of the rows.

*height_ratios* must be of length *nrows*. Each row gets a relative
height of ``height_ratios[i] / sum(height_ratios)``.
Nr   zRExpected the given number of height ratios to match the number of rows of the grid)r   r    r   r"   )r   r   s     r   r   GridSpecBase.set_height_ratiosz   sF      C$++-M4;;. D E E"/r   c                     U R                   $ )zY
Return the height ratios.

This is *None* if no height ratios have been set explicitly.
)r"   r-   s    r   get_height_ratiosGridSpecBase.get_height_ratios   s     &&&r   c                    U R                  5       u  p#U R                  U5      nUR                  nUR                  nUR                  nUR
                  nUR                  n	UR                  n
Xe-
  nX-
  nXXS-
  -  -   -  nX-  nX-  [        U R                  5      -  nU R                   Vs/ s H  nUU-  PM
     nnS/U/US-
  -  -   n[        R                  " [        R                  " UU/5      R                  5      nXXS-
  -  -   -  nU	U-  nUU-  [        U R                  5      -  nU R                   Vs/ s H  nUU-  PM
     nnS/U/US-
  -  -   n[        R                  " [        R                  " UU/5      R                  5      nUU-
  R                  S5      R                   u  nnUU-   R                  S5      R                   u  nnUUUU4$ s  snf s  snf )a  
Return the positions of the grid cells in figure coordinates.

Parameters
----------
fig : `~matplotlib.figure.Figure`
    The figure the grid should be applied to. The subplot parameters
    (margins and spacing between subplots) are taken from *fig*.

Returns
-------
bottoms, tops, lefts, rights : array
    The bottom, top, left, right positions of the grid cells in
    figure coordinates.
r   r   )   )r4   r9   leftrightbottomtopwspacehspacesumr"   npcumsumcolumn_stackflatr#   reshapeT)r   figr   r   subplot_paramsrQ   rR   rS   rT   rU   rV   	tot_width
tot_heightcell_hsep_hnormrcell_heightssep_heightscell_hscell_wsep_wcell_widths
sep_widthscell_wsfig_topsfig_bottoms	fig_lefts
fig_rightss                                r   get_grid_positionsGridSpecBase.get_grid_positions   s     ((*005""$$&&  &&&&L	\
 vQw'778~D$;$; <<*.*A*AB*AQD*ABceWa01))BOO[,,GHMMN fAg&667~D$:$: ;;)-)?)?@)?Aq4x)?@SUGuQw/0
))BOOZ,EFKKL!$w 7 7 @ B B+!% 8 8 A C C	:Hi;; C As   ,G:Gc                     U R                  5        H`  nUR                  5       nUc  M  [        US5      (       a  UR                  5       R                  5       nUR	                  5       X4:X  d  M^  Us  $    [        XU S9$ )zW
Check if the figure already has a gridspec with these dimensions,
or create a new one
get_topmost_subplotspecr8   )get_axesget_gridspechasattrru   r4   GridSpec)r8   r   r   axgss        r   _check_gridspec_exists#GridSpecBase._check_gridspec_exists   sr     //#B"B~2899 335BBDB??$6I $ V44r   c                 &   U R                  5       u  p#S n[        U[        5      (       a0   Uu  pV[        R
                  " U" XRS5      U" XcS5      /X#45      u  pOU" XU-  S5      u  p[        XU	5      $ ! [         a  n[        S5      UeSnAff = f)z,Create and return a `.SubplotSpec` instance.c                    U n[        U [        5      (       a*  U R                  U5      u  pEnXT:  a  XES-
  4$ [        S5      eU S:  a  X-   n SU s=::  a	  U:  a   X 4$   Ub  [        SU SU SU 35      e[        SU SU 35      e)Nr   z=GridSpec slice would result in no space allocated for subplotr   zindex z is out of bounds for axis z with size z) is out of bounds for GridSpec with size )r   sliceindices
IndexError)keysizeaxisorig_keystartstop_s          r   
_normalize,GridSpecBase.__getitem__.<locals>._normalize   s    H#u%%!$T!2Q< (?*  "9 : : 7*C?d?8O #%$vhZ 8--1F+dV&E F F %vhZ 8;;?&&B C Cr   zUnrecognized subplot specNr   r   )r4   r   tupler   rX   ravel_multi_indexSubplotSpec)
r   r   r   r   r   k1k2errnum1num2s
             r   __getitem__GridSpecBase.__getitem__   s    ((*	C( c5!!G --Bq):b+CD JD$ $C=JD4t,,  G !<=3FGs   A5 5
B?BBFT)sharexshareysqueeze
subplot_kwc                f   U R                   nUc  [        S5      e[        U[        5      (       d  U(       a  SOSn[        U[        5      (       d  U(       a  SOSn[        R
                  " / SQXS9  Uc  0 nUR                  5       n[        R                  " U R                  U R                  4[        S9n[        U R                  5       H[  n[        U R                  5       H?  nSUS   XgS	4   US	U4   S
.n	X   US'   X   US'   UR                  " XU4   40 UD6XgU4'   MA     M]     US;   a"  UR                   H  n
U
R                  SS9  M     US;   a"  UR                   H  n
U
R!                  SS9  M     U(       a0  UR"                  S:X  a  UR%                  5       $ UR'                  5       $ U$ )zy
Add all subplots specified by this `GridSpec` to its parent figure.

See `.Figure.subplots` for detailed documentation.
NzIGridSpec.subplots() only works for GridSpecs created with a parent figureallnone)r   rowcolr   FT)r   r   )dtype)r   r   r   )r   r   r   r   r   r   )r   r   T)skip_non_rectangular_axes)r   r   r   )r8   r   r   strr   check_in_listcopyrX   emptyr   r   objectrangeadd_subplotr[   _label_outer_xaxis_label_outer_yaxisr   itemr   )r   r   r   r   r   r8   axarrr   r   shared_withr{   s              r   subplotsGridSpecBase.subplots   s    > < = = &#&&$U&F&#&&$U&FE"(	9J__&
 $++t{{36B%CT[[)'+E$K&+FmE!S&MK'2':
8$'2':
8$"("4"4cN#2&0#23h * & ^#jj%%%E !^#jj%%%E !  $)::?5::<GG Lr   )r#   r   r   r"   )NNr,   )r   r   )r&   
__module____qualname____firstlineno____doc__r   r)   propertyr   r   r4   r9   rB   r   rG   r   rL   rr   staticmethodr}   r   r   __static_attributes__r7   r   r   r	   r	      s    
,2
 -:<E-=?E( .&0'-<^ 5 5(#-J "'ud 3 3r   r	   c                   d   ^  \ rS rSrSr    S
U 4S jjr/ SQrS rSS jrS r	  SS jr
S	rU =r$ )rz   i/  z
A grid layout to place subplots within a figure.

The location of the grid cells is determined in a similar way to
`.SubplotParams` using *left*, *right*, *top*, *bottom*, *wspace*
and *hspace*.

Indexing a GridSpec instance returns a `.SubplotSpec`.
c                 x   > X@l         XPl        X`l        Xpl        Xl        Xl        X0l        [        TU ]!  XU
US9  g)a   
Parameters
----------
nrows, ncols : int
    The number of rows and columns of the grid.

figure : `.Figure`, optional
    Only used for constrained layout to create a proper layoutgrid.

left, right, top, bottom : float, optional
    Extent of the subplots as a fraction of figure width or height.
    Left cannot be larger than right, and bottom cannot be larger than
    top. If not given, the values will be inferred from a figure or
    rcParams at draw time. See also `GridSpec.get_subplot_params`.

wspace : float, optional
    The amount of width reserved for space between subplots,
    expressed as a fraction of the average axis width.
    If not given, the values will be inferred from a figure or
    rcParams when necessary. See also `GridSpec.get_subplot_params`.

hspace : float, optional
    The amount of height reserved for space between subplots,
    expressed as a fraction of the average axis height.
    If not given, the values will be inferred from a figure or
    rcParams when necessary. See also `GridSpec.get_subplot_params`.

width_ratios : array-like of length *ncols*, optional
    Defines the relative widths of the columns. Each column gets a
    relative width of ``width_ratios[i] / sum(width_ratios)``.
    If not given, all columns will have the same width.

height_ratios : array-like of length *nrows*, optional
    Defines the relative heights of the rows. Each row gets a
    relative height of ``height_ratios[i] / sum(height_ratios)``.
    If not given, all rows will have the same height.

r   r   N)	rQ   rS   rR   rT   rU   rV   r8   superr   )r   r   r   r8   rQ   rS   rR   rT   rU   rV   r   r   r%   s               r   r   GridSpec.__init__9  sC    T 	
&2'4 	 	6r   rQ   rS   rR   rT   rU   rV   c                 <   UR                  5        H.  u  p#X R                  ;   a  [        XU5        M"  [        U S35      e   [        R
                  R                  R                  5        H  nUR                  R                  R                   H  nUR                  5       c  M  UR                  5       R                  5       nUR                  5       U :X  d  MJ  UR                  SS9nUR                  UR                  5       R!                  U5      5        M     M     g)a  
Update the subplot parameters of the grid.

Parameters that are not explicitly given are not changed. Setting a
parameter to *None* resets it to :rc:`figure.subplot.*`.

Parameters
----------
left, right, top, bottom : float or None, optional
    Extent of the subplots as a fraction of figure width or height.
wspace, hspace : float, optional
    Spacing between the subplots as a fraction of the average subplot
    width / height.
z is an unknown keywordNF)root)items_AllowedKeyssetattrAttributeErrorr   Gcffigsvaluescanvasr8   axesget_subplotspecru   rx   
get_figure_set_positionget_position)r   kwargskv
figmanagerr{   ssr^   s           r   updateGridSpec.updateq  s     LLNDA%%%#$s*@%ABB	 #
 ),,1188:J ''..33%%'3++-EEGB(D0 mmm7((););)=)J)J3)OP 4 ;r   c                 F   Uc=  U R                    Vs0 s H  nU[        R                  SU-      _M     nn[        S0 UD6nO [        R                  " UR
                  5      nUR                  " S0 U R                    Vs0 s H  o"[        X5      _M     snD6  U$ s  snf s  snf )a  
Return the `.SubplotParams` for the GridSpec.

In order of precedence the values are taken from

- non-*None* attributes of the GridSpec
- the provided *figure*
- :rc:`figure.subplot.*`

Note that the ``figure`` attribute of the GridSpec is always ignored.
figure.subplot.r7   )r   mplrcParamsSubplotParamsr   subplotparsr   getattr)r   r8   r   kwr   s        r   r9   GridSpec.get_subplot_params  s     >,,.,a S\\"3A"566,  .'-"-K))F$6$67KN4;L;LM;La!11;LMN. Ns   !B=Bc                 j    U R                    Vs/ s H  n[        X5      (       d  M  UPM     sn$ s  snf )z
Return a list of the names of the subplot parameters explicitly set
in the GridSpec.

This is a subset of the attributes of `.SubplotParams`.
)r   r   )r   r   s     r   locally_modified_subplot_params(GridSpec.locally_modified_subplot_params  s+      ,,A,a0@,AAAs   00c                     Uc  UR                  5       n[        R                  " XR                  [        R                  " UR                  U S9X#XEUS9nU(       a  U R
                  " S0 UD6  gg)a  
Adjust subplot parameters to give specified padding.

Parameters
----------
figure : `.Figure`
    The figure.
renderer :  `.RendererBase` subclass, optional
    The renderer to be used.
pad : float
    Padding between the figure edge and the edges of subplots, as a
    fraction of the font-size.
h_pad, w_pad : float, optional
    Padding (height/width) between edges of adjacent subplots.
    Defaults to *pad*.
rect : tuple (left, bottom, right, top), default: None
    (left, bottom, right, top) rectangle in normalized figure
    coordinates that the whole subplots area (including labels) will
    fit into. Default (None) is the whole figure.
N)	grid_spec)padh_padw_padrectr7   )_get_rendererr   get_tight_layout_figurer   get_subplotspec_listr   )r   r8   rendererr   r   r   r   r   s           r   tight_layoutGridSpec.tight_layout  sd    , ++-H66KK..v{{dKUdD KK!&! r   )rS   r8   rV   rQ   rR   rT   rU   )	NNNNNNNNNr,   )NgHzG?NNN)r&   r   r   r   r   r   r   r   r9   r   r   r   __classcell__r%   s   @r   rz   rz   /  sG     -19=%)2646l JLQ8.B -1<@" "r   rz   c                   D   ^  \ rS rSrSr  SU 4S jjrSS jrS rSrU =r	$ )	GridSpecFromSubplotSpeci  zl
GridSpec whose subplot layout parameters are inherited from the
location specified by a given SubplotSpec.
c                    > X@l         XPl        [        U[        5      (       a  X0l        O[        S5      eU R                  R                  5       R                  U l        [        TU ]%  XUUS9  g)a  
Parameters
----------
nrows, ncols : int
    Number of rows and number of columns of the grid.
subplot_spec : SubplotSpec
    Spec from which the layout parameters are inherited.
wspace, hspace : float, optional
    See `GridSpec` for more details. If not specified default values
    (from the figure or rcParams) are used.
height_ratios : array-like of length *nrows*, optional
    See `GridSpecBase` for details.
width_ratios : array-like of length *ncols*, optional
    See `GridSpecBase` for details.
zVsubplot_spec must be type SubplotSpec, usually from GridSpec, or axes.get_subplotspec.r   N)
_wspace_hspacer   r   _subplot_spec	TypeErrorrx   r8   r   r   )	r   r   r   subplot_specrU   rV   r   r   r%   s	           r   r    GridSpecFromSubplotSpec.__init__  so    & lK00!-NO O ((557>>&2'4 	 	6r   c           	         U R                   b  U R                   O+Ub  UR                  R                  O[        R                  S   nU R
                  b  U R
                  O+Ub  UR                  R                  O[        R                  S   nU R                  R                  U5      nUR                  u  pVpx[        XWXhX2S9$ )z1Return a dictionary of subplot layout parameters.zfigure.subplot.hspacezfigure.subplot.wspace)rQ   rR   rS   rT   rU   rV   )r   r   rV   r   r   r   rU   r   r   extentsr   )	r   r8   rV   rU   figboxrQ   rS   rR   rT   s	            r   r9   *GridSpecFromSubplotSpec.get_subplot_params  s    "&,,":$,,4:4Fv))00||$;< 	 #',,":$,,4:4Fv))00||$;< 	 ##008#)>> e$$*$*; 	;r   c                 6    U R                   R                  5       $ )zI
Return the topmost `.SubplotSpec` instance associated with the subplot.
)r   ru   r-   s    r   ru   /GridSpecFromSubplotSpec.get_topmost_subplotspec  s     !!99;;r   )r   r   r   r8   )NNNNr,   )
r&   r   r   r   r   r   r9   ru   r   r   r   s   @r   r   r     s%     &*266@; < <r   r   c                       \ rS rSrSrSS jrS r\S 5       r\	S 5       r
\
R                  S 5       r
S	 rS
 r\	S 5       r\	S 5       rS rS rS rS rS rS rS rS rS rSrg)r   i	  a%  
The location of a subplot in a `GridSpec`.

.. note::

    Likely, you will never instantiate a `SubplotSpec` yourself. Instead,
    you will typically obtain one from a `GridSpec` using item-access.

Parameters
----------
gridspec : `~matplotlib.gridspec.GridSpec`
    The GridSpec, which the subplot is referencing.
num1, num2 : int
    The subplot will occupy the *num1*-th cell of the given
    *gridspec*.  If *num2* is provided, the subplot will span between
    *num1*-th cell and *num2*-th cell **inclusive**.

    The index starts from 0.
Nc                 (    Xl         X l        X0l        g r,   )	_gridspecr   r   )r   gridspecr   r   s       r   r   SubplotSpec.__init__  s    !		r   c           
          U R                  5        SU R                  R                   SU R                  R                   SU R                  R                   SU R                  R                   S3
$ )N[:z, ])rx   r=   r   r   r>   r-   s    r   r)   SubplotSpec.__repr__"  sc    $$&'q<<%%&a(9(9':"<<%%&a(9(9':!= 	>r   c                    [        U5      S:X  a]  Uu  n[        U[        5      (       a  U$ [        U[        5      (       d  [	        SU< 35      e [        [        [        U5      5      u  p4nO4[        U5      S:X  a  Uu  p4nO[        R                  " SS[        U5      S9e[        R                  XU5      nUc
  [        X4U S9n[        U[        5      (       a9  [        U5      S	:X  a*  [        S
 U 5       5      (       d  [	        SU 35      eUu  pxO:[        U[        5      (       a  US:  d  XSU-  :  a  [	        SX4-   SU< 35      eU=pxXgS-
  U $ ! [         a    [	        SU< 35      Sef = f)z
Construct a `.SubplotSpec` from a parent `.Figure` and either

- a `.SubplotSpec` -- returned as is;
- one or three numbers -- a MATLAB-style subplot specifier.
r   z>Single argument to subplot must be a three-digit integer, not N   subplotz1 or 3)takesgivenrv   rP   c              3   B   #    U  H  n[        U[        5      v   M     g 7fr,   )r   r   ).0ns     r   	<genexpr>1SubplotSpec._from_subplot_args.<locals>.<genexpr>F  s     <1z!X..s   z3Subplot specifier tuple must contain integers, not z(num must be an integer with 1 <= num <= z, not )r    r   r   r   r   mapintr   r   nargs_errorrz   r}   r   r   )	r8   argsargrowscolsnumr|   ijs	            r   _from_subplot_argsSubplotSpec._from_subplot_args'  s    t9>DC#{++
X.. $$'7,- -7"%c3s8"4C
 Y!^"OD""9HCINN,,V4@:$V4Bc5!!c#h!m<<<< I#O  DAqc8,,a3d? >tyk J'#  KAA#ay3  7 $$'7,-2677s   E E.c                 L    U R                   c  U R                  $ U R                   $ r,   )_num2r   r-   s    r   r   SubplotSpec.num2W  s     JJ.tyy>DJJ>r   c                     Xl         g r,   )r  )r   values     r   r   r  [  s    
r   c                     U R                   $ r,   )r   r-   s    r   rx   SubplotSpec.get_gridspec_  s    ~~r   c                 t    U R                  5       R                  5       u  pXU R                  U R                  4$ )z
Return the subplot geometry as tuple ``(n_rows, n_cols, start, stop)``.

The indices *start* and *stop* define the range of the subplot within
the `GridSpec`. *stop* is inclusive (i.e. for a single cell
``start == stop``).
)rx   r4   r   r   )r   r  r  s      r   r4   SubplotSpec.get_geometryb  s2     &&(557
499dii//r   c                     U R                  5       R                  n[        U R                  U-  U R                  U-  S-   5      $ )z6The rows spanned by this subplot, as a `range` object.r   )rx   r   r   r   r   )r   r   s     r   r=   SubplotSpec.rowspanm  s<     !!#))TYY%'e);a)?@@r   c                     U R                  5       R                  n[        U R                  U-  U R                  U-  /5      u  p#[        X#S-   5      $ )z9The columns spanned by this subplot, as a `range` object.r   )rx   r   sortedr   r   r   )r   r   c1c2s       r   r>   SubplotSpec.colspans  sL     !!#)) U*DII,=>?Ra  r   c                 4    U R                   R                  S:H  $ Nr   )r=   r   r-   s    r   is_first_rowSubplotSpec.is_first_row|      ||!!Q&&r   c                 d    U R                   R                  U R                  5       R                  :H  $ r,   )r=   r   rx   r   r-   s    r   is_last_rowSubplotSpec.is_last_row  &    ||  D$5$5$7$=$===r   c                 4    U R                   R                  S:H  $ r-  )r>   r   r-   s    r   is_first_colSubplotSpec.is_first_col  r0  r   c                 d    U R                   R                  U R                  5       R                  :H  $ r,   )r>   r   rx   r   r-   s    r   is_last_colSubplotSpec.is_last_col  r4  r   c                    U R                  5       nUR                  5       u  p4[        R                  " U R                  U R
                  /X445      u  pVUR                  U5      u  pxpXu   R                  5       nX   R                  5       nX   R                  5       nX   R                  5       n[        R                  " XX5      $ )z:
Update the subplot position from ``figure.subplotpars``.
)rx   r4   rX   unravel_indexr   r   rr   minmaxr   from_extents)r   r8   r   r   r   r  r  ro   rn   rp   rq   
fig_bottomfig_topfig_left	fig_rights                  r   r   SubplotSpec.get_position  s     $$&,,.%%tyy$))&<unM
''/ 	5y !&**,
.$$&?&&($((*	  yJJr   c                 h    U R                  5       n[        US5      (       a  UR                  5       $ U $ )zH
Return the topmost `SubplotSpec` instance associated with the subplot.
ru   )rx   ry   ru   )r   r   s     r   ru   #SubplotSpec.get_topmost_subplotspec  s4     $$&86773355Kr   c           	          U R                   U R                  U R                  4[        US[	        5       5      [        US[	        5       5      [        US[	        5       5      4:H  $ )ze
Two SubplotSpecs are considered equal if they refer to the same
position(s) in the same `GridSpec`.
r   r   r   )r   r   r   r   r   )r   others     r   __eq__SubplotSpec.__eq__  sS     DII6E;9E6684E668466 	7r   c                 Z    [        U R                  U R                  U R                  45      $ r,   )hashr   r   r   r-   s    r   __hash__SubplotSpec.__hash__  s     T^^TYY		:;;r   c                     [        XU 40 UD6$ )a  
Create a GridSpec within this subplot.

The created `.GridSpecFromSubplotSpec` will have this `SubplotSpec` as
a parent.

Parameters
----------
nrows : int
    Number of rows in grid.

ncols : int
    Number of columns in grid.

Returns
-------
`.GridSpecFromSubplotSpec`

Other Parameters
----------------
**kwargs
    All other parameters are passed to `.GridSpecFromSubplotSpec`.

See Also
--------
matplotlib.pyplot.subplots

Examples
--------
Adding three subplots in the space occupied by a single subplot::

    fig = plt.figure()
    gs0 = fig.add_gridspec(3, 1)
    ax1 = fig.add_subplot(gs0[0])
    ax2 = fig.add_subplot(gs0[1])
    gssub = gs0[2].subgridspec(1, 3)
    for i in range(3):
        fig.add_subplot(gssub[0, i])
)r   )r   r   r   r   s       r   subgridspecSubplotSpec.subgridspec  s    P 'uTDVDDr   )r   r  r   r   r,   )r&   r   r   r   r   r   r)   r   r  r   r   setterrx   r4   r=   r>   r.  r2  r6  r9  r   ru   rI  rM  rP  r   r7   r   r   r   r   	  s    &
>
 * *^ ? ? 
[[ 	0 A A
 ! !'>'>K 	7<(Er   r   c                   4    \ rS rSrSr  SS jr  SS jrSrg)r   i  zE
Parameters defining the positioning of a subplots grid in a figure.
Nc                 |    S H#  n[        X[        R                  SU 3   5        M%     U R                  XX4XV5        g)a  
Defaults are given by :rc:`figure.subplot.[name]`.

Parameters
----------
left : float
    The position of the left edge of the subplots,
    as a fraction of the figure width.
right : float
    The position of the right edge of the subplots,
    as a fraction of the figure width.
bottom : float
    The position of the bottom edge of the subplots,
    as a fraction of the figure height.
top : float
    The position of the top edge of the subplots,
    as a fraction of the figure height.
wspace : float
    The width of the padding between subplots,
    as a fraction of the average Axes width.
hspace : float
    The height of the padding between subplots,
    as a fraction of the average Axes height.
r   r   N)r   r   r   r   )r   rQ   rS   rR   rT   rU   rV   r   s           r   r   SubplotParams.__init__  s:    4 JCDs||ocU,CDE JD%f=r   c                 .   Ub  UOU R                   Ub  UOU R                  :  a  [        S5      eUb  UOU R                  Ub  UOU R                  :  a  [        S5      eUb  Xl         Ub  X0l        Ub  X l        Ub  X@l        Ub  XPl        Ub  X`l        gg)zI
Update the dimensions of the passed parameters. *None* means unchanged.
Nzleft cannot be >= rightzbottom cannot be >= top)rQ   rR   r   rS   rT   rU   rV   )r   rQ   rS   rR   rT   rU   rV   s          r   r   SubplotParams.update  s    
 %T499".EDJJ@677)Vt{{?C:677IJ K?H K K r   )rS   rV   rQ   rR   rT   rU   )NNNNNN)r&   r   r   r   r   r   r   r   r7   r   r   r   r     s$     @D%)>< >B#'!r   r   )r   r   loggingnumbersr   numpyrX   
matplotlibr   r   r   r   matplotlib.transformsr   	getLoggerr&   _logr	   rz   r   r   r   r7   r   r   <module>r_     sv   
      : : &"R Rj["| ["|9<l 9<xOE OEd9! 9!r   