σ
 m[c           @` s1  d  d l  m Z m Z m Z m Z d  d l Z d  d l m Z d  d l m	 Z	 m
 Z
 d  d l m Z d  d l j Z d  d l m Z d  d l j Z d  d l Z d  d l m Z d e f d	     YZ i  Z d d
  Z e   Z d e f d     YZ e j j  d e j! e   e j j  d e j! e   d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   map(   t   GridSpect   SubplotSpec(   t	   docstring(   t   Axes(   t   mplDeprecationt   SubplotBasec           B` s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z RS(   uΆ   
    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` s΅  | |  _  t |  d k rΆ t | d t  r> | d |  _ qΰy2 t t | d   } t t |  \ } } } Wn t k
 r t d   n Xt	 | | d |  j  | d |  _ n*t |  d k rΝ| \ } } } t |  } t |  } t | t
  r`t |  d k r`g  | D] } t |  ^ q} t	 | | d |  j  | d d | d !|  _ qΰ| d k  s|| | | k r‘t d j d | | d	 |    n  t	 | | d |  j  t |  d |  _ n t d
 | f   |  j   |  j j |  | |  j |  |  j j d k r-d |  _ d |  _ n |  j j j d }	 |	 t j   }	 t j d |  j j d |	 d |   |  _ t j d |  j d |  j j d d t d t d |   |  _ d S(   u  
        *fig* is a :class:`matplotlib.figure.Figure` instance.

        *args* is the tuple (*numRows*, *numCols*, *plotNum*), where
        the array of subplots in the figure has dimensions *numRows*,
        *numCols*, and where *plotNum* is the number of the subplot
        being created.  *plotNum* starts at 1 in the upper left
        corner and increases to the right.

        If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
        decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
        i   i    u4   Single argument to subplot must be a 3-digit integert   figurei   i   u)   num must be 1 <= num <= {maxn}, not {num}t   maxnt   numu"   Illegal argument(s) to subplot: %su   .axt   parentt   namet   artistu   .post   post   subplotN(   R   t   lent
   isinstanceR   t   _subplotspect   strt   intR   t
   ValueErrorR   t   tuplet   formatt   update_paramst   _axes_classt   __init__t   figboxt
   _layoutboxt   Nonet   _poslayoutboxR   t	   layoutboxt   seq_idt	   LayoutBoxt   True(
   t   selft   figt   argst   kwargst   st   rowst   colsR   t   nR   (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyR      sT    	!	%	)
				c         C` s`   d   } g  |  j  j   D] } | |  r | ^ q d } t   | f |  j   g } t |  S(   Nc         S` s   t  |  t  o t  |  t  S(   N(   t
   issubclassR   R
   (   t   c(    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   not_subplotbased   s    i    (   t	   __class__t   mrot!   _PicklableSubplotClassConstructort   __getstate__R   (   R&   R0   R/   t
   axes_classt   r(    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt
   __reduce__`   s    	c         C` s/   |  j    j   \ } } } } | | | d f S(   u%   get the subplot geometry, e.g., 2,2,3i   (   t   get_subplotspect   get_geometry(   R&   R+   R,   t   num1t   num2(    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyR9   n   s    c         C` sA   t  | | d |  j | d |  _ |  j   |  j |  j  d S(   u2   change subplot geometry, e.g., from 1,1,1 to 2,2,3R   i   N(   R   R   R   R   t   set_positionR   (   R&   t   numrowst   numcolsR   (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   change_geometryt   s    
c         C` s   |  j  S(   u8   get the SubplotSpec instance associated with the subplot(   R   (   R&   (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyR8   {   s    c         C` s   | |  _  d S(   u8   set the SubplotSpec instance associated with the subplotN(   R   (   R&   t   subplotspec(    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   set_subplotspec   s    c         C` s@   |  j    j |  j d t \ |  _ |  _ |  _ |  _ |  _ d S(   u0   update the subplot position from fig.subplotparst
   return_allN(	   R8   t   get_positionR   R%   R   t   rowNumt   colNumt   numRowst   numCols(   R&   (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyR      s    c         C` s   |  j  d k S(   Ni    (   RE   (   R&   (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   is_first_col   s    c         C` s   |  j  d k S(   Ni    (   RD   (   R&   (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   is_first_row   s    c         C` s   |  j  |  j d k S(   Ni   (   RD   RF   (   R&   (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   is_last_row   s    c         C` s   |  j  |  j d k S(   Ni   (   RE   RG   (   R&   (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   is_last_col   s    c         C` sΞ   |  j    } |  j   } | sq x' |  j d d  D] } | j t  q1 W|  j   j   j t  |  j d  n  | sΚ x' |  j d d  D] } | j t  q W|  j	   j   j t  |  j
 d  n  d S(   u¨   Only show "outer" labels and tick labels.

        x-labels are only kept for subplots on the last row; y-labels only for
        subplots on the first column.
        t   whichu   bothu    N(   RJ   RH   t   get_xticklabelst   set_visiblet   Falset	   get_xaxist   get_offset_textt
   set_xlabelt   get_yticklabelst	   get_yaxist
   set_ylabel(   R&   t   lastrowt   firstcolt   label(    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   label_outer   s    c         O` s.  d d l  m } d | k rZ d | k rZ | d |  k	 rZ | d |  k	 rZ t d   qZ n  |  j   f | } | |  j | |  \ } } } t |  |  j | |  } |  j j |  |  j d  | j d  |  j d k	 r| j d k	 r| j j
 |  j  | j j
 |  j  n  |  j j |  |  | S(   uN   
        Make a twinx axes of self. This is used for twinx and twiny.
        i    (   t   process_projection_requirementsu   sharexu   shareyu%   Twinned Axes may share only one axis.u   datalimN(   t   matplotlib.projectionsRZ   R   R8   R   t   subplot_class_factoryt   add_subplott   set_adjustableR   R    t   constrain_sameR!   t   _twinned_axest   join(   R&   t   klR)   RZ   t   projection_classt   keyt   ax2(    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   _make_twin_axesͺ   s"     (   t   __name__t
   __module__t   __doc__R   R7   R9   R?   R8   RA   R   RH   RI   RJ   RK   RY   Rf   (    (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyR
      s   	G											c         C` sm   |  d  k r t }  n  t j |   } | d  k ri t t d  |  j t |  f i |  d 6 } | t |  <n  | S(   Nu	   %sSubplotu   _axes_class(   R    R   t   _subplot_classest   gett   typeR   Rg   R
   (   R5   t	   new_class(    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyR\   Ι   s    		R3   c           B` s   e  Z d  Z d   Z RS(   u¬   
    This stub class exists to return the appropriate subplot
    class when __call__-ed with an axes class. This is purely to
    allow Pickling of Axes and Subplots.
    c         C` s"   t    } t |  } | | _ | S(   N(   R3   R\   R1   (   R&   R5   t   subplot_instancet   subplot_class(    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   __call__ε   s    		(   Rg   Rh   Ri   Rp   (    (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyR3   ί   s   R   t   Subplot("   t
   __future__R    R   R   R   t   sixt	   six.movesR   t   matplotlib.gridspecR   R   t
   matplotlibR   t   matplotlib.artistR   t   martistt   matplotlib.axes._axesR   t   matplotlib._layoutboxR   R"   t   warningst   matplotlib.cbookR	   t   objectR
   Rj   R    R\   Rq   R3   t   interpdt   updatet   kwdoc(    (    (    s8   lib/python2.7/site-packages/matplotlib/axes/_subplots.pyt   <module>   s"   "΄	