ó
ÄCõRc           @  s´   d  Z  d d l m Z m Z d d l Z e j Z d d l j Z d d l	 Z
 d d l Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d S(   sÍ  
:mod:`~matplotlib.gridspec` is a module which specifies the location
of the subplot in the figure.

    ``GridSpec``
        specifies the geometry of the grid that a subplot will be
        placed. The number of rows and number of columns of the grid
        need to be set. Optionally, the subplot layout parameters
        (e.g., left, right, etc.) can be tuned.

    ``SubplotSpec``
        specifies the location of the subplot in the given *GridSpec*.


iÿÿÿÿ(   t   divisiont   print_functionNt   GridSpecBasec           B  sw   e  Z d  Z d d d „ Z d „  Z d d „ Z d d d „ Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z RS(   sm   
    A base class of GridSpec that specifies the geometry of the grid
    that a subplot will be placed.
    c         C  s1   | | |  _  |  _ |  j | ƒ |  j | ƒ d S(   s¸   
        The number of rows and number of columns of the grid need to
        be set. Optionally, the ratio of heights and widths of rows and
        columns can be specified.
        N(   t   _nrowst   _ncolst   set_height_ratiost   set_width_ratios(   t   selft   nrowst   ncolst   height_ratiost   width_ratios(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   __init__!   s    c         C  s   |  j  |  j f S(   s$   get the geometry of the grid, eg 2,3(   R   R   (   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   get_geometry.   s    c         C  s   d  S(   N(    (   R   t   fig(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   get_subplot_params2   s    i   c         C  s4   | \ } } |  | | | … | | | … f } | S(   s:   
        create and return a SuplotSpec instance.
        (    (   R   t   loct   rowspant   colspant   loc1t   loc2t   subplotspec(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   new_subplotspec5   s    $c         C  s   | |  _  d  S(   N(   t   _col_width_ratios(   R   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR   >   s    c         C  s   |  j  S(   N(   R   (   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   get_width_ratiosA   s    c         C  s   | |  _  d  S(   N(   t   _row_height_ratios(   R   R
   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR   D   s    c         C  s   |  j  S(   N(   R   (   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   get_height_ratiosG   s    c   !      C  s«  |  j  ƒ  \ } } |  j | ƒ } | j } | j } | j } | j } | j }	 | j }
 | | } | | } | | |
 | d } |
 | } |  j d k	 rà | | } t
 t |  j ƒ ƒ } g  |  j D] } | | | ^ qÃ } n | g | } d g | g | d } t j j t j t | | ƒ ƒ ƒ } | | |	 | d } |	 | } |  j d k	 rž| | } t
 t |  j ƒ ƒ } g  |  j D] } | | | ^ q�} n | g | } d g | g | d } t j j t j t | | ƒ ƒ ƒ } g  t | ƒ D] } | | d | ^ qô} g  t | ƒ D] } | | d | d ^ q} g  t | ƒ D] } | | d | ^ qN} g  t | ƒ D] } | | d | d ^ qy}  | | | |  f S(   so   
        return lists of bottom and top position of rows, left and
        right positions of columns.
        i   i    i   N(   R   R   t   leftt   rightt   bottomt   topt   wspacet   hspaceR   t   Nonet   floatt   sumt   npt   addt
   accumulatet   ravelt   zipR   t   range(!   R   R   R   R	   t   subplot_paramsR   R   R   R   R   R    t   totWidtht	   totHeightt   cellHt   sepHt	   netHeightt   trt   rt   cellHeightst
   sepHeightst   cellHst   cellWt   sepWt   netWidtht
   cellWidthst	   sepWidthst   cellWst   rowNumt   figTopst
   figBottomst   colNumt   figLeftst	   figRights(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   get_grid_positionsK   sB    						



'$

'$+/+/c         C  s	  |  j  ƒ  \ } } | | } t | t ƒ rxy | \ } } Wn t k
 rZ t d ƒ ‚ n Xt | t ƒ r… | j | ƒ \ } } }	 nQ | d k  rž | | 7} n  | | k s¶ | d k  rÅ t d ƒ ‚ n  | | d } } t | t ƒ r | j | ƒ \ }
 } }	 nQ | d k  r| | 7} n  | | k s1| d k  r@t d ƒ ‚ n  | | d }
 } | | |
 } | d | | d } n� t | t ƒ r¬| j | ƒ \ } } }	 | d 8} nM | d k  rÅ| | 7} n  | | k sÝ| d k  rìt d ƒ ‚ n  | d } } t |  | | ƒ S(   s:   
        create and return a SuplotSpec instance.
        s   unrecognized subplot speci    s   index out of rangei   N(	   R   t
   isinstancet   tuplet
   ValueErrort   slicet   indicest
   IndexErrorR!   t   SubplotSpec(   R   t   keyR   R	   t   totalt   k1t   k2t   row1t   row2t   _t   col1t   col2t   num1t   num2(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   __getitem__ƒ   s@    
N(   t   __name__t
   __module__t   __doc__R!   R   R   R   R   R   R   R   R   RA   RT   (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR      s   							8t   GridSpecc        	   B  s}   e  Z d  Z d d d d d d d d d „ Z d d d d d d g Z d „  Z d d	 „ Z d
 „  Z d d d d d d „ Z	 RS(   s¨   
    A class that specifies the geometry of the grid that a subplot
    will be placed. The location of grid is determined by similar way
    as the SubplotParams.
    c         C  sY   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ t j |  | | d |	 d |
 ƒd S(   s¸   
        The number of rows and number of columns of the
        grid need to be set. Optionally, the subplot layout parameters
        (e.g., left, right, etc.) can be tuned.
        R   R
   N(   R   R   R   R   R   R    R   R   (   R   R   R	   R   R   R   R   R   R    R   R
   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR   ¾   s    
						R   R   R   R   R   R    c   	      K  sÄ  xO | j  ƒ  D]A \ } } | |  j k r; t |  | | ƒ q t d | f ƒ ‚ q Wd d l m } d d l m } xK| j j	 j
 ƒ  D]7} x.| j j j D]} t | | ƒ sw| j d k	 rt | j | ƒ r| j j ƒ  j ƒ  |  k rt| j j ƒ  | j | j j ƒ qtq¸| j d k	 r¸t | j | ƒ r¸| j j ƒ  j ƒ  |  k rt| j j ƒ  | j | j j ƒ qtq¸q› | j ƒ  j ƒ  } | j ƒ  |  k r› | j ƒ  | j | j ƒ q› q› Wq… Wd S(   s‚   
        Update the current values.  If any kwarg is None, default to
        the current value, if set, otherwise to rc.
        s   %s is unknown keywordiÿÿÿÿ(   t   _pylab_helpers(   t   SubplotBaseN(   t	   iteritemst   _AllowedKeyst   setattrt   AttributeErrort
   matplotlibRY   t   matplotlib.axesRZ   t   Gcft   figst
   itervaluest   canvast   figuret   axesRB   t   _sharexR!   t   get_subplotspect   get_gridspect   update_paramst   set_positiont   figboxt   _shareyt   get_topmost_subplotspec(	   R   t   kwargst   kt   vRY   RZ   t
   figmanagert   axt   ss(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   updateØ   s*    !!
c         C  s»   d d l  m } d d l } | d k rg t g  |  j D] } | t d | f ^ q5 ƒ } | | �  } n | j | j ƒ } t g  |  j D] } | t |  | ƒ f ^ q† ƒ } | j	 | �  | S(   s–   
        return a dictionary of subplot layout parameters. The default
        parameters are from rcParams unless a figure attribute is set.
        iÿÿÿÿ(   t   SubplotParamsNs   figure.subplot.(
   t   matplotlib.figureRv   t   copyR!   t   dictR\   t   rcParamst   subplotparst   getattrRu   (   R   R   Rv   Rx   Rp   t   kwR{   t	   update_kw(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR   ü   s    *1c         C  s)   g  |  j  D] } t |  | ƒ r
 | ^ q
 S(   N(   R\   R|   (   R   Rp   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   locally_modified_subplot_params  s    gHáz®Gñ?c         C  s©   d d l  m } m } m }	 | | j d |  ƒ}
 d	 |
 k rM t j d ƒ n  | d	 k rh |	 | ƒ } n  | | | j |
 | d | d | d | d | ƒ} |  j | �  d	 S(
   s^  
        Adjust subplot parameters to give specified padding.

        Parameters:

        pad : float
            padding between the figure edge and the edges of subplots, as a fraction of the font-size.
        h_pad, w_pad : float
            padding (height/width) between edges of adjacent subplots.
            Defaults to `pad_inches`.
        rect : if rect is given, it is interpreted as a rectangle
            (left, bottom, right, top) in the normalized figure
            coordinate that the whole subplots area (including
            labels) will fit into. Default is (0, 0, 1, 1).
        iÿÿÿÿ(   t   get_subplotspec_listt   get_tight_layout_figuret   get_renderert	   grid_specsg   This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect.t   padt   h_padt   w_padt   rectN(	   t   tight_layoutR€   R�   R‚   Rf   R!   t   warningst   warnRu   (   R   R   t   rendererR„   R…   R†   R‡   R€   R�   R‚   t   subplotspec_listRo   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyRˆ     s    	N(
   RU   RV   RW   R!   R   R\   Ru   R   R   Rˆ   (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyRX   ·   s   	$	t   GridSpecFromSubplotSpecc           B  s8   e  Z d  Z d d d d d „ Z d d „ Z d „  Z RS(   sx   
    GridSpec whose subplot layout parameters are inherited from the
    location specified by a given SubplotSpec.
    c         C  s>   | |  _  | |  _ | |  _ t j |  | | d | d | ƒd S(   s`  
        The number of rows and number of columns of the grid need to
        be set. An instance of SubplotSpec is also needed to be set
        from which the layout parameters will be inherited. The wspace
        and hspace of the layout can be optionally specified or the
        default values (from the figure or rcParams) will be used.
        R   R
   N(   t   _wspacet   _hspacet   _subplot_specR   R   (   R   R   R	   t   subplot_specR   R    R
   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR   ?  s    			c         C  sß   | d k r# t d } t d } n | j j } | j j } |  j d k	 rV |  j } n  |  j d k	 rq |  j } n  |  j j | d t	 ƒ} | j
 \ } } } } d d l m }	 |	 d | d | d | d	 | d
 | d | ƒ }
 |
 S(   sC   
        return a dictionary of subplot layout parameters.
        s   figure.subplot.hspaces   figure.subplot.wspacet
   return_alliÿÿÿÿ(   Rv   R   R   R   R   R   R    N(   R!   Rz   R{   R    R   R�   RŽ   R�   t   get_positiont   Falset   extentsRw   Rv   (   R   R   R    R   Rl   R   R   R   R   Rv   t   sp(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR   T  s&    
	c         C  s   |  j  j ƒ  S(   s@   get the topmost SubplotSpec instance associated with the subplot(   R�   Rn   (   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyRn   u  s    N(   RU   RV   RW   R!   R   R   Rn   (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR�   :  s
   !RH   c           B  sA   e  Z d  Z d d „ Z d „  Z d „  Z e d „ Z d „  Z	 RS(   sH   
    specifies the location of the subplot in the given *GridSpec*.
    c         C  s;   | j  ƒ  \ } } | | } | |  _ | |  _ | |  _ d S(   sÕ   
        The subplot will occupy the num1-th cell of the given
        gridspec.  If num2 is provided, the subplot will span between
        num1-th cell and num2-th cell.

        The index stars from 0.
        N(   R   t	   _gridspecRR   RS   (   R   t   gridspecRR   RS   t   rowst   colsRJ   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR     s
    	
		c         C  s   |  j  S(   N(   R—   (   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyRi   �  s    c         C  s.   |  j  ƒ  j ƒ  \ } } | | |  j |  j f S(   sc   
        get the subplot geometry, eg 2,2,3. Unlike SuplorParams,
        index is 0-based
        (   Ri   R   RR   RS   (   R   R™   Rš   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR   “  s    c         C  sC  |  j  ƒ  } | j ƒ  \ } } | j | ƒ \ } } } }	 t |  j | ƒ \ }
 } | |
 } | |
 } | | } |	 | } |  j d k	 rt |  j | ƒ \ } } | | } | | } | | } |	 | } t | | ƒ } t | | ƒ } t | | ƒ } t | | ƒ } n  t	 j
 j | | | | ƒ } | r;| |
 | | | f S| Sd S(   sB   
        update the subplot position from fig.subplotpars
        N(   Ri   R   RA   t   divmodRR   RS   R!   t   mint   maxt   mtransformst   Bboxt   from_extents(   R   R   R’   R˜   R   R	   R=   R<   R?   R@   R;   R>   t	   figBottomt   figTopt   figLeftt   figRightt   rowNum2t   colNum2t
   figBottom2t   figTop2t   figLeft2t	   figRight2Rl   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyR“   œ  s.    







c         C  s-   |  j  ƒ  } t | d ƒ r% | j ƒ  S|  Sd S(   s@   get the topmost SubplotSpec instance associated with the subplotRn   N(   Ri   t   hasattrRn   (   R   R˜   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyRn   Å  s    
N(
   RU   RV   RW   R!   R   Ri   R   R”   R“   Rn   (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyRH   z  s   			)(   RW   t
   __future__R    R   R_   Rz   t   matplotlib.transformst
   transformsRž   t   numpyR$   R‰   t   objectR   RX   R�   RH   (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/gridspec.pyt   <module>   s   	œƒ@