a
    ëÝEb  ã                   @   s\   d dl Zd dl mZmZ d dlmZ d dlmZmZ G dd„ dƒZ	e 
e	dd¡ZeeƒZdS )	é    N)Ú_apiÚcbook)ÚAxes)ÚGridSpecÚSubplotSpecc                   @   s6  e Zd ZdZdd„ Zejdddd�dd	„ ƒZejdd
d�dd„ ƒZdd„ Z	dd„ Z
dd„ Zejddd�edd„ ƒƒZejddd�edd„ ƒƒZejddd�edd„ ƒƒZe d¡dd„ ƒZejddd�d d!„ ƒZejdd"d�d#d$„ ƒZejdd%d�d&d'„ ƒZejdd(d�d)d*„ ƒZd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3S )4Ú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   Z_from_subplot_args)ÚselfZfigÚargsÚkwargs© r   úY/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/axes/_subplots.pyr
      s    zSubplotBase.__init__z3.4Úget_subplotspecz1(get_subplotspec returns a SubplotSpec instance.))ÚalternativeZaddendumc                 C   s"   |   ¡  ¡ \}}}}|||d fS )z*Get the subplot geometry, e.g., (2, 2, 3).r   )r   Úget_geometry)r   ÚrowsÚcolsZnum1Znum2r   r   r   r   &   s    zSubplotBase.get_geometryr   )r   c                 C   s2   t ||| jd�|d  | _|  ¡  |  | j¡ dS )z;Change subplot geometry, e.g., from (1, 1, 1) to (2, 2, 3).)Úfigurer   N)r   r   Ú_subplotspecÚupdate_paramsZset_positionÚfigbox)r   ZnumrowsZnumcolsÚnumr   r   r   Úchange_geometry.   s    ÿÿzSubplotBase.change_geometryc                 C   s   | j S )z?Return the `.SubplotSpec` instance associated with the subplot.)r   ©r   r   r   r   r   6   s    zSubplotBase.get_subplotspecc                 C   s   || _ |  | | j¡¡ dS )z=Set the `.SubplotSpec`. instance associated with the subplot.N)r   Z_set_positionÚget_positionr   )r   Z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_gridspeczget_position()c                 C   s   |   ¡ S ©N)r   r   r   r   r   r   C   s    zSubplotBase.figboxzget_gridspec().nrowsc                 C   s
   |   ¡ jS r   )r   Únrowsr   r   r   r   ÚnumRowsI   s    zSubplotBase.numRowszget_gridspec().ncolsc                 C   s
   |   ¡ jS r   )r   Úncolsr   r   r   r   ÚnumColsN   s    zSubplotBase.numColsc                 C   s   dS )z=Update the subplot position from ``self.figure.subplotpars``.Nr   r   r   r   r   r   S   s    zSubplotBase.update_paramsz#ax.get_subplotspec().is_first_row()c                 C   s   |   ¡ jjdkS ©Nr   )r   ÚrowspanÚstartr   r   r   r   Úis_first_rowY   s    zSubplotBase.is_first_rowz"ax.get_subplotspec().is_last_row()c                 C   s   |   ¡ jj|  ¡ jkS r   )r   r%   Ústopr   r    r   r   r   r   Úis_last_row]   s    zSubplotBase.is_last_rowz#ax.get_subplotspec().is_first_col()c                 C   s   |   ¡ jjdkS r$   )r   Úcolspanr&   r   r   r   r   Úis_first_cola   s    zSubplotBase.is_first_colz"ax.get_subplotspec().is_last_col()c                 C   s   |   ¡ jj|  ¡ jkS r   )r   r*   r(   r   r"   r   r   r   r   Úis_last_cole   s    zSubplotBase.is_last_colc                 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_outeri   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)r4   Zlabelbottomr   )Ú
isinstanceÚpatchÚmplÚpatchesÚ	Rectangler   ZxaxisÚget_label_positionr'   Z
set_xlabelÚset_tick_paramsÚ
offsetTextr   Úset_visibler)   ©r   r-   ÚssZlabel_positionr   r   r   r.   t   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Úleftr2   r3   F)r4   Z	labelleftr   Úright)r4   Z
labelrightr   )r6   r7   r8   r9   r:   r   Zyaxisr;   r+   Z
set_ylabelr<   r=   r   r>   r,   r?   r   r   r   r/   ‡   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.ZsharexZshareyz$Twinned Axes may share only one axisZdatalim)Ú
ValueErrorr   Zadd_subplotr   Zset_adjustableZ_twinned_axesÚjoin)r   r   r   Ztwinr   r   r   Ú_make_twin_axesš   s    

zSubplotBase._make_twin_axesN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   Ú
deprecatedr   r   r   r   r   Úpropertyr   r!   r#   r   r'   r)   r+   r,   r0   r.   r/   rE   r   r   r   r   r      sJ   þ

ÿ




r   z	{}Subplotr	   )Z
matplotlibr8   r   r   Zmatplotlib.axes._axesr   Zmatplotlib.gridspecr   r   r   Z_make_class_factoryZsubplot_class_factoryZSubplotr   r   r   r   Ú<module>   s    "ÿ