
 m[c           @` sm  d  Z  d d l m Z m Z m Z m Z d d l Z d d l m Z d d l	 j
 Z d d l m Z d d l m Z d e f d	     YZ d
 e f d     YZ d d l m Z m Z d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ i  Z d   Z d   Z e d e d  Z  d d l! m" Z" e e"  Z# d S(   u  
The axes_divider module provides helper classes to adjust the positions of
multiple axes at drawing time.

 Divider: this is the class that is used to calculate the axes
    position. It divides the given rectangular area into several sub
    rectangles. You initialize the divider by setting the horizontal
    and vertical lists of sizes that the division will be based on. You
    then use the new_locator method, whose return value is a callable
    object that can be used to set the axes_locator of the axes.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   map(   t   SubplotBasei   (   t	   axes_sizet   Dividerc           B` s
  e  Z d  Z d d d  Z d   Z d   Z d   Z e d    Z	 e d    Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z d   Z d   Z d d d d d  Z d d d  Z d   Z d d d  Z RS(   u  
    This class calculates the axes position. It
    divides the given rectangular area into several
    sub-rectangles. You initialize the divider by setting the
    horizontal and vertical lists of sizes
    (:mod:`mpl_toolkits.axes_grid.axes_size`) that the division will
    be based on. You then use the new_locator method to create a
    callable object that can be used as the axes_locator of the
    axes.
    u   Cc         C` sU   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ d |  _ d |  _ d |  _	 d S(   u  
        Parameters
        ----------
        fig : Figure
        pos : tuple of 4 floats
            position of the rectangle that will be divided
        horizontal : list of :mod:`~mpl_toolkits.axes_grid.axes_size`
            sizes for horizontal division
        vertical : list of :mod:`~mpl_toolkits.axes_grid.axes_size`
            sizes for vertical division
        aspect : bool
            if True, the overall rectangular area is reduced
            so that the relative part of the horizontal and
            vertical scales have the same scale.
        anchor : {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}
            placement of the reduced rectangle when *aspect* is True
        i    N(
   t   _figt   _post   _horizontalt	   _verticalt   _anchort   _aspectt
   _xrefindext
   _yrefindext   Nonet   _locator(   t   selft   figt   post
   horizontalt   verticalt   aspectt   anchor(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   __init__&   s    								c         C` s&   g  |  j    D] } | j |  ^ q S(   N(   t   get_horizontalt   get_size(   R   t   renderert   s(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   get_horizontal_sizesD   s    c         C` s&   g  |  j    D] } | j |  ^ q S(   N(   t   get_verticalR   (   R   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   get_vertical_sizesG   s    c         C` s>   d d l  m } | |  j    } | |  j    } | | f S(   Ni   (   t   AddList(   R   R!   R   R   (   R   R!   t   vsizet   hsize(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   get_vsize_hsizeJ   s    c         C` s]   d \ } } x( |  D]  \ } } | | 7} | | 7} q W| d k rU | | | } | Sd Sd  S(   Ng        (   g        g        (    (   t   lt
   total_sizet   rs_sumt   as_sumt   _rst   _ast   k(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   _calc_kS   s    
c         C` sA   d g } x1 |  D]) \ } } | j  | d | | |  q W| S(   Ng        i(   t   append(   R%   R+   t   offsetsR)   R*   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   _calc_offsetsb   s    	!c         C` s   | |  _  d S(   u   
        set the position of the rectangle.

        Parameters
        ----------
        pos : tuple of 4 floats
            position of the rectangle that will be divided
        N(   R	   (   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   set_positionn   s    	c         C` s   |  j  S(   u%   return the position of the rectangle.(   R	   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   get_positiony   s    c         C` sS   | t  j j k s$ t |  d k r0 | |  _ n t d d j t  j j    d S(   u  
        Parameters
        ----------
        anchor : {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}
            anchor position

          =====  ============
          value  description
          =====  ============
          'C'    Center
          'SW'   bottom left
          'S'    bottom
          'SE'   bottom right
          'E'    right
          'NE'   top right
          'N'    top
          'NW'   top left
          'W'    left
          =====  ============

        i   u   argument must be among %su   , N(   t   mtransformst   Bboxt   coefst   lenR   t
   ValueErrort   joint   BBox(   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt
   set_anchor}   s    $c         C` s   |  j  S(   u   return the anchor(   R   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt
   get_anchor   s    c         C` s   | |  _  d S(   u   
        Parameters
        ----------
        h : list of :mod:`~mpl_toolkits.axes_grid.axes_size`
            sizes for horizontal division
        N(   R
   (   R   t   h(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   set_horizontal   s    c         C` s   |  j  S(   u   return horizontal sizes(   R
   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR      s    c         C` s   | |  _  d S(   u   
        Parameters
        ----------
        v : list of :mod:`~mpl_toolkits.axes_grid.axes_size`
            sizes for vertical division
        N(   R   (   R   t   v(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   set_vertical   s    c         C` s   |  j  S(   u   return vertical sizes(   R   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR      s    c         C` s   | |  _  d S(   uE   
        Parameters
        ----------
        aspect : bool
        N(   R   (   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt
   set_aspect   s    c         C` s   |  j  S(   u   return aspect(   R   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt
   get_aspect   s    c         C` s   | |  _  d  S(   N(   R   (   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   set_locator   s    c         C` s   |  j  S(   N(   R   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   get_locator   s    c         C` s0   |  j  d  k r |  j   S|  j  | |  j Sd  S(   N(   R   R   R1   t   bounds(   R   t   axR   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   get_position_runtime   s    
c         C` s  |  j  j   \ } } |  j | |  \ }	 }
 } } |  j |  } |  j |  } |  j | | |  } |  j | | |  } |  j   rLt | |  } |  j | |  } |  j | |  } | d | d | } | d | d | } t	 j
 j |	 |
 | |  } t	 j
 j |	 |
 | |  } | j |  j   |  } | j | j } } n1 |  j | |  } |  j | |  } |	 |
 } } | d k r| d } n  | d k r| d } n  | | | | | | | | | } } | | | | | | | | | } } t	 j
 j | | | |  S(   u  
        Parameters
        ----------
        nx, nx1 : int
            Integers specifying the column-position of the
            cell. When *nx1* is None, a single *nx*-th column is
            specified. Otherwise location of columns spanning between *nx*
            to *nx1* (but excluding *nx1*-th column) is specified.
        ny, ny1 : int
            Same as *nx* and *nx1*, but for row positions.
        axes
        renderer
        ii    i   N(   R   t   get_size_inchesRE   R   R    R,   R@   t   minR/   R2   R3   t   from_boundst   anchoredR:   t   x0t   y0R   (   R   t   nxt   nyt   nx1t   ny1t   axesR   t   figWt   figHt   xt   yt   wR;   t   hsizest   vsizest   k_ht   k_vR+   t   oxt   oyt   wwt   hht   pbt   pb1t   pb1_anchoredRJ   RK   t   x1t   w1t   y1t   h1(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   locate   s4    ))c         C` s   t  |  | | | |  S(   u  
        Returns a new locator
        (:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
        specified cell.

        Parameters
        ----------
        nx, nx1 : int
            Integers specifying the column-position of the
            cell. When *nx1* is None, a single *nx*-th column is
            specified. Otherwise location of columns spanning between *nx*
            to *nx1* (but excluding *nx1*-th column) is specified.
        ny, ny1 : int
            Same as *nx* and *nx1*, but for row positions.
        (   t   AxesLocator(   R   RL   RM   RN   RO   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   new_locator  s    c         C` s   | d k r1 |  j  j d |  |  j d 7_ n | d k rP |  j  j |  n` | d k r |  j j d |  |  j d 7_ n/ | d k r |  j j |  n t d d   d  S(	   Nu   lefti    i   u   rightu   bottomu   topu!   the position must be one of left,u    right, bottom, or top(   R
   t   insertR   R-   R   R   R6   (   R   t   positiont   size(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   append_size  s    g?c         C` s   | d  k r! d d d d g } n  d d l m } m } m } xH | D]@ } | | |  } | |  }	 | |	 |  }
 |  j | |
  qD Wd  S(   Nu   leftu   rightu   bottomu   topi   (   t   Paddedt   SizeFromFunct   GetExtentHelper(   R   R   Rl   Rm   Rn   Rk   (   R   t   use_axest   padt   adjust_dirsRl   Rm   Rn   t   dt   helperRj   t   padded_size(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   add_auto_adjustable_area#  s    N(   t   __name__t
   __module__t   __doc__R   R   R   R    R$   t   staticmethodR,   R/   R0   R1   R9   R:   R<   R   R>   R   t   FalseR?   R@   RA   RB   RE   Re   Rg   Rk   Ru   (    (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR      s2   
																		2	Rf   c           B` s/   e  Z d  Z d d d  Z d   Z d   Z RS(   u|   
    A simple callable object, initialized with AxesDivider class,
    returns the position and size of the given cell.
    c         C` s   | |  _  | j } | j } | | | | |  _ |  _ | d k rO | d } n  | d k rh | d } n  | | |  _ | | |  _ d S(   u  
        Parameters
        ----------
        axes_divider : AxesDivider
        nx, nx1 : int
            Integers specifying the column-position of the
            cell. When *nx1* is None, a single *nx*-th column is
            specified. Otherwise location of columns spanning between *nx*
            to *nx1* (but excluding *nx1*-th column) is specified.
        ny, ny1 : int
            Same as *nx* and *nx1*, but for row positions.
        i   N(   t   _axes_dividerR   R   t   _nxt   _nyR   t   _nx1t   _ny1(   R   t   axes_dividerRL   RM   RN   RO   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR   6  s    			c         C` sS   |  j  j } |  j  j } |  j  j |  j | |  j | |  j | |  j | | |  S(   N(   R{   R   R   Re   R|   R}   R~   R   (   R   RP   R   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   __call__R  s    


c         C` s'   t  |  j d  r |  j j   Sd  Sd  S(   Nu   get_subplotspec(   t   hasattrR{   t   get_subplotspecR   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR   ^  s    N(   Rv   Rw   Rx   R   R   R   R   (    (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyRf   1  s   	(   t   SubplotSpect   GridSpect   SubplotDividerc           B` sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   uT   
    The Divider class whose rectangle area is specified as a subplot geometry.
    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 |  _ n t |  d k rq| \ } } } t |  } t |  } t | t
  rNt |  d k rNg  | D] } t |  ^ q} t	 | |  | d d | d !|  _ qt	 | |  t |  d |  _ n t d | f   |  j   |  j j }	 | j d g   }
 | j d g   } | j d	 d  } | j d
 d  } | rt d   n  t j |  | |	 |
 | d | d | d S(   u+  
        Parameters
        ----------
        fig : :class:`matplotlib.figure.Figure`
        args : tuple (*numRows*, *numCols*, *plotNum*)
            The array of subplots in the figure has dimensions *numRows*,
            *numCols*, and *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 integeri   i   u"   Illegal argument(s) to subplot: %su
   horizontalu   verticalu   aspectu   anchoru   Cu    R   R   N(   t   figureR5   t
   isinstanceR   t   _subplotspect   strt   intR   R6   R   t   tuplet   update_paramst   figboxRC   t   popR   t	   ExceptionR   R   (   R   R   t   argst   kwargsR   t   rowst   colst   numt   nR   R   R   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR   m  s<    	!(#
c         C` s   |  j    |  j j S(   u$   return the bounds of the subplot box(   R   R   RC   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR1     s    
c         C` s   |  j    j |  j  |  _ d S(   u0   update the subplot position from fig.subplotparsN(   R   R1   R   R   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s    c         C` s/   |  j    j   \ } } } } | | | d f S(   u%   get the subplot geometry, e.g., 2,2,3i   (   R   t   get_geometry(   R   R   R   t   num1t   num2(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s    c         C` s8   t  | |  | d |  _ |  j   |  j |  j  d S(   u2   change subplot geometry, e.g., from 1,1,1 to 2,2,3i   N(   R   R   R   R0   R   (   R   t   numrowst   numcolsR   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   change_geometry  s    
c         C` s   |  j  S(   u   get the SubplotSpec instance(   R   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s    c         C` s   | |  _  d S(   u   set the SubplotSpec instanceN(   R   (   R   t   subplotspec(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   set_subplotspec  s    (
   Rv   Rw   Rx   R   R1   R   R   R   R   R   (    (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR   h  s   	E	%				t   AxesDividerc           B` sw   e  Z d  Z d
 d
 d  Z d   Z d
 e d  Z d
 e d  Z d
 e	 d  Z
 d   Z d   Z d   Z d	   Z RS(   u1   
    Divider based on the pre-existing axes.
    c         C` s   | |  _  | d k r* t j |  |  _ n	 | |  _ | d k rT t j |  |  _ n	 | |  _ t j |  d | j	   d d d |  j g d |  j g d d d d d S(	   uw   
        Parameters
        ----------
        axes : :class:`~matplotlib.axes.Axes`
        xref
        yref
        R   R   R   R   R   R   u   CN(
   t   _axesR   t   Sizet   AxesXt   _xreft   AxesYt   _yrefR   R   t
   get_figure(   R   RP   t   xreft   yref(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s    			c         K` sy   |  j  } | j d d   } | d  k rQ t | t  rB | j } qQ t |  } n  | | j   | j d t	  |  } | S(   Nu
   axes_classt   original(
   R   R   R   R   R   t   _axes_classt   typeR   R1   t   True(   R   R   RP   t
   axes_classRD   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   _get_new_axes  s    	c         K` s<  | rq t  | t j  s3 t j | d |  j } n  | r^ |  j j d |  |  j d 7_ qq |  j j |  n  t  | t j  s t j | d |  j } n  | r |  j j d |  |  j d 7_ |  j	 d d d |  j
  } n8 |  j j |  |  j	 d t |  j  d d |  j
  } |  j |   } | j |  | S(   u  
        Add a new axes on the right (or left) side of the main axes.

        Parameters
        ----------
        size : :mod:`~mpl_toolkits.axes_grid.axes_size` or float or string
            A width of the axes. If float or string is given, *from_any*
            function is used to create the size, with *ref_size* set to AxesX
            instance of the current axes.
        pad : :mod:`~mpl_toolkits.axes_grid.axes_size` or float or string
            Pad between the axes. It takes same argument as *size*.
        pack_start : bool
            If False, the new axes is appended at the end
            of the list, i.e., it became the right-most axes. If True, it is
            inserted at the start of the list, and becomes the left-most axes.
        kwargs
            All extra keywords arguments are passed to the created axes.
            If *axes_class* is given, the new axes will be created as an
            instance of the given class. Otherwise, the same class of the
            main axes will be used.
        t   fraction_refi    i   RL   RM   (   R   R   t   _Baset   from_anyR   R
   Rh   R   R-   Rg   R   R5   R   t   set_axes_locator(   R   Rj   Rp   t
   pack_startR   t   locatorRD   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   new_horizontal  s(    (c         K` s<  | rq t  | t j  s3 t j | d |  j } n  | r^ |  j j d |  |  j d 7_ qq |  j j |  n  t  | t j  s t j | d |  j } n  | r |  j j d |  |  j d 7_ |  j	 d |  j
 d d  } n8 |  j j |  |  j	 d |  j
 d t |  j  d  } |  j |   } | j |  | S(   u  
        Add a new axes on the top (or bottom) side of the main axes.

        Parameters
        ----------
        size : :mod:`~mpl_toolkits.axes_grid.axes_size` or float or string
            A height of the axes. If float or string is given, *from_any*
            function is used to create the size, with *ref_size* set to AxesX
            instance of the current axes.
        pad : :mod:`~mpl_toolkits.axes_grid.axes_size` or float or string
            Pad between the axes. It takes same argument as *size*.
        pack_start : bool
            If False, the new axes is appended at the end
            of the list, i.e., it became the right-most axes. If True, it is
            inserted at the start of the list, and becomes the left-most axes.
        kwargs
            All extra keywords arguments are passed to the created axes.
            If *axes_class* is given, the new axes will be created as an
            instance of the given class. Otherwise, the same class of the
            main axes will be used.
        R   i    i   RL   RM   (   R   R   R   R   R   R   Rh   R   R-   Rg   R   R5   R   R   (   R   Rj   Rp   R   R   R   RD   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   new_verticalN  s(    (c         K` s   | d k r* |  j  | | d t | } n | d k rT |  j  | | d t | } nd | d k r~ |  j | | d t | } n: | d k r |  j | | d t | } n t d d   | r |  j j |  n  | S(   u   
        create an axes at the given *position* with the same height
        (or width) of the main axes.

         *position*
           ["left"|"right"|"bottom"|"top"]

         *size* and *pad* should be axes_grid.axes_size compatible.
        u   leftR   u   rightu   bottomu   topu!   the position must be one of left,u    right, bottom, or top(   R   R   Rz   R   R6   R   t   add_axes(   R   Ri   Rj   Rp   t   add_to_figureR   RD   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   append_axes  s    
c         C` s@   |  j  d  k r5 |  j j   } | d k r. t St Sn |  j  Sd  S(   Nu   auto(   R   R   R   R@   Rz   R   (   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR@     s    c         C` s6   |  j  d  k r+ |  j j d t  } | j S|  j  Sd  S(   NR   (   R	   R   R   R1   R   RC   (   R   t   bbox(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR1     s    c         C` s'   |  j  d  k r |  j j   S|  j  Sd  S(   N(   R   R   R   R:   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR:     s    c         C` s'   t  |  j d  r |  j j   Sd  Sd  S(   Nu   get_subplotspec(   R   R   R   R   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s    N(   Rv   Rw   Rx   R   R   R   Rz   R   R   R   R   R@   R1   R:   R   (    (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s   	22	
		t   HBoxDividerc           B` sY   e  Z d    Z e d    Z e d    Z d d  Z d   Z d d d d d  Z	 RS(   c         O` s   t  j |  | | |  d  S(   N(   R   R   (   R   R   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s    c         C` s  t  |   } d d  l } | j | j | d | d f d d  } | j | d d d } xK t |   D]= \ } \ }	 }
 |	 | | | f <d | | d f <|
 | | <qj Wg  | D] \ }	 }
 |	 ^ q | d d  d  f <| t g  | D] \ } }
 |
 ^ q  | d <| j | j |  j j } | d  } | d } | | k r| | j	 g  |  D] \ }	 }
 |
 ^ qS | j	 g  |  D] \ }	 }
 |	 ^ qy } n  | S(   Ni    i   t   dtypeu   di(
   R5   t   numpyt   matt   zerost	   enumeratet   sumt   It   Tt   A1t   array(   t   equivalent_sizest   appended_sizest   max_equivalent_sizet   total_appended_sizeR   t   npt   At   Bt   it   rt   at   rst   karray_Ht   karrayt   H(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   _determine_karray  s$    ,/-

&,c         C` sP   d g } x@ t  |  |  D]/ \ \ } } } | j | d | | |  q W| S(   Ng        i(   t   zipR-   (   R   R   R.   R   R   R+   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR/     s    	"!c         C` s   t  |  | d | d  S(   u  
        returns a new locator
        (:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
        specified cell.

        Parameters
        ----------
        nx, nx1 : int
            Integers specifying the column-position of the
            cell. When *nx1* is None, a single *nx*-th column is
            specified. Otherwise location of columns spanning between *nx*
            to *nx1* (but excluding *nx1*-th column) is specified.
        ny, ny1 : int
            Same as *nx* and *nx1*, but for row positions.
        i    N(   Rf   R   (   R   RL   RN   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyRg     s    c	         C` s   | }	 | }
 | | } | | } |  j  |	 |
 | |  } |  j |
 |  } | d | d | } |	 d } | d | d | d | } t j j | | | |  } t j j | | | |  } | j |  j   |  } | j | j } } | | | | f S(   u   
        Parameters
        ----------
        x
        y
        w
        h
        y_equivalent_sizes
        x_appended_sizes
        figW
        figH
        ii    i   (	   R   R/   R2   R3   RH   RI   R:   RJ   RK   (   R   RS   RT   RU   R;   t   y_equivalent_sizest   x_appended_sizesRQ   RR   R   R   R   R   R   RZ   R\   t   ref_hR]   R^   R_   R`   RJ   RK   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   _locate  s     

	
c      	   C` s   |  j  j   \ } } |  j | |  \ }	 }
 } } |  j |  } |  j |  } |  j |	 |
 | | | | | |  \ } } } } | d k r | d } n  | | | | | | | | | } } | | } } t j j	 | | | |  S(   u  
        Parameters
        ----------
        axes_divider : AxesDivider
        nx, nx1 : int
            Integers specifying the column-position of the
            cell. When *nx1* is None, a single *nx*-th column is
            specified. Otherwise location of columns spanning between *nx*
            to *nx1* (but excluding *nx1*-th column) is specified.
        ny, ny1 : int
            Same as *nx* and *nx1*, but for row positions.
        axes
        renderer
        i   N(
   R   RF   RE   R    R   R   R   R2   R3   RH   (   R   RL   RM   RN   RO   RP   R   RQ   RR   RS   RT   RU   R;   R   R   RJ   RK   RZ   R]   Ra   Rb   Rc   Rd   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyRe     s    )N(
   Rv   Rw   R   Ry   R   R/   R   Rg   R   Re   (    (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s   	
	%t   VBoxDividerc           B` s/   e  Z d  Z d d  Z d d d d d  Z RS(   uT   
    The Divider class whose rectangle area is specified as a subplot geometry.
    c         C` s   t  |  d | d |  S(   u  
        returns a new locator
        (:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
        specified cell.

        Parameters
        ----------
        ny, ny1 : int
            Integers specifying the row-position of the
            cell. When *ny1* is None, a single *ny*-th row is
            specified. Otherwise location of rows spanning between *ny*
            to *ny1* (but excluding *ny1*-th row) is specified.
        i    N(   Rf   R   (   R   RM   RO   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyRg   C  s    c      	   C` s   |  j  j   \ } } |  j | |  \ }	 }
 } } |  j |  } |  j |  } |  j |
 |	 | | | | | |  \ } } } } | d k r | d } n  | | } } | | | | | | | | | } } t j j	 | | | |  S(   u  
        Parameters
        ----------
        axes_divider : AxesDivider
        nx, nx1 : int
            Integers specifying the column-position of the
            cell. When *nx1* is None, a single *nx*-th column is
            specified. Otherwise location of columns spanning between *nx*
            to *nx1* (but excluding *nx1*-th column) is specified.
        ny, ny1 : int
            Same as *nx* and *nx1*, but for row positions.
        axes
        renderer
        i   N(
   R   RF   RE   R   R    R   R   R2   R3   RH   (   R   RL   RM   RN   RO   RP   R   RQ   RR   RS   RT   RU   R;   t   x_equivalent_sizest   y_appended_sizesRK   RJ   R[   R\   Ra   Rb   Rc   Rd   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyRe   S  s    )N(   Rv   Rw   Rx   R   Rg   Re   (    (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR   >  s   t   LocatableAxesBasec           B` sG   e  Z d    Z d   Z d   Z d d  Z d e d  Z d   Z	 RS(   c         O` s,   |  j  j |  | |  d  |  _ d  |  _ d  S(   N(   R   R   R   R   t   _locator_renderer(   R   t   klt   kw(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR   v  s    	c         C` s   | |  _  d  S(   N(   R   (   R   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR   }  s    c         C` s   |  j  S(   N(   R   (   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   get_axes_locator  s    c         C` sZ   |  j    d  k r( |  j j |  |  n. |  j    |  |  j  } |  j j |  d | d  S(   NRi   (   R   R   R   t   apply_aspectR   (   R   Ri   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s    c         C` s#   | |  _  |  j j |  | |  d  S(   N(   R   R   t   draw(   R   R   t   inframe(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR     s    	c         O` s   d | k r' d | k r' t  d   n  t |   |  j |  j t  | |  } | j |  j    |  j j |  |  j d  | j d  |  j	 j
 |  |  | S(   uY   
        Need to overload so that twinx/twiny will work with
        these axes.
        u   sharexu   shareyu%   Twinned Axes may share only one axis.u   datalim(   R6   R   R   R1   R   R   R   R   t   set_adjustablet   _twinned_axesR7   (   R   R   R   t   ax2(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   _make_twin_axes  s    'N(
   Rv   Rw   R   R   R   R   R   Rz   R   R   (    (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyR   u  s   			c         C` sX   t  j |   } | d  k rT t t d |  j  t |  f i |  d 6 } | t  |  <n  | S(   Nu   Locatable%su   _axes_class(   t   _locatableaxes_classest   getR   R   R   Rv   R   (   R   t	   new_class(    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   locatable_axes_factory  s    	c         C` sb   t  |  d  s- t t |    } | |  _ n  t |   } | j d d d d  } |  j |  | S(   Nu   set_axes_locatorRL   i    RM   (   R   R   R   t	   __class__R   Rg   R   (   RP   R   t   dividerR   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   make_axes_locatable  s    g?c         C` sb   | d  k r! d d d d g } n  t |   } | d  k rB |  } n  | j d | d | d |  d  S(   Nu   leftu   rightu   bottomu   topRo   Rp   Rq   (   R   R   Ru   (   RD   Ro   Rp   Rq   R   (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   make_axes_area_auto_adjustable  s    	(   t   Axes($   Rx   t
   __future__R    R   R   R   t   sixt	   six.movesR   t   matplotlib.transformst
   transformsR2   t   matplotlib.axesR   t    R   R   t   objectR   Rf   t   matplotlib.gridspecR   R   R   R   R   R   R   R   R   R   R   R   t   mpl_axesR   t   LocatableAxes(    (    (    sC   lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_divider.pyt   <module>   s,   " 47+		