403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/matplotlib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/matplotlib/__pycache__/gridspec.cpython-310.pyc
o

�:�a�o�@s�dZddlZddlZddlmZddlZddlZddlm	Z	m
Z
mZmZddl
mZe�e�ZGdd�d�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
�ZdS)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�eZdZdZd'dd�Zdd�Zedd�d	d
�Zedd�dd
�Zd
d�Z	d(dd�Z
d)dd�Zdd�Zdd�Z
dd�Zdd�Zd*dd�Zedd ��Zd!d"�Zddd#dd$�d%d&�ZdS)+�GridSpecBasezm
    A base class of GridSpec that specifies the geometry of the grid
    that a subplot will be placed.
    NcCsft|t�r	|dkrtd|����t|t�r|dkr td|����|||_|_|�|�|�|�dS)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.
        rz/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�5/usr/lib/python3/dist-packages/matplotlib/gridspec.py�__init__!s��
zGridSpecBase.__init__cCsbtt|j��dkrd|jfnd}tt|j��dkr d|jfnd}dj|jj|j|j||d�S)N�z, height_ratios=%r�z, width_ratios=%rz&{clsname}({nrows}, {ncols}{optionals}))�clsnamerr�	optionals)	�len�set�_row_height_ratios�_col_width_ratios�format�	__class__�__name__rr)r�
height_arg�	width_argrrr�__repr__:s�����zGridSpecBase.__repr__cC�|jS�N)r�rrrr�<lambda>F�zGridSpecBase.<lambda>zThe number of rows in the grid.)�doccCr%r&)rr'rrrr(Hr)z"The number of columns in the grid.cCs|j|jfS)zW
        Return a tuple containing the number of rows and columns in the grid.
        )rrr'rrr�get_geometryKszGridSpecBase.get_geometrycCsdSr&r)r�figurerrr�get_subplot_paramsQszGridSpecBase.get_subplot_paramsrcCs(|\}}||||�|||�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�subplotspecrrr�new_subplotspecUszGridSpecBase.new_subplotspeccC�6|durdg|j}nt|�|jkrtd��||_dS)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)``.
        NrzTExpected the given number of width ratios to match the number of columns of the grid)rrr
r)rrrrrre�

zGridSpecBase.set_width_ratioscCr%)zo
        Return the width ratios.

        This is *None* if no width ratios have been set explicitly.
        )rr'rrr�get_width_ratioss�zGridSpecBase.get_width_ratioscCr5)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)``.
        NrzRExpected the given number of height ratios to match the number of rows of the grid)rrr
r)rrrrrr
{r6zGridSpecBase.set_height_ratioscCr%)zq
        Return the height ratios.

        This is *None* if no height ratios have been set explicitly.
        )rr'rrr�get_height_ratios�r8zGridSpecBase.get_height_ratiosFcst|��\}}|rd}d}d}d}d}	d}
n|�|�}|j}|j}|j}|j}|j}	|j}
||}||}
|
||
|d}|
|}||t|j	���fdd�|j	D�}dg|g|d}t
�t
�||g�j
�}|||	|d}|	|}||t|j���fdd�|jD�}dg|g|d}t
�t
�||g�j
�}||�d�j\}}||�d�j\}}||||fS)	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.
        gg�?rc�g|]}|��qSrr��.0�r��normrr�
<listcomp>��z3GridSpecBase.get_grid_positions.<locals>.<listcomp>rcr:rrr;r>rrr@�rA)����)r+r-�left�right�bottom�top�wspace�hspace�sumr�np�cumsum�column_stack�flatr�reshape�T)r�fig�rawrrrDrErFrGrHrI�subplot_params�	tot_width�
tot_height�cell_h�sep_h�cell_heights�sep_heights�cell_hs�cell_w�sep_w�cell_widths�
sep_widths�cell_ws�fig_tops�fig_bottoms�	fig_lefts�
fig_rightsrr>r�get_grid_positions�s@
zGridSpecBase.get_grid_positionscCs`|��D]$}t|d�r(|����}t|d�r|����}|��||fkr(|Sqt|||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,)�get_axes�hasattrre�get_gridspecrfr+�GridSpec)r,rr�ax�gsrrr�_check_gridspec_exists�s

�z#GridSpecBase._check_gridspec_existsc

Cs�|��\}}dd�}t|t�r<z|\}}Wnty&}ztd�|�d}~wwt�|||d�|||d�g||f�\}}	n
||||d�\}}	t|||	�S)z,Create and return a `.SubplotSpec` instance.cSs�|}t|t�r|�|�\}}}||kr||dfStd��|dkr%||}d|kr2|kr3||fS|durDtd|�d|�d|����td|�d|����)Nrz=GridSpec slice would result in no space allocated for subplotrzindex 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�_rrr�
_normalize�s(
�
��
�z,GridSpecBase.__getitem__.<locals>._normalizezUnrecognized subplot specNrr)r+r	�tupler
rK�ravel_multi_index�SubplotSpec)
rrrrrry�k1�k2�err�num1�num2rrr�__getitem__�s

��
�zGridSpecBase.__getitem__T)�sharex�sharey�squeeze�
subplot_kwcCsr|j}|durtd��t|t�r|rdnd}t|t�r!|rdnd}t|t�r+t�d�tjgd�||d�|dur;i}|��}t	j
|j|jft
d�}t|j�D]8}t|j�D]0}d|d	||d
f|d
|fd�}	|	||d<|	||d
<|j|||ffi|��|||f<qVqO|dvr�|jD]}
|
jdd�q�|dvr�|jD]}
|
jdd�q�|r�|jdkr�|��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�nonez]sharex argument to subplots() was an integer.  Did you intend to use subplot() (without 's')?)r��row�colr�)r�r�)�dtype)rrr)r�r�r�r�r�r�)r�r�T)�check_patch)r�r�r)r,r
r	�boolrr�
warn_external�
check_in_list�copyrK�emptyrr�object�range�add_subplotrN�_label_outer_xaxis�_label_outer_yaxisrs�itemr�)rr�r�r�r�r,�axarrr�r��shared_withrlrrr�subplotssP


�
��
���	

zGridSpecBase.subplots)NNr&)rr�F)r!�
__module__�__qualname__�__doc__rr$�propertyrrr+r-r4rr7r
r9rd�staticmethodrnr�r�rrrrrs0
��


=
%�rcsZeZdZdZ				d�fdd�	Zgd�Zdd�Zddd	�Zd
d�Z		dd
d�Z	�Z
S)rkz�
    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�dS)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.

        �rrN)	rDrFrErGrHrIr,�superr)rrrr,rDrFrErGrHrIrr�r rrrOs*

�zGridSpec.__init__)rDrFrErGrHrIcKs�|��D]\}}||jvrt|||�qt|�d���tjj��D](}|jj	j
D] }t|tj
j
�rH|����}|��|krH|�|���|j	��q(q!dS)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�Gcf�figs�values�canvasr,�axesr	�mpl�SubplotBasererfrj�
_set_position�get_position)r�kwargs�k�v�
figmanagerrl�ssrrr�update�s
����zGridSpec.updatecs\|durdd��jD�}tjjdi|��}nt�|j�}|jdi�fdd��jD���|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.*`
        NcSsi|]	}|td|�qS)zfigure.subplot.)r�r<r�rrr�
<dictcomp>��z/GridSpec.get_subplot_params.<locals>.<dictcomp>csi|]}|t�|��qSr��getattrr�r'rrr��sr)r�r�r,�
SubplotParamsr��subplotparsr�)rr,�kwr�rr'rr-�s
 zGridSpec.get_subplot_paramscs�fdd��jD�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`.
        csg|]	}t�|�r|�qSrr�r�r'rrr@�r�z<GridSpec.locally_modified_subplot_params.<locals>.<listcomp>)r�r'rr'r�locally_modified_subplot_params�sz(GridSpec.locally_modified_subplot_params�H�z�G�?c	
Csltj|j|d�}d|vrt�d�|durt�|�}tj||j||||||d�}|r4|jdi|��dSdS)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.
        )�	grid_specNzcThis figure includes Axes that are not compatible with tight_layout, so results might be incorrect.)�pad�h_pad�w_pad�rectr)r�get_subplotspec_listr�rr��get_renderer�get_tight_layout_figurer�)	rr,�rendererr�r�r�r��subplotspec_listr�rrrr�s�


��zGridSpec.tight_layout)	NNNNNNNNNr&)Nr�NNN)r!r�r�r�rr�r�r-r�r�
__classcell__rrr�rrkGs�6
	�rkcs8eZdZdZ		d	�fdd�	Zd
dd�Zdd�Z�ZS)�GridSpecFromSubplotSpeczx
    GridSpec whose subplot layout parameters are inherited from the
    location specified by a given SubplotSpec.
    Ncs8||_||_||_|j��j|_t�j||||d�dS)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.
        r�N)�_wspace�_hspace�
_subplot_specrjr,r�r)rrr�subplot_specrHrIrrr�rrr�s

�z GridSpecFromSubplotSpec.__init__c	Cs�|jdur|jn|dur|jjntd}|jdur|jn|dur$|jjntd}|j�|�}|j\}}}}t	j
j||||||d�S)z1Return a dictionary of subplot layout parameters.Nzfigure.subplot.hspacezfigure.subplot.wspace)rDrErFrGrHrI)r�r�rIrr�rHr�r��extentsr�r,r�)	rr,rIrH�figboxrDrFrErGrrrr-s��
�z*GridSpecFromSubplotSpec.get_subplot_paramscCs
|j��S)zY
        Return the topmost `.SubplotSpec` instance associated with the subplot.
        )r�rfr'rrrrfs
z/GridSpecFromSubplotSpec.get_topmost_subplotspec)NNNNr&)r!r�r�r�rr-rfr�rrr�rr��s�
r�c@s�eZdZdZd+dd�Zdd�Zedd��Zed	d
��Z	e	j
dd
��Z	dd
�Zdd�Zdd�Z
edd��Zedd��Zdd�Zdd�Zdd�Zdd�Ze�dd�d,d!d"��Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdS)-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.
    NcCs||_||_||_dSr&)�	_gridspecr�r�)r�gridspecr�r�rrrr/s
zSubplotSpec.__init__c
Cs6|���d|jj�d|jj�d|jj�d|jj�d�
S)N�[�:z, �])rjr/rvrwr0r'rrrr$4s
����zSubplotSpec.__repr__c	CsNt|�dkr8|\}t|t�r|St|t�std|����zttt|��\}}}Wn%ty7td|���d�wt|�dkrD|\}}}n
tdt|��d���t	�
|||�}|dur`t	|||d�}t|t�r�t|�dkr�td	d
�|D��s{td|����|\}}nt|t�r�|dks�|||kr�td||�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.
        rz>Single argument to subplot must be a three-digit integer, not N�z0subplot() takes 1 or 3 positional arguments but z were givenrgrCcss�|]}t|t�VqdSr&)r	r)r<�nrrr�	<genexpr>Ys�z1SubplotSpec._from_subplot_args.<locals>.<genexpr>z3Subplot specifier tuple must contain integers, not znum must be 1 <= num <= z, not )
rr	r|rr
�map�int�str�	TypeErrorrkrnrzr�)	r,�args�arg�rows�cols�numrm�i�jrrr�_from_subplot_args9sR

������
��
�zSubplotSpec._from_subplot_argscCs|jdur|jS|jSr&)�_num2r�r'rrrr�hszSubplotSpec.num2cCs
||_dSr&)r�)r�valuerrrr�ls
cCs
i|j�Sr&)�__dict__r'rrr�__getstate__ps
zSubplotSpec.__getstate__cCr%r&)r�r'rrrrjsszSubplotSpec.get_gridspeccCs |����\}}|||j|jfS)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``).
        )rjr+r�r�)rr�r�rrrr+vszSubplotSpec.get_geometrycCs$|��j}t|j||j|d�S)z6The rows spanned by this subplot, as a `range` object.r)rjrr�r�r�)rrrrrr/�s
zSubplotSpec.rowspancCs4|��j}t|j||j|g�\}}t||d�S)z9The columns spanned by this subplot, as a `range` object.r)rjr�sortedr�r�r�)rr�c1�c2rrrr0�s
zSubplotSpec.colspancC�|jjdkS�Nr)r/rvr'rrr�is_first_row��zSubplotSpec.is_first_rowcC�|jj|��jkSr&)r/rwrjrr'rrr�is_last_row��zSubplotSpec.is_last_rowcCr�r�)r0rvr'rrr�is_first_col�r�zSubplotSpec.is_first_colcCr�r&)r0rwrjrr'rrr�is_last_col�r�zSubplotSpec.is_last_colz3.4�
return_allFcCs�|��}|��\}}t�|j|jg||f�\}}|�|�\}}	}
}||��}|	|��}
|
|��}||��}t	�
||||
�}|rN||d|d||fS|S)zJ
        Update the subplot position from ``figure.subplotpars``.
        r)rjr+rK�
unravel_indexr�r�rd�min�maxr�from_extents)rr,r�r�rrr�r�rar`rbrc�
fig_bottom�fig_top�fig_left�	fig_rightr�rrrr��s
�zSubplotSpec.get_positioncCs|��}t|d�r
|��S|S)zX
        Return the topmost `SubplotSpec` instance associated with the subplot.
        rf)rjrirf)rr�rrrrf�s
z#SubplotSpec.get_topmost_subplotspeccCs8|j|j|jft|dt��t|dt��t|dt��fkS)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�r�)r�otherrrr�__eq__�s��zSubplotSpec.__eq__cCst|j|j|jf�Sr&)�hashr�r�r�r'rrr�__hash__�szSubplotSpec.__hash__cKst|||fi|��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�)rrrr�rrr�subgridspec�s(zSubplotSpec.subgridspecr&r�)r!r�r�r�rr$r�r�r�r��setterr�rjr+r/r0r�r�r�r�r�delete_parameterr�rfrrrrrrrr|s6

.





r|)r�r��logging�numbersr�numpyrK�
matplotlibr�rrrr�matplotlib.transformsr�	getLoggerr!�_logrrkr�r|rrrr�<module>s 

.7

Youez - 2016 - github.com/yon3zu
LinuXploit