o
    môjZt  ã                   @   s¨   d Z ddlZddlZddlmZ ddlZddlZddlm	Z	m
Z
mZ ddlmZ e e¡ZG dd„ dƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ dƒZG dd„ dƒZdS )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                   @   s®   e Zd ZdZd'dd„Zdd„ Zedd„ d	d
�Zedd„ dd
�Zdd„ Z	d(dd„Z
d)dd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedd„ ƒZd d!„ Zd"d"d#dd$œd%d&„ZdS )*ÚGridSpecBasezm
    A base class of GridSpec that specifies the geometry of the grid
    that a subplot will be placed.
    Nc                 C   sf   t |tƒr	|dkrtd|›�ƒ‚t |tƒr|dkr td|›�ƒ‚||| _| _|  |¡ |  |¡ dS )aŸ  
        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_ratios© r   úf/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/matplotlib/gridspec.pyÚ__init__    s   ÿÿ
zGridSpecBase.__init__c                 C   sb   t t| jƒƒdkrd| j›�nd}t t| jƒƒdkr d| j›�nd}dj| jj| j| j|| d�S )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   Z
height_argZ	width_argr   r   r   Ú__repr__9   s   ÿÿÿÿüzGridSpecBase.__repr__c                 C   ó   | j S ©N)r
   ©r   r   r   r   Ú<lambda>E   ó    zGridSpecBase.<lambda>zThe number of rows in the grid.)Údocc                 C   r"   r#   )r   r$   r   r   r   r%   G   r&   z"The number of columns in the grid.c                 C   s   | j | jfS )zW
        Return a tuple containing the number of rows and columns in the grid.
        )r
   r   r$   r   r   r   Úget_geometryJ   s   zGridSpecBase.get_geometryc                 C   s   d S r#   r   )r   Úfigurer   r   r   Úget_subplot_paramsP   s   zGridSpecBase.get_subplot_paramsr   c                 C   s(   |\}}| ||| …||| …f }|S )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.
        r   )r   ÚlocÚrowspanÚcolspanÚloc1Úloc2Úsubplotspecr   r   r   Únew_subplotspecT   s   zGridSpecBase.new_subplotspecc                 C   ó6   |du rdg| j  }nt|ƒ| j krtdƒ‚|| _dS )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   r   r   r   r   d   ó
   
zGridSpecBase.set_width_ratiosc                 C   r"   )zo
        Return the width ratios.

        This is *None* if no width ratios have been set explicitly.
        )r   r$   r   r   r   Úget_width_ratiosr   ó   zGridSpecBase.get_width_ratiosc                 C   r2   )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   r   r   r   r   z   r3   zGridSpecBase.set_height_ratiosc                 C   r"   )zq
        Return the height ratios.

        This is *None* if no height ratios have been set explicitly.
        )r   r$   r   r   r   Úget_height_ratiosˆ   r5   zGridSpecBase.get_height_ratiosc                    sV  |   ¡ \}}|  |¡}|j}|j}|j}|j}|j}	|j}
|| }|| }|||
|d    }|
| }|| t| j	ƒ ‰ ‡ fdd„| j	D ƒ}dg|g|d   }t
 t
 ||g¡j¡}|||	|d    }|	| }|| t| jƒ ‰ ‡ fdd„| jD ƒ}dg|g|d   }t
 t
 ||g¡j¡}||  d¡j\}}||  d¡j\}}||||fS )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   c                    ó   g | ]}|ˆ  ‘qS r   r   ©Ú.0Úr©Únormr   r   Ú
<listcomp>¯   ó    z3GridSpecBase.get_grid_positions.<locals>.<listcomp>r   c                    r7   r   r   r8   r;   r   r   r=   ·   r>   )éÿÿÿÿé   )r(   r*   ÚleftÚrightÚbottomÚtopÚwspaceÚhspaceÚsumr   ÚnpÚcumsumÚcolumn_stackÚflatr   ÚreshapeÚT)r   Úfigr   r   Zsubplot_paramsrA   rB   rC   rD   rE   rF   Z	tot_widthZ
tot_heightZcell_hZsep_hZcell_heightsZsep_heightsZcell_hsZcell_wZsep_wZcell_widthsZ
sep_widthsZcell_wsÚfig_topsÚfig_bottomsÚ	fig_leftsÚ
fig_rightsr   r;   r   Úget_grid_positions�   s2   
zGridSpecBase.get_grid_positionsc                 C   sZ   |   ¡ D ]!}| ¡ }|dur%t|dƒr| ¡  ¡ }| ¡ ||fkr%|  S qt||| d�S )zo
        Check if the figure already has a gridspec with these dimensions,
        or create a new one
        NÚget_topmost_subplotspec©r)   )Úget_axesÚget_gridspecÚhasattrrT   r(   ÚGridSpec)r)   r   r   ÚaxÚgsr   r   r   Ú_check_gridspec_exists¿   s   
€z#GridSpecBase._check_gridspec_existsc           
   
   C   s˜   |   ¡ \}}dd„ }t|tƒr<z|\}}W n ty& } ztdƒ|‚d}~ww t |||dƒ|||dƒg||f¡\}}	n
|||| dƒ\}}	t| ||	ƒS )z,Create and return a `.SubplotSpec` instance.c                 S   sœ   | }t | tƒr|  |¡\}}}||kr||d fS tdƒ‚| dk r%| | } d|   kr2|k r3| | fS  |d urDtd|› d|› d|› �ƒ‚td|› d|› �ƒ‚)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Ú_r   r   r   Ú
_normalizeØ   s(   
ÿ
ÿÿ
ÿz,GridSpecBase.__getitem__.<locals>._normalizezUnrecognized subplot specNr   r   )r(   r   Útupler	   rH   Úravel_multi_indexÚSubplotSpec)
r   r`   r   r   rg   Úk1Úk2ÚerrÚnum1Únum2r   r   r   Ú__getitem__Ô   s   

€ÿ
þzGridSpecBase.__getitem__FT)ÚsharexÚshareyÚsqueezeÚ
subplot_kwc                C   s^  | j }|du rtdƒ‚t|tƒs|rdnd}t|tƒs!|rdnd}tjg d¢||d� |du r1i }| ¡ }tj| j	| j
ftd�}t| j	ƒD ]8}t| j
ƒD ]0}d|d ||d	f |d	|f d
œ}	|	| |d< |	| |d< |j| ||f fi |¤Ž|||f< qLqE|dv rŽ|jD ]}
|
jdd� q…|dv rž|jD ]}
|
jdd� q•|r­|jdkr©| ¡ S | ¡ S |S )z‘
        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)ru   ÚrowÚcolrv   FT)rq   rr   )Údtype)r   r   r   )rv   ru   rw   rx   rq   rr   )rx   ru   T)Úskip_non_rectangular_axes)rw   ru   r   )r)   r	   r   Ústrr   Úcheck_in_listÚcopyrH   Úemptyr
   r   ÚobjectÚrangeÚadd_subplotrK   Ú_label_outer_xaxisÚ_label_outer_yaxisra   Úitemrs   )r   rq   rr   rs   rt   r)   Zaxarrrw   rx   Zshared_withrZ   r   r   r   Úsubplotsù   sH   


ÿÿ
ÿÿû	

zGridSpecBase.subplots)NNr#   )r   r   )r    Ú
__module__Ú__qualname__Ú__doc__r   r!   Úpropertyr   r   r(   r*   r1   r   r4   r   r6   rS   Ústaticmethodr\   rp   r…   r   r   r   r   r      s0    
ÿÿ

/
%ÿr   c                       sZ   e Zd ZdZ				d‡ fdd„	Zg d¢Zdd„ Zddd	„Zd
d„ Z		ddd„Z	‡  Z
S )rY   a  
    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`.
    Nc                    sB   || _ || _|| _|| _|| _|	| _|| _tƒ j|||
|d� dS )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)	rA   rC   rB   rD   rE   rF   r)   Úsuperr   )r   r   r   r)   rA   rC   rB   rD   rE   rF   r   r   ©r   r   r   r   9  s   *

þzGridSpec.__init__©rA   rC   rB   rD   rE   rF   c                 K   s    |  ¡ D ]\}}|| jv rt| ||ƒ qt|› d�ƒ‚tjj ¡ D ],}|jj	j
D ]$}| ¡ durL| ¡  ¡ }| ¡ | krL|jdd�}| | ¡  |¡¡ q(q!dS )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Úcanvasr)   ÚaxesÚget_subplotspecrT   rW   Ú
get_figureÚ_set_positionÚget_position)r   ÚkwargsÚkÚvZ
figmanagerrZ   ÚssrN   r   r   r   Úupdateq  s   
€ûÿzGridSpec.updatec                    sX   |du rdd„ ˆ j D ƒ}tdi |¤Ž}nt |j¡}|jdi ‡ fdd„ˆ j D ƒ¤Ž |S )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.
        Nc                 S   s   i | ]
}|t jd |  “qS )úfigure.subplot.)ÚmplÚrcParams©r9   rž   r   r   r   Ú
<dictcomp>š  s    ÿz/GridSpec.get_subplot_params.<locals>.<dictcomp>c                    s   i | ]}|t ˆ |ƒ“qS r   ©Úgetattrr¥   r$   r   r   r¦      s    r   )r‘   ÚSubplotParamsr}   Úsubplotparsr¡   )r   r)   Úkwrª   r   r$   r   r*   �  s   ÿ zGridSpec.get_subplot_paramsc                    s   ‡ fdd„ˆ j D ƒS )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`.
        c                    s   g | ]	}t ˆ |ƒr|‘qS r   r§   r¥   r$   r   r   r=   «  s    z<GridSpec.locally_modified_subplot_params.<locals>.<listcomp>)r‘   r$   r   r$   r   Úlocally_modified_subplot_params¤  s   z(GridSpec.locally_modified_subplot_paramsçHáz®Gñ?c              
   C   sT   |du r|  ¡ }tj||jtj|j| d�|||||d�}|r(| jdi |¤Ž dS dS )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Úrectr   )Ú_get_rendererr   Úget_tight_layout_figurer˜   Úget_subplotspec_listr¡   )r   r)   Úrendererr¯   r°   r±   r²   r�   r   r   r   Útight_layout­  s   
ýÿzGridSpec.tight_layout)	NNNNNNNNNr#   )Nr­   NNN)r    r†   r‡   rˆ   r   r‘   r¡   r*   r¬   r·   Ú__classcell__r   r   r�   r   rY   /  s    	ý6
	ÿrY   c                       s8   e Zd ZdZ		d	‡ fdd„	Zd
dd„Zdd„ Z‡  ZS )ÚGridSpecFromSubplotSpeczx
    GridSpec whose subplot layout parameters are inherited from the
    location specified by a given SubplotSpec.
    Nc                    sL   || _ || _t|tƒr|| _ntdƒ‚| j ¡ j| _tƒ j	||||d� dS )ak  
        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   rj   Ú_subplot_specÚ	TypeErrorrW   r)   rŒ   r   )r   r   r   Úsubplot_specrE   rF   r   r   r�   r   r   r   Ò  s   
ÿ

þz GridSpecFromSubplotSpec.__init__c           	      C   s‚   | j dur| j n|dur|jjntjd }| jdur| jn|dur%|jjntjd }| j |¡}|j	\}}}}t
||||||d�S )z1Return a dictionary of subplot layout parameters.Nzfigure.subplot.hspacezfigure.subplot.wspace)rA   rB   rC   rD   rE   rF   )r»   rª   rF   r£   r¤   rº   rE   r¼   rœ   Úextentsr©   )	r   r)   rF   rE   ZfigboxrA   rC   rB   rD   r   r   r   r*   ò  s   þþþz*GridSpecFromSubplotSpec.get_subplot_paramsc                 C   s
   | j  ¡ S )zY
        Return the topmost `.SubplotSpec` instance associated with the subplot.
        )r¼   rT   r$   r   r   r   rT     s   
z/GridSpecFromSubplotSpec.get_topmost_subplotspec)NNNNr#   )r    r†   r‡   rˆ   r   r*   rT   r¸   r   r   r�   r   r¹   Í  s    ý
 r¹   c                   @   s¸   e Zd ZdZd&dd„Zdd„ Zedd„ ƒZed	d
„ ƒZ	e	j
dd
„ ƒZ	dd„ Zdd„ Zedd„ ƒZedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ ZdS )'rj   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                 C   s   || _ || _|| _d S r#   )Ú	_gridspecrn   ro   )r   Úgridspecrn   ro   r   r   r   r     s   
zSubplotSpec.__init__c              
   C   s6   |   ¡ › d| jj› d| jj› d| jj› d| jj› d�
S )NÚ[ú:z, Ú])rW   r,   rd   re   r-   r$   r   r   r   r!   "  s   
ÿÿþþzSubplotSpec.__repr__c           	      C   sN  t |ƒdkr8|\}t|tƒr|S t|tƒstd|›�ƒ‚zttt|ƒƒ\}}}W n% ty7   td|›�ƒd‚w t |ƒdkrD|\}}}n
tj	ddt |ƒd�‚t
 | ||¡}|du r`t
||| d�}t|tƒr€t |ƒd	kr€td
d„ |D ƒƒs{td|› �ƒ‚|\}}nt|tƒr�|dk s�||| kr›td|| › d|›�ƒ‚| }}||d |… S )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é   Zsubplotz1 or 3)ÚtakesÚgivenrU   r@   c                 s   s   � | ]}t |tƒV  qd S r#   )r   r   )r9   Únr   r   r   Ú	<genexpr>F  s   € z1SubplotSpec._from_subplot_args.<locals>.<genexpr>z3Subplot specifier tuple must contain integers, not z(num must be an integer with 1 <= num <= z, not )r   r   rj   r   r	   ÚmapÚintr{   r   Únargs_errorrY   r\   rh   ru   )	r)   ÚargsÚargÚrowsÚcolsÚnumr[   ÚiÚjr   r   r   Ú_from_subplot_args'  sR   

ÿÿÿÿþÿÿ
ÿÿzSubplotSpec._from_subplot_argsc                 C   s   | j d u r| jS | j S r#   )Ú_num2rn   r$   r   r   r   ro   W  s   zSubplotSpec.num2c                 C   s
   || _ d S r#   )rÕ   )r   Úvaluer   r   r   ro   [  s   
c                 C   r"   r#   )rÀ   r$   r   r   r   rW   _  s   zSubplotSpec.get_gridspecc                 C   s    |   ¡  ¡ \}}||| j| jfS )a  
        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``).
        )rW   r(   rn   ro   )r   rÏ   rÐ   r   r   r   r(   b  s   zSubplotSpec.get_geometryc                 C   s$   |   ¡ j}t| j| | j| d ƒS )z6The rows spanned by this subplot, as a `range` object.r   )rW   r   r€   rn   ro   )r   r   r   r   r   r,   m  s   
zSubplotSpec.rowspanc                 C   s4   |   ¡ j}t| j| | j| gƒ\}}t||d ƒS )z9The columns spanned by this subplot, as a `range` object.r   )rW   r   Úsortedrn   ro   r€   )r   r   Úc1Úc2r   r   r   r-   s  s   
zSubplotSpec.colspanc                 C   ó   | j jdkS ©Nr   )r,   rd   r$   r   r   r   Úis_first_row|  ó   zSubplotSpec.is_first_rowc                 C   ó   | j j|  ¡ jkS r#   )r,   re   rW   r   r$   r   r   r   Úis_last_row  ó   zSubplotSpec.is_last_rowc                 C   rÚ   rÛ   )r-   rd   r$   r   r   r   Úis_first_col‚  rÝ   zSubplotSpec.is_first_colc                 C   rÞ   r#   )r-   re   rW   r   r$   r   r   r   Úis_last_col…  rà   zSubplotSpec.is_last_colc                 C   s‚   |   ¡ }| ¡ \}}t | j| jg||f¡\}}| |¡\}}}	}
||  ¡ }||  ¡ }|	|  ¡ }|
|  ¡ }t	 
||||¡S )zJ
        Update the subplot position from ``figure.subplotpars``.
        )rW   r(   rH   Úunravel_indexrn   ro   rS   ÚminÚmaxr   Úfrom_extents)r   r)   rÁ   r   r   rÏ   rÐ   rP   rO   rQ   rR   Z
fig_bottomZfig_topZfig_leftZ	fig_rightr   r   r   rœ   ˆ  s   
ÿzSubplotSpec.get_positionc                 C   s   |   ¡ }t|dƒr| ¡ S | S )zX
        Return the topmost `SubplotSpec` instance associated with the subplot.
        rT   )rW   rX   rT   )r   rÁ   r   r   r   rT   ˜  s   
z#SubplotSpec.get_topmost_subplotspecc                 C   s8   | j | j| jft|dtƒ ƒt|dtƒ ƒt|dtƒ ƒfkS )z}
        Two SubplotSpecs are considered equal if they refer to the same
        position(s) in the same `GridSpec`.
        rÀ   rn   ro   )rÀ   rn   ro   r¨   r   )r   Úotherr   r   r   Ú__eq__¢  s   þÿzSubplotSpec.__eq__c                 C   s   t | j| j| jfƒS r#   )ÚhashrÀ   rn   ro   r$   r   r   r   Ú__hash__­  s   zSubplotSpec.__hash__c                 K   s   t ||| fi |¤ŽS )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�   r   r   r   Úsubgridspec°  s   (zSubplotSpec.subgridspecr#   )r    r†   r‡   rˆ   r   r!   rŠ   rÔ   r‰   ro   ÚsetterrW   r(   r,   r-   rÜ   rß   rá   râ   rœ   rT   rè   rê   rë   r   r   r   r   rj   	  s2    

/




rj   c                   @   s,   e Zd ZdZ		ddd„Z		ddd„ZdS )r©   zM
    Parameters defining the positioning of a subplots grid in a figure.
    Nc                 C   s:   dD ]}t | |tjd|› � ƒ q|  ||||||¡ dS )au  
        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   rA   rC   rB   rD   rE   rF   r`   r   r   r   r   à  s   zSubplotParams.__init__c                 C   s´   |dur|n| j |dur|n| jkrtdƒ‚|dur|n| j|dur$|n| jkr,tdƒ‚|dur3|| _ |dur:|| _|durA|| _|durH|| _|durO|| _|durX|| _dS dS )zY
        Update the dimensions of the passed parameters. *None* means unchanged.
        Nzleft cannot be >= rightzbottom cannot be >= top)rA   rB   r	   rC   rD   rE   rF   )r   rA   rC   rB   rD   rE   rF   r   r   r   r¡   þ  s*   ÿÿ
ÿzSubplotParams.update)NNNNNN)r    r†   r‡   rˆ   r   r¡   r   r   r   r   r©   Û  s    
ÿÿr©   )rˆ   r}   ÚloggingÚnumbersr   ÚnumpyrH   Ú
matplotlibr£   r   r   r   Úmatplotlib.transformsr   Ú	getLoggerr    Ú_logr   rY   r¹   rj   r©   r   r   r   r   Ú<module>   s$    
   < S