U
    d»{jÚ  ã                   @   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| |ddddgf|Ž |  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   é   N)Ú_axes_classÚ__init__Úset_subplotspecr   Z_from_subplot_args)ÚselfZfigÚargsÚkwargs© r   úX/var/www/html/bwave/python/venv/lib/python3.8/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   Z_set_positionÚget_positionÚfigure)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_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   ZxaxisÚget_label_positionZis_first_rowZ
set_xlabelÚset_tick_paramsÚ
offsetTextr   Úset_visibleZis_last_row©r
   r   ÚssZ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   Zyaxisr#   Zis_first_colZ
set_ylabelr$   r%   r   r&   Zis_last_colr'   r   r   r   r   Q   s     


zSubplotBase._label_outer_yaxisc                 O   sn   d|kr0d|kr0|d | k	r0|d | k	r0t dƒ‚| jj|  ¡ f|ž|Ž}|  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_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   )Z
matplotlibr    r   Zmatplotlib.axes._axesr   Zmatplotlib.gridspecr   r   Z_make_class_factoryZsubplot_class_factoryZSubplotr   r   r   r   Ú<module>   s   k  ÿ