
    G8c                     |    d dl Zd dl mZ d dlmZ d dlmZ  G d d      Z ej                  edd      Z	 e	e      Z
y)	    N)cbook)Axes)SubplotSpecc                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)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                      | j                   j                  | |g dfi | | j                  t        j                  ||             y)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kwargss       ;/usr/lib/python3/dist-packages/matplotlib/axes/_subplots.pyr   zSubplotBase.__init__   s>    ( 	"!!$\DVD[;;CFG    c                     | j                   S )z?Return the `.SubplotSpec` instance associated with the subplot.)_subplotspecr   s    r   get_subplotspeczSubplotBase.get_subplotspec&   s       r   c                 f    || _         | j                  |j                  | j                               y)z=Set the `.SubplotSpec`. instance associated with the subplot.N)r   _set_positionget_positionfigure)r   subplotspecs     r   r   zSubplotBase.set_subplotspec*   s'    ';33DKK@Ar   c                 6    | j                   j                         S )z<Return the `.GridSpec` instance associated with the subplot.)r   get_gridspecr   s    r   r   zSubplotBase.get_gridspec/   s      --//r   c                 L    | j                  d       | j                  d       y)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   s    r   label_outerzSubplotBase.label_outer3   s&     	E2E2r   c                   |r/t        | j                  t        j                  j                        sy | j                         }| j                  j                         }|j                         s|dk(  r| j                  d       | j                  j                  dd       | j                  j                  j                         d   dk(  r%| j                  j                  j                  d       |j                         s|dk(  r| j                  d       | j                  j                  dd       | j                  j                  j                         d   d	k(  r&| j                  j                  j                  d       y y y )
Ntop bothF)whichlabeltopr	   bottom)r(   labelbottomr   )
isinstancepatchmplpatches	Rectangler   xaxisget_label_positionis_first_row
set_xlabelset_tick_params
offsetTextr   set_visibleis_last_rowr   r    sslabel_positions       r   r!   zSubplotBase._label_outer_xaxis>   s#   z$**ckk6K6KL!!#668 &#JJ&&Ve&Dzz$$113A6!;

%%11%8~~)#JJ&&V&Gzz$$113A6!;

%%11%8 <	  r   c                   |r/t        | j                  t        j                  j                        sy | j                         }| j                  j                         }|j                         s|dk(  r| j                  d       | j                  j                  dd       | j                  j                  j                         d   dk(  r%| j                  j                  j                  d       |j                         s|dk(  r| j                  d       | j                  j                  dd       | j                  j                  j                         d   d	k(  r&| j                  j                  j                  d       y y y )
Nleftr&   r'   F)r(   	labelleftr   right)r(   
labelrightr	   )r,   r-   r.   r/   r0   r   yaxisr2   is_first_col
set_ylabelr5   r6   r   r7   is_last_colr9   s       r   r"   zSubplotBase._label_outer_yaxisQ   s#   z$**ckk6K6KL!!#668 '#JJ&&Vu&Ezz$$113A6!;

%%11%8~~(#JJ&&V&Fzz$$113A6!;

%%11%8 <	  r   c                     d|v rd|v r|d   | ur|d   | urt        d       | j                  j                  | j                         g|i |}| j	                  d       |j	                  d       | j
                  j                  | |       |S )z<Make a twinx axes of self. This is used for twinx and twiny.sharexshareyz$Twinned Axes may share only one axisdatalim)
ValueErrorr   add_subplotr   set_adjustable_twinned_axesjoin)r   r   r   twins       r   _make_twin_axeszSubplotBase._make_twin_axesd   s    v(f"4 ht+x0@0L !GHH&t{{&&t';';'=OOOI&I&d+r   N)__name__
__module____qualname____doc__r   r   r   r   r#   r!   r"   rO    r   r   r   r      s1    H0!B
0	39&9&r   r   z	{}Subplotr
   )
matplotlibr.   r   matplotlib.axes._axesr   matplotlib.gridspecr   r   _make_class_factorysubplot_class_factorySubplotrT   r   r   <module>r[      sD      & +h hV 211m- 

%r   