a
    ëÝEbôo  ã                   @   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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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
:doc:`/tutorials/intermediate/arranging_axes` for a guide.
é    N)ÚIntegral)Ú_apiÚ_pylab_helpersÚtight_layoutÚrcParams)Ú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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ƒr2|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   úS/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/gridspec.pyÚ__init__!   s    ÿÿ
zGridSpecBase.__init__c                 C   sb   t t| jƒƒdkrd| jf nd}t t| jƒƒdkr@d| jf nd}dj| jj| j| j|| d�S )Né   z, height_ratios=%rÚ z, width_ratios=%rz&{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__:   s    ÿÿÿÿüzGridSpecBase.__repr__c                 C   s   | j S ©N)r   ©r   r   r   r   Ú<lambda>F   ó    zGridSpecBase.<lambda>zThe number of rows in the grid.)Údocc                 C   s   | j S r#   )r   r$   r   r   r   r%   H   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_geometryK   s    zGridSpecBase.get_geometryc                 C   s   d S r#   r   )r   Úfigurer   r   r   Úget_subplot_paramsQ   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Úloc2Zsubplotspecr   r   r   Únew_subplotspecU   s    zGridSpecBase.new_subplotspecc                 C   s6   |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   e   s
    zGridSpecBase.set_width_ratiosc                 C   s   | j S )zo
        Return the width ratios.

        This is *None* if no width ratios have been set explicitly.
        )r   r$   r   r   r   Úget_width_ratioss   s    zGridSpecBase.get_width_ratiosc                 C   s6   |du rdg| j  }nt|ƒ| j kr,tdƒ‚|| _dS )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   {   s
    zGridSpecBase.set_height_ratiosc                 C   s   | j S )zq
        Return the height ratios.

        This is *None* if no height ratios have been set explicitly.
        )r   r$   r   r   r   Úget_height_ratios‰   s    zGridSpecBase.get_height_ratiosFc                    st  |   ¡ \}}|r*d}d}d}d}d}	d}
n.|  |¡}|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*.
        raw : bool, default: False
            If *True*, the subplot parameters of the figure are not taken
            into account. The grid spans the range [0, 1] in both directions
            without margins and there is no space between grid cells. This is
            used for constrained_layout.

        Returns
        -------
        bottoms, tops, lefts, rights : array
            The bottom, top, left, right positions of the grid cells in
            figure coordinates.
        g        g      ð?r   c                    s   g | ]}|ˆ  ‘qS r   r   ©Ú.0Úr©Znormr   r   Ú
<listcomp>¾   r&   z3GridSpecBase.get_grid_positions.<locals>.<listcomp>r   c                    s   g | ]}|ˆ  ‘qS r   r   r3   r6   r   r   r7   Æ   r&   )éÿÿÿÿé   )r(   r*   ÚleftÚrightÚbottomÚtopÚwspaceÚhspaceÚsumr   ÚnpZcumsumZcolumn_stackÚflatr   ZreshapeÚT)r   ZfigÚrawr   r   r:   r;   r<   r=   r>   r?   Zsubplot_paramsZ	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   r6   r   Úget_grid_positions‘   s@    
zGridSpecBase.get_grid_positionsc                 C   s`   |   ¡ D ]H}t|dƒr| ¡  ¡ }t|dƒr8| ¡  ¡ }| ¡ ||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
        Úget_subplotspecÚget_topmost_subplotspec©r)   )Zget_axesÚhasattrrJ   Úget_gridspecrK   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yX } ztdƒ|‚W Y d}~n
d}~0 0 t |||dƒ|||dƒg||f¡\}}	n|||| dƒ\}}	t| ||	ƒS )z,Create and return a `.SubplotSpec` instance.c                 S   s¨   | }t | tƒr<|  |¡\}}}||kr2||d fS tdƒ‚nh| dk rL| | } d|   kr`|k rln n| | fS |d ur�td|› d|› d|› �ƒ‚ntd|› d|› �ƒ‚d S )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ÚsizeZaxisZorig_keyÚstartÚstopÚ_r   r   r   Ú
_normalizeç   s&    


ÿÿ

ÿz,GridSpecBase.__getitem__.<locals>._normalizezUnrecognized subplot specNr   r   )r(   r	   Útupler
   rA   Zravel_multi_indexÚSubplotSpec)
r   rV   r   r   r[   Zk1Zk2ÚerrÚnum1Únum2r   r   r   Ú__getitem__ã   s    
 þ
zGridSpecBase.__getitem__T)ÚsharexÚshareyÚsqueezeÚ
subplot_kwc                C   s‚  | j }|du rtdƒ‚t|tƒr,|r(dnd}t|tƒrB|r>dnd}t|tƒrVt d¡ tjg d¢||d� |du rvi }| ¡ }t	j
| j| jftd�}t| jƒD ]p}t| jƒD ]`}d|d	 ||d
f |d
|f dœ}	|	| |d< |	| |d< |j| ||f fi |¤Ž|||f< q¬qž|dv �r4|jD ]}
|
jdd� �q |dv �rX|jD ]}
|
jdd� �qD|�rz|jdk�rr| ¡ S | ¡ S |S d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Únonez]sharex argument to subplots() was an integer.  Did you intend to use subplot() (without 's')?)rf   ÚrowÚcolrg   )rb   rc   )Zdtype)r   r   r   )rg   rf   rh   ri   rb   rc   )ri   rf   T)Zcheck_patch)rh   rf   r   )r)   r
   r	   Úboolr   r   Úwarn_externalZcheck_in_listÚcopyrA   Úemptyr   r   ÚobjectÚrangeZadd_subplotrB   Z_label_outer_xaxisZ_label_outer_yaxisrW   Úitemrd   )r   rb   rc   rd   re   r)   Zaxarrrh   ri   Zshared_withrP   r   r   r   Úsubplots  sN    


ÿ
ÿÿ
ÿÿ



zGridSpecBase.subplots)NN)N)r   r   )F)r!   Ú
__module__Ú__qualname__Ú__doc__r   r"   Úpropertyr   r   r(   r*   r0   r   r1   r   r2   rI   ÚstaticmethodrR   ra   rq   r   r   r   r   r      s.   
ÿÿ


=
%ÿr   c                	       sN   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 )rO   zà
    A grid layout to place subplots within a figure.

    The location of the grid cells is determined in a similar way to
    `~.figure.SubplotParams` using *left*, *right*, *top*, *bottom*, *wspace*
    and *hspace*.
    Nc                    sB   || _ || _|| _|| _|| _|	| _|| _tƒ j|||
|d� dS )aø  
        Parameters
        ----------
        nrows, ncols : int
            The number of rows and columns of the grid.

        figure : `~.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)	r:   r<   r;   r=   r>   r?   r)   Úsuperr   )r   r   r   r)   r:   r<   r;   r=   r>   r?   r   r   ©r    r   r   r   O  s    *
þzGridSpec.__init__)r:   r<   r;   r=   r>   r?   c                 K   sš   |  ¡ D ].\}}|| jv r(t| ||ƒ qt|› d�ƒ‚qtjj ¡ D ]P}|jj	j
D ]@}t|tj
jƒrR| ¡  ¡ }| ¡ | krR| | ¡  |j	¡¡ qRqDd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 keywordN)ÚitemsÚ_AllowedKeysÚsetattrÚAttributeErrorr   ZGcfZfigsÚvaluesZcanvasr)   Úaxesr	   ÚmplZSubplotBaserJ   rK   rN   Z_set_positionÚget_position)r   ÚkwargsÚkÚvZ
figmanagerrP   Ússr   r   r   Úupdate‡  s    
ÿzGridSpec.updatec                    s\   |du r,dd„ ˆ j D ƒ}tjjf i |¤Ž}nt |j¡}|jf i ‡ fdd„ˆ j D ƒ¤Ž |S )zë
        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.*`
        Nc                 S   s   i | ]}|t d |  “qS )zfigure.subplot.)r   ©r4   rƒ   r   r   r   Ú
<dictcomp>®  r&   z/GridSpec.get_subplot_params.<locals>.<dictcomp>c                    s   i | ]}|t ˆ |ƒ“qS r   ©Úgetattrr‡   r$   r   r   rˆ   ³  r&   )r{   r€   r)   ÚSubplotParamsrl   Ú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   r7   ¾  r&   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   sh   t j|j| d�}d|v r"t d¡ |du r4t  |¡}t j||j||||||d�}|rd| jf i |¤Ž dS )ay  
        Adjust subplot parameters to give specified padding.

        Parameters
        ----------
        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 of 4 floats, default: (0, 0, 1, 1), i.e. the whole figure
            (left, bottom, right, top) rectangle in normalized figure
            coordinates that the whole subplots area (including labels) will
            fit into.
        )Z	grid_specNzcThis figure includes Axes that are not compatible with tight_layout, so results might be incorrect.)ÚpadÚh_padÚw_padÚrect)r   Zget_subplotspec_listr   r   rk   Zget_rendererZget_tight_layout_figurer†   )	r   r)   Úrendererr�   r‘   r’   r“   Zsubplotspec_listr‚   r   r   r   r   À  s    ÿ


þzGridSpec.tight_layout)	NNNNNNNNN)N)Nr�   NNN)r!   rr   rs   rt   r   r{   r†   r*   rŽ   r   Ú__classcell__r   r   ry   r   rO   G  s       ý6
	  ÿrO   c                       s4   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                    s8   || _ || _|| _| 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.
        rw   N)Ú_wspaceÚ_hspaceÚ_subplot_specrN   r)   rx   r   )r   r   r   Zsubplot_specr>   r?   r   r   ry   r   r   r   é  s    
þz GridSpecFromSubplotSpec.__init__c           	      C   s‚   | j dur| j n|dur |jjntd }| jdur8| jn|durH|jjntd }| j |¡}|j\}}}}t	j
j||||||d�S )z1Return a dictionary of subplot layout parameters.Nzfigure.subplot.hspacezfigure.subplot.wspace)r:   r;   r<   r=   r>   r?   )r˜   rŒ   r?   r   r—   r>   r™   r�   Zextentsr€   r)   r‹   )	r   r)   r?   r>   Úfigboxr:   r<   r;   r=   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™   rK   r$   r   r   r   rK     s    z/GridSpecFromSubplotSpec.get_topmost_subplotspec)NNNN)N)r!   rr   rs   rt   r   r*   rK   r•   r   r   ry   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dd„ Zedd„ ƒZedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Ze dd¡d,d!d"„ƒZd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ ZdS )-r]   aN  
    The location of a subplot in a `GridSpec`.

    .. note::

        Likely, you'll 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#   )Ú	_gridspecr_   r`   )r   Úgridspecr_   r`   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, ú])rN   r,   rX   rY   r-   r$   r   r   r   r"   4  s    
ÿÿþþzSubplotSpec.__repr__c           	      C   s`  t |ƒdkrv|\}t|tƒr |S t|tƒs8td|›�ƒ‚zttt|ƒƒ\}}}W q¢ tyr   td|›�ƒd‚Y q¢0 n,t |ƒdkrŽ|\}}}ntdt |ƒ› d�ƒ‚t	 
| ||¡}|du rÆt	||| d�}t|tƒ�rt |ƒdk�rtd	d
„ |D ƒƒ�std|› �ƒ‚|\}}nDt|tƒ�r0|dk �s0||| k�rHt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é   z0subplot() takes 1 or 3 positional arguments but z were givenrL   r9   c                 s   s   | ]}t |tƒV  qd S r#   )r	   r   )r4   Únr   r   r   Ú	<genexpr>Y  r&   z1SubplotSpec._from_subplot_args.<locals>.<genexpr>z3Subplot specifier tuple must contain integers, not znum must be 1 <= num <= z, not )r   r	   r]   r   r
   ÚmapÚintÚstrÚ	TypeErrorrO   rR   r\   rf   )	r)   ÚargsÚargÚrowsÚcolsÚnumrQ   ÚiÚjr   r   r   Ú_from_subplot_args9  sP    

ÿÿÿÿþ
ÿ
ÿ
$ÿzSubplotSpec._from_subplot_argsc                 C   s   | j d u r| jS | j S r#   )Ú_num2r_   r$   r   r   r   r`   h  s    zSubplotSpec.num2c                 C   s
   || _ d S r#   )r¯   )r   Úvaluer   r   r   r`   l  s    c                 C   s
   i | j ¥S r#   )Ú__dict__r$   r   r   r   Ú__getstate__p  s    zSubplotSpec.__getstate__c                 C   s   | j S r#   )r›   r$   r   r   r   rN   s  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``).
        )rN   r(   r_   r`   )r   r©   rª   r   r   r   r(   v  s    zSubplotSpec.get_geometryc                 C   s$   |   ¡ j}t| j| | j| d ƒS )z6The rows spanned by this subplot, as a `range` object.r   )rN   r   ro   r_   r`   )r   r   r   r   r   r,   �  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   )rN   r   Úsortedr_   r`   ro   )r   r   Úc1Úc2r   r   r   r-   ‡  s    
zSubplotSpec.colspanc                 C   s   | j jdkS ©Nr   )r,   rX   r$   r   r   r   Úis_first_row�  s    zSubplotSpec.is_first_rowc                 C   s   | j j|  ¡ jkS r#   )r,   rY   rN   r   r$   r   r   r   Úis_last_row“  s    zSubplotSpec.is_last_rowc                 C   s   | j jdkS r¶   )r-   rX   r$   r   r   r   Úis_first_col–  s    zSubplotSpec.is_first_colc                 C   s   | j j|  ¡ jkS r#   )r-   rY   rN   r   r$   r   r   r   Úis_last_col™  s    zSubplotSpec.is_last_colz3.4Ú
return_allFc                 C   s¤   |   ¡ }| ¡ \}}t | j| jg||f¡\}}| |¡\}}	}
}||  ¡ }|	|  ¡ }|
|  ¡ }||  ¡ }t	 
||||¡}|rœ||d |d ||fS |S dS )zJ
        Update the subplot position from ``figure.subplotpars``.
        r   N)rN   r(   rA   Zunravel_indexr_   r`   rI   ÚminÚmaxr   Zfrom_extents)r   r)   r»   rœ   r   r   r©   rª   rF   rE   rG   rH   Z
fig_bottomZfig_topZfig_leftZ	fig_rightrš   r   r   r   r�   œ  s    ÿ
zSubplotSpec.get_positionc                 C   s"   |   ¡ }t|dƒr| ¡ S | S dS )zX
        Return the topmost `SubplotSpec` instance associated with the subplot.
        rK   N)rN   rM   rK   )r   rœ   r   r   r   rK   ²  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›   r_   r`   )r›   r_   r`   rŠ   rn   )r   Úotherr   r   r   Ú__eq__¼  s    þÿzSubplotSpec.__eq__c                 C   s   t | j| j| jfƒS r#   )Úhashr›   r_   r`   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 or 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.subgridspec)N)F)r!   rr   rs   rt   r   r"   rv   r®   ru   r`   Úsetterr²   rN   r(   r,   r-   r·   r¸   r¹   rº   r   Zdelete_parameterr�   rK   r¿   rÁ   rÂ   r   r   r   r   r]     s4   

.





r]   )rt   rl   ÚloggingÚnumbersr   ÚnumpyrA   Z
matplotlibr€   r   r   r   r   Zmatplotlib.transformsr   Ú	getLoggerr!   Ú_logr   rO   r–   r]   r   r   r   r   Ú<module>   s   
  . 7