a
    SicÚ  ã                   @   sT   d dl Zd dl mZ d dlmZ d dlmZ G dd„ dƒZe edd¡Z	e	eƒZ
dS )	é    N)Úcbook)ÚAxes)ÚSubplotSpecc                   @   sP   e Zd Z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 )ÚSubplotBasez¶
    Base class for subplots, which are :class:`Axes` instances with
    additional methods to facilitate generating and manipulating a set
    of :class:`Axes` within a figure.
    c                 O   s2   | j j| |g d¢fi |¤Ž |  t ||¡¡ dS )a›  
        Parameters
        ----------
        fig : `matplotlib.figure.Figure`

        *args : tuple (*nrows*, *ncols*, *index*) or int
            The array of subplots in the figure has dimensions ``(nrows,
            ncols)``, and *index* is the index of the subplot being created.
            *index* starts at 1 in the upper left corner and increases to the
            right.

            If *nrows*, *ncols*, and *index* are all single digit numbers, then
            *args* can be passed as a single 3-digit number (e.g. 234 for
            (2, 3, 4)).

        **kwargs
            Keyword arguments are passed to the Axes (sub)class constructor.
        )r   r   é   r   N)Ú_axes_classÚ__init__Úset_subplotspecr   Ú_from_subplot_args)ÚselfÚfigÚargsÚkwargs© r   úU/var/www/html/django/DPS/env/lib/python3.9/site-packages/matplotlib/axes/_subplots.pyr      s    zSubplotBase.__init__c                 C   s   | j S )z?Return the `.SubplotSpec` instance associated with the subplot.)Ú_subplotspec©r   r   r   r   Úget_subplotspec&   s    zSubplotBase.get_subplotspecc                 C   s   || _ |  | | j¡¡ dS )z=Set the `.SubplotSpec`. instance associated with the subplot.N)r   Ú_set_positionÚget_positionÚfigure)r   Úsubplotspecr   r   r   r	   *   s    zSubplotBase.set_subplotspecc                 C   s
   | j  ¡ S )z<Return the `.GridSpec` instance associated with the subplot.)r   Úget_gridspecr   r   r   r   r   /   s    zSubplotBase.get_gridspecc                 C   s   | j dd | jdd dS )a  
        Only show "outer" labels and tick labels.

        x-labels are only kept for subplots on the last row (or first row, if
        labels are on the top side); y-labels only for subplots on the first
        column (or last column, if labels are on the right side).
        F)Úcheck_patchN)Ú_label_outer_xaxisÚ_label_outer_yaxisr   r   r   r   Úlabel_outer3   s    zSubplotBase.label_outerc                C   sÆ   |rt | jtjjƒsd S |  ¡ }| j ¡ }| ¡ sv|dkrD|  	d¡ | jj
ddd | jj ¡ d dkrv| jj d¡ | ¡ sÂ|dkr|  	d¡ | jj
ddd | jj ¡ d d	krÂ| jj d¡ d S )
NÚtopÚ ÚbothF)ÚwhichZlabeltopr   Úbottom)r    Zlabelbottomr   )Ú
isinstanceÚpatchÚmplÚpatchesÚ	Rectangler   ÚxaxisÚget_label_positionZis_first_rowÚ
set_xlabelÚset_tick_paramsÚ
offsetTextr   Úset_visibleÚis_last_row©r   r   ÚssÚlabel_positionr   r   r   r   >   s     


zSubplotBase._label_outer_xaxisc                C   sÆ   |rt | jtjjƒsd S |  ¡ }| j ¡ }| ¡ sv|dkrD|  	d¡ | jj
ddd | jj ¡ d dkrv| jj d¡ | ¡ sÂ|dkr|  	d¡ | jj
ddd | jj ¡ d d	krÂ| jj d¡ d S )
NÚleftr   r   F)r    Z	labelleftr   Úright)r    Z
labelrightr   )r"   r#   r$   r%   r&   r   Úyaxisr(   Zis_first_colÚ
set_ylabelr*   r+   r   r,   Zis_last_colr.   r   r   r   r   Q   s     


zSubplotBase._label_outer_yaxisc                 O   st   d|v r0d|v r0|d | ur0|d | ur0t dƒ‚| jj|  ¡ g|¢R i |¤Ž}|  d¡ | d¡ | j | |¡ |S )z<Make a twinx axes of self. This is used for twinx and twiny.ÚsharexÚshareyz$Twinned Axes may share only one axisZdatalim)Ú
ValueErrorr   Úadd_subplotr   Zset_adjustableÚ_twinned_axesÚjoin)r   r   r   Ztwinr   r   r   Ú_make_twin_axesd   s    

zSubplotBase._make_twin_axesN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r	   r   r   r   r   r;   r   r   r   r   r      s   r   z	{}Subplotr   )Ú
matplotlibr$   r   Zmatplotlib.axes._axesr   Úmatplotlib.gridspecr   r   Ú_make_class_factoryÚsubplot_class_factoryÚSubplotr   r   r   r   Ú<module>   s   kÿ