3
ƽh                 @   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 ddljZej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 )aa  
: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.

See the tutorial :ref:`sphx_glr_tutorials_intermediate_gridspec.py` for a
comprehensive usage guide.
    N)Integral)_pylab_helperscbook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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   sj   t |t s|dkr"td| t |t s6|dkrDtd| || | _| _| j| | j| 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 column 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   9/tmp/pip-build-7iwl8md4/matplotlib/matplotlib/gridspec.py__init__    s    
zGridSpecBase.__init__c             C   sR   | j d k	rd| j f nd}| jd k	r0d| jf nd}dj| jj| j| j|| dS )Nz, height_ratios=%r z, width_ratios=%rz&{clsname}({nrows}, {ncols}{optionals}))Zclsnamer   r   	optionals)_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   s   | j S )N)r   )r   r   r   r   <lambda>E   s    zGridSpecBase.<lambda>zThe number of rows in the grid.)docc             C   s   | j S )N)r   )r   r   r   r   r   G   s    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 )Nr   )r   figurer   r   r   get_subplot_paramsP   s    zGridSpecBase.get_subplot_params   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colspanZloc1loc2Zsubplotspecr   r   r   new_subplotspecT   s    zGridSpecBase.new_subplotspecc             C   s(   |dk	r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)``.
        NzTExpected the given number of width ratios to match the number of columns of the grid)lenr   r
   r   )r   r   r   r   r   r   d   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_ratiosp   s    zGridSpecBase.get_width_ratiosc             C   s(   |dk	r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)``.
        NzRExpected 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   x   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                s  | j  \}}|r*d}d}d}d}d}	d}
n.| j|}|j}|j}|j}|j}|j}	|j}
|| }|| }|||
|d    }|
| }| jdk	r|| t	| j   fdd| jD }n
|g| }dg|g|d   }t
jt
j||gj}|||	|d    }|	| }| jdk	r:|| t	| j   fdd| jD }n
|g| }dg|g|d   }t
jt
j||gj}|| jdj\}}|| 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$   Nc                s   g | ]}|  qS r   r   ).0r)normr   r   
<listcomp>   s    z3GridSpecBase.get_grid_positions.<locals>.<listcomp>r   c                s   g | ]}|  qS r   r   )r-   r.   )r/   r   r   r0      s       )r2   r1   r2   )r2   r1   )r!   r#   leftrightbottomtopwspacehspacer   sumnpZcumsumZcolumn_stackflatr   ZreshapeT)r   Zfigrawr   r   r3   r4   r5   r6   r7   r8   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   )r/   r   get_grid_positions   sH    



zGridSpecBase.get_grid_positionsc       
      C   s   | j  \}}dd }t|try|\}}W n, tk
rV } ztd|W Y dd}~X nX tj|||d|||dg||f\}}	n|||| d\}}	t| ||	S )z,Create and return a `.SubplotSpec` instance.c             S   s   | }t | tr<| j|\}}}||kr2||d fS tdnh| dk rL| | } d|   ko^|k n  rl| | fS |d k	rt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
   r:   Zravel_multi_indexSubplotSpec)
r   rF   r   r   rK   Zk1Zk2errnum1num2r   r   r   __getitem__   s    
zGridSpecBase.__getitem__T)sharexshareysqueeze
subplot_kwc            C   s  | j }|dkrtdt|tr,|r(dnd}t|trB|r>dnd}t|trVtjd tjddddg||d |dkrzi }|j }t	j
| j| jftd	}x~t| jD ]p}xjt| jD ]\}d|d ||d
f |d
|f d}	|	| |d< |	| |d< |j| ||f f||||f< qW qW |dkrdx@|ddddf jD ]&}
|
jjdddd |
jjjd q:W |dkrx@|ddddf jD ]&}
|
jjdddd |
jjjd qW |r|jdkr|j S |j S |S dS )aQ	  
        Add all subplots specified by this `GridSpec` to its parent figure.

        This utility wrapper makes it convenient to create common layouts of
        subplots in a single call.

        Parameters
        ----------
        sharex, sharey : bool or {'none', 'all', 'row', 'col'}, default: False
            Controls sharing of properties among x (*sharex*) or y (*sharey*)
            axes:

            - True or 'all': x- or y-axis will be shared among all subplots.
            - False or 'none': each subplot x- or y-axis will be independent.
            - 'row': each subplot row will share an x- or y-axis.
            - 'col': each subplot column will share an x- or y-axis.

            When subplots have a shared x-axis along a column, only the x tick
            labels of the bottom subplot are created. Similarly, when subplots
            have a shared y-axis along a row, only the y tick labels of the
            first column subplot are created. To later turn other subplots'
            ticklabels on, use `~matplotlib.axes.Axes.tick_params`.

        squeeze : bool, optional, default: True
            - If True, extra dimensions are squeezed out from the returned
              array of Axes:

              - if only one subplot is constructed (nrows=ncols=1), the
                resulting single Axes object is returned as a scalar.
              - for Nx1 or 1xM subplots, the returned object is a 1D numpy
                object array of Axes objects.
              - for NxM, subplots with N>1 and M>1 are returned as a 2D array.

            - If False, no squeezing at all is done: the returned Axes object
              is always a 2D array containing Axes instances, even if it ends
              up being 1x1.

        subplot_kw : dict, optional
            Dict with keywords passed to the `~.Figure.add_subplot` call used
            to create each subplot.

        Returns
        -------
        ax : `~.axes.Axes` object or array of Axes objects.
            *ax* can be either a single `~matplotlib.axes.Axes` object or
            an array of Axes objects if more than one subplot was created. The
            dimensions of the resulting array can be controlled with the
            squeeze keyword, see above.

        See Also
        --------
        .pyplot.subplots
        .Figure.add_subplot
        .pyplot.subplot
        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')?rowcol)rR   rS   )Zdtyper   )rW   rV   rX   rY   rR   rS   r$   ZbothF)whichZlabelbottomZlabeltop)rZ   Z	labelleftZ
labelright)r   r   )rY   rV   r2   )rX   rV   )r"   r
   r	   boolr   r   _warn_externalZ_check_in_listcopyr:   emptyr   r   objectrangeZadd_subplotr;   ZxaxisZset_tick_paramsZ
offsetTextZset_visibleZyaxisrG   itemrT   )r   rR   rS   rT   rU   r"   ZaxarrrX   rY   Zshared_withaxr   r   r   subplots   sJ    :



"



zGridSpecBase.subplots)NN)N)r$   r$   )F)r   
__module____qualname____doc__r   r   propertyr   r   r!   r#   r)   r   r+   r   r,   rB   rQ   rc   r   r   r   r   r      s$   



C%r   c            	   @   sV   e Zd ZdZdddZddddd	d
gZdd Zdd ZdddZdd Z	dddZ
dS )GridSpecz
    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             C   s   || _ || _|| _|| _|| _|	| _|| _tj| |||
|d | jdksT| jj	  r\d| _
n(| jj  tj| jj
d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 layoutbox.

        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 column gets a
            relative height of ``height_ratios[i] / sum(height_ratios)``.
            If not given, all rows will have the same height.

        )r   r   Ngridspec)parentnameartist)r3   r5   r4   r6   r7   r8   r"   r   r   Zget_constrained_layout
_layoutboxZinit_layoutbox	layoutbox	LayoutBoxseq_id)r   r   r   r"   r3   r5   r4   r6   r7   r8   r   r   r   r   r   r   r  s"    *


zGridSpec.__init__r3   r5   r4   r6   r7   r8   c             C   s   | j dd iS )Nrm   )__dict__)r   r   r   r   __getstate__  s    zGridSpec.__getstate__c             K   s  x:|j  D ].\}}|| jkr*t| || q
t| dq
W xtjjj D ]}x|jj	j
D ]}t|tj
jst|jtj
jr|jj j | kr|jj  |j|jj n:t|jtj
jr|jj j | kr|jj  |j|jj qZ|j j }|j | krZ|j  |j|j qZW qJW 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 keywordN)items_AllowedKeyssetattrAttributeErrorr   ZGcfZfigsvaluesZcanvasr"   axesr	   mplZSubplotBaseZ_sharexZget_subplotspecget_gridspecZupdate_paramsZ_set_positionfigboxZ_shareyget_topmost_subplotspec)r   kwargskvZ
figmanagerrb   ssr   r   r   update  s&    


zGridSpec.updatec                sT   |dkr(dd  j D }tjjf |}ntj|j}|jf  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   )r-   r~   r   r   r   
<dictcomp>  s    z/GridSpec.get_subplot_params.<locals>.<dictcomp>c                s   i | ]}t  ||qS r   )getattr)r-   r~   )r   r   r   r     s    )rt   ry   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   r0     s    z<GridSpec.locally_modified_subplot_params.<locals>.<listcomp>)rt   )r   r   )r   r   locally_modified_subplot_params  s    z(GridSpec.locally_modified_subplot_paramsHzG?c       	   
   C   sd   t j|j| d}d|kr"tjd |dkr4t j|}t j||j||||||d}|r`| jf | 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_listrx   r   r\   Zget_rendererZget_tight_layout_figurer   )	r   r"   Zrendererr   r   r   r   Zsubplotspec_listr}   r   r   r   r     s    


zGridSpec.tight_layout)	NNNNNNNNN)N)Nr   NNN)r   rd   re   rf   r   rt   rr   r   r#   r   r   r   r   r   r   rh   j  s      
?'
	 rh   c               @   s,   e Zd ZdZd	ddZd
ddZdd ZdS )GridSpecFromSubplotSpeczx
    GridSpec whose subplot layout parameters are inherited from the
    location specified by a given SubplotSpec.
    Nc       	      C   sn   || _ || _|| _| jj j| _tj| ||||d |j}|dkrJd| _n |j||j	d t
j  | d| _dS )a`  
        The number of rows and number of columns of the grid need to
        be set. An instance of SubplotSpec is also needed to be set
        from which the layout parameters will be inherited. The wspace
        and hspace of the layout can be optionally specified or the
        default values (from the figure or rcParams) will be used.
        )r   r   Nz	.gridspec)rk   rl   )_wspace_hspace_subplot_specrz   r"   r   r   rm   Zlayout_from_subplotspecrk   rn   rp   )	r   r   r   Zsubplot_specr7   r8   r   r   Z	subspeclbr   r   r   r   &  s    
z GridSpecFromSubplotSpec.__init__c       	      C   s   | j dk	r| j n|dk	r |jjntd }| jdk	r8| jn|dk	rH|jjntd }| jj|}|j\}}}}t	j
j||||||dS )z1Return a dictionary of subplot layout parameters.Nzfigure.subplot.hspacezfigure.subplot.wspace)r3   r4   r5   r6   r7   r8   )r   r   r8   r   r   r7   r   get_positionZextentsry   r"   r   )	r   r"   r8   r7   r{   r3   r5   r4   r6   r   r   r   r#   C  s    
z*GridSpecFromSubplotSpec.get_subplot_paramsc             C   s
   | j j S )zY
        Return the topmost `.SubplotSpec` instance associated with the subplot.
        )r   r|   )r   r   r   r   r|   S  s    z/GridSpecFromSubplotSpec.get_topmost_subplotspec)NNNN)N)r   rd   re   rf   r   r#   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dd Zejddddd Zedd Zedd Zd'ddZdd Zd d! Zd"d# Zd$d% ZdS )(rM   aX  
    Specifies 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   sN   || _ || _|| _|jd k	rD|j}tj||jd tj  | d| _nd | _d S )Nz.ss)rj   rk   rl   )	_gridspecrO   rP   rm   rn   ro   rk   rp   )r   ri   rO   rP   Zglbr   r   r   r   n  s    
zSubplotSpec.__init__c          
   C   s6   | j   d| jj d| jj d| jj d| jj d
S )N[:z, ])rz   r&   rH   rI   r'   )r   r   r   r   r     s    zSubplotSpec.__repr__c       
      C   s  d}t |dkr|\}t|tr$|S t|tsDtjd|d t|}yttt|\}}}W n$ t	k
r   t	d| dY nX t
||| d|d  S n2t |dkr|\}}}t|tot|tstjd|d tt||g\}}t
||| d}t|trZt |d	krZtd
d |D sBtjd|d tt|\}}	n|\}}	||d |	 S t|ts|tjd|d t|}|dk s||| krt	d||  d| ||d  S ntdt | 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.
        z{Passing non-integers as three-element position specification is deprecated since %(since)s and will be removed %(removal)s.r$   z3.3)messagez>Single argument to subplot must be a three-digit integer, not N)r"      r1   c             s   s   | ]}t |tV  qd S )N)r	   r   )r-   nr   r   r   	<genexpr>  s    z1SubplotSpec._from_subplot_args.<locals>.<genexpr>znum must be 1 <= num <= z, not z0subplot() takes 1 or 3 positional arguments but z were given)r*   r	   rM   r   r   warn_deprecatedstrmapintr
   rh   rL   rV   	TypeError)
r"   argsr   argrowscolsnumZgsijr   r   r   _from_subplot_args  sF    




zSubplotSpec._from_subplot_argsc             C   s   | j d kr| jS | j S )N)_num2rO   )r   r   r   r   rP     s    zSubplotSpec.num2c             C   s
   || _ d S )N)r   )r   valuer   r   r   rP     s    c             C   s   | j dd iS )Nrm   )rq   )r   r   r   r   rr     s    zSubplotSpec.__getstate__c             C   s   | j S )N)r   )r   r   r   r   rz     s    zSubplotSpec.get_gridspecc             C   s    | j  j \}}||| 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``).
        )rz   r!   rO   rP   )r   r   r   r   r   r   r!     s    zSubplotSpec.get_geometryz3.3zrowspan, colspan)alternativec             C   sD   | j  }|j \}}t| j|\}}t| j|\}}||||||fS )z
        Return the subplot row and column numbers as a tuple
        ``(n_rows, n_cols, row_start, row_stop, col_start, col_stop)``.
        )rz   r!   divmodrO   rP   )r   ri   r   r   Z	row_startZ	col_startZrow_stopZcol_stopr   r   r   get_rows_columns  s
    zSubplotSpec.get_rows_columnsc             C   s$   | j  j}t| j| | j| d S )z6The rows spanned by this subplot, as a `range` object.r$   )rz   r   r`   rO   rP   )r   r   r   r   r   r&     s    
zSubplotSpec.rowspanc             C   s4   | j  j}t| j| | j| g\}}t||d S )z9The columns spanned by this subplot, as a `range` object.r$   )rz   r   sortedrO   rP   r`   )r   r   Zc1c2r   r   r   r'     s    
zSubplotSpec.colspanFc             C   s   | j  }|j \}}tj| j| jg||f\}}|j|\}}	}
}|| j }|	| j }|
| j }|| j }t	j
||||}|r||d |d ||fS |S dS )zJ
        Update the subplot position from ``figure.subplotpars``.
        r   N)rz   r!   r:   Zunravel_indexrO   rP   rB   minmaxr   Zfrom_extents)r   r"   Z
return_allri   r   r   r   r   r?   r>   r@   rA   Z
fig_bottomZfig_topZfig_leftZ	fig_rightr{   r   r   r   r     s    zSubplotSpec.get_positionc             C   s"   | j  }t|dr|j S | S dS )zX
        Return the topmost `SubplotSpec` instance associated with the subplot.
        r|   N)rz   hasattrr|   )r   ri   r   r   r   r|     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   rO   rP   )r   rO   rP   r   r_   )r   otherr   r   r   __eq__  s    zSubplotSpec.__eq__c             C   s   t | j| j| jfS )N)hashr   rO   rP   )r   r   r   r   __hash__  s    zSubplotSpec.__hash__c             K   s   t ||| f|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   rd   re   rf   r   r   staticmethodr   rg   rP   setterrr   rz   r!   r   Z
deprecatedr   r&   r'   r   r|   r   r   r   r   r   r   r   rM   Z  s"   
7	

rM   )rf   r]   loggingnumbersr   numpyr:   Z
matplotlibry   r   r   r   r   Zmatplotlib.transformsr   Zmatplotlib._layoutboxrm   rn   	getLoggerr   _logr   rh   r   rM   r   r   r   r   <module>
   s    

  R 89