ó
 m[c           @` sÅ   d  d l  m Z m Z m Z m Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 j Z d  d l j Z d  d l j Z d  d l Z d  d l Z e j Z d e j f d     YZ d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   allow_rasterization(   t	   docstringt   Spinec           B` s  e  Z d  Z d   Z e j 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 e d    Z d   Z d   Z d   Z d   Z d   Z d   Z e d    Z e d    Z e d    Z d   Z  RS(   uÓ  an axis spine -- the line noting the data area boundaries

    Spines are the lines connecting the axis tick marks and noting the
    boundaries of the data area. They can be placed at arbitrary
    positions. See function:`~matplotlib.spines.Spine.set_position`
    for more information.

    The default position is ``('outward',0)``.

    Spines are subclasses of class:`~matplotlib.patches.Patch`, and
    inherit much of their behavior.

    Spines draw a line, a circle, or an arc depending if
    function:`~matplotlib.spines.Spine.set_patch_line`,
    function:`~matplotlib.spines.Spine.set_patch_circle`, or
    function:`~matplotlib.spines.Spine.set_patch_arc` has been called.
    Line-like is the default.

    c         C` s   d S(   Nu   Spine(    (   t   self(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   __str__'   s    c         K` s  t  t |   j |   | |  _ |  j |  j j  | |  _ |  j d  |  j t	 d  |  j
 t	 d  |  j d  d |  _ |  j d  |  j |  j j  d |  _ t |  _ d |  _ t | t j j  sß t d   n  | |  _ d |  _ t j   |  _ d S(	   uč   
        - *axes* : the Axes instance containing the spine
        - *spine_type* : a string specifying the spine type
        - *path* : the path instance used to draw the spine

        Valid kwargs are:
        %(Patch)s
        u   noneu   axes.edgecoloru   axes.linewidthu
   projectingg      @u4   'path' must be an instance of 'matplotlib.path.Path'u   lineN(   t   superR   t   __init__t   axest
   set_figuret   figuret
   spine_typet   set_facecolort   set_edgecolort   rcParamst   set_linewidtht   set_capstylet   Nonet   axist
   set_zordert   set_transformt	   transDatat   _boundst   Falset   _smart_boundst	   _positiont
   isinstancet
   matplotlibt   patht   Patht
   ValueErrort   _patht   _patch_typet   mtransformst   IdentityTransformt   _patch_transform(   R   R   R   R   t   kwargs(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyR
   *   s(    
								c         C` s`   | |  _  |  j d k r. |  j j j |  n% |  j d k rS |  j j j |  n  t |  _ d S(   u6   set the spine and associated axis to have smart boundsu   leftu   rightu   topu   bottomN(   u   leftu   right(   u   topu   bottom(   R   R   R   t   yaxist   set_smart_boundst   xaxist   Truet   stale(   R   t   value(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyR)   Y   s    	c         C` s   |  j  S(   u&   get whether the spine has smart bounds(   R   (   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   get_smart_boundsd   s    c         C` sv   d |  _  | |  _ | d |  _ | d |  _ | |  _ | |  _ t j j | |  |  _	 |  j
 |  j j  t |  _ d S(   u   set the spine to be arc-likeu   arci   N(   R#   t   _centert   _widtht   _heightt   _theta1t   _theta2t   mpathR    t   arcR"   R   R   t	   transAxesR+   R,   (   R   t   centert   radiust   theta1t   theta2(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   set_patch_arch   s    				c         C` sL   d |  _  | |  _ | d |  _ | d |  _ |  j |  j j  t |  _ d S(   u   set the spine to be circularu   circlei   N(	   R#   R/   R0   R1   R   R   R6   R+   R,   (   R   R7   R8   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   set_patch_circleu   s    		c         C` s   d |  _  t |  _ d S(   u   set the spine to be linearu   lineN(   R#   R+   R,   (   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   set_patch_line   s    	c         C` s   |  j  d k s t  |  j |  j d  |  j |  j d  f } |  j |  j  } |  j |  j  } t j   j	 | d | d  j
 |   |  _ d S(   u  NOTE: This cannot be called until after this has been added
                 to an Axes, otherwise unit conversion will fail. This
                 makes it very important to call the accessor method and
                 not directly access the transformation member variable.
        u   arcu   circlei    i   g      ą?N(   u   arcu   circle(   R#   t   AssertionErrort   convert_xunitsR/   t   convert_yunitsR0   R1   R$   t   Affine2Dt   scalet	   translateR&   (   R   R7   t   widtht   height(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   _recompute_transform   s    c         C` s7   |  j  d k r  |  j   |  j St t |   j   Sd  S(   Nu   arcu   circle(   u   arcu   circle(   R#   RF   R&   R	   R   t   get_patch_transform(   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyRG      s    
c         C` s   |  j  S(   N(   R"   (   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   get_path   s    c         C` s/   |  j  d  k r+ d |  _  |  j |  j   n  d  S(   Nu   outwardg        (   u   outwardg        (   R   R   t   set_position(   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   _ensure_position_is_set   s    	c         C` s5   | |  _  |  j  d k	 r( |  j  j   n  t |  _ d S(   uÄ   register an axis

        An axis should be registered with its corresponding spine from
        the Axes instance. This allows the spine to clear any axis
        properties when needed.
        N(   R   R   t   claR+   R,   (   R   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   register_axis¤   s    	c         C` s,   d |  _ |  j d k	 r( |  j j   n  d S(   u   Clear the current spineN(   R   R   R   RK   (   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyRK   °   s    	c         C` s£   |  j    |  j } t | t j  rR | d k r: d } qR | d k rR d } qR n  t |  d k rs t d   n  | \ } } | d	 k r | d k r t St Sd
 S(   u¶   return True if directly on axes frame

        This is useful for determining if a spine is the edge of an
        old style MPL plot. If so, this function will return True.
        u   centeru   axesg      ą?u   zerou   datai    i   u   position should be 2-tupleu   outwardN(   u   axesg      ą?(   u   datai    (	   RJ   R   R   t   sixt   string_typest   lenR!   R+   R   (   R   t   positiont   position_typet   amount(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   is_frame_like¶   s    
		c         C` s  |  j  d k r d S|  j d k r|  j  d k rI |  j j j \ } } n: |  j  d k rp |  j j j \ } } n t d |  j    |  j rt	 | | g  \ } } |  j  d k rŚ |  j j
 j \ } } |  j j   } n6 |  j  d k r|  j j
 j \ } } |  j j   } n  t j |  } t	 | | g  \ } } | | k  rL| } nN | | k | | k @} | | }	 t |	  r|	 d } n | } t | |  } | | k rÆ| } q | | k | | k @} | | }	 t |	  rč|	 d	 } n | } t | |  } qn |  j \ } } |  j d
 k r}|  j  d k rgy |  j j   }
 Wn t k
 r\d }
 n Xy |  j j   } Wn t k
 rd	 } n X| |
 | } | |
 | } | | k rĀ| | } } n  t j j t j |  t j |   |  _ |  j  d k rz|  j j j \ } } y |  j j   } Wn t k
 r<| } n X| | | | } | |  _ | |  _ qzqt d |  j    n |  j j } | j d k s¤t  d   |  j  d k rŹ| | d <| | d <n9 |  j  d k rš| | d <| | d <n t d |  j    d S(   u3   automatically set spine bounds to the view intervalu   circleNu   leftu   rightu   topu   bottomu   unknown spine spine_type: %si’’’’i    u   arci   u#   unable to set bounds for spine "%s"i   u   unexpected vertices shape(   u   leftu   right(   u   topu   bottom(   u   leftu   right(   u   topu   bottom(   u   bottomu   top(   i   i   (   u   leftu   right(   i    i   (   i   i   (   u   bottomu   top(   i    i    (   i   i    (!   R   R   R   R   t   viewLimt	   intervalyt	   intervalxR!   R   t   sortedt   dataLimt
   get_ytickst
   get_xtickst   npt   sortRO   t   maxt   minR#   t   get_theta_directiont   AttributeErrort   get_theta_offsetR4   R    R5   t   rad2degR"   t   get_roriginR1   R0   t   verticest   shapeR>   (   R   t   lowt   hight   viewlim_lowt   viewlim_hight   datalim_lowt   datalim_hight   tickst   condt   tickvalst	   directiont   offsett   rmint   rmaxt   rorigint   scaled_diametert   v1(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   _adjust_locationĖ   s    		
	


*
	

c         C` s/   |  j    t t |   j |  } t |  _ | S(   N(   Rv   R	   R   t   drawR   R,   (   R   t   renderert   ret(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyRw   7  s    
	c         C` sŪ  |  j    |  j } t | t j  rR | d k r: d } qR | d k rR d } qR n  t |  d k sp t d   | \ } } | d k s t  | d	 k rm| d k r¾ d
 t j   f |  _	 q×|  j
 d k rAi d d 6d d 6d d 6d d 6|  j
 } | | d d } | | d d } d t j | | |  j j  f |  _	 q×t j d |  j
  d
 t j   f |  _	 nj| d k r|  j
 d k rµd t j j d d d d | d  f |  _	 q×|  j
 d k rńd t j j d d d d d |  f |  _	 q×t j d |  j
  d
 t j   f |  _	 nŗ | d k r×|  j
 d  k rE| d 8} n  |  j
 d! k rxd t j   j | d  f |  _	 q×|  j
 d" k r«d t j   j d |  f |  _	 q×t j d |  j
  d
 t j   f |  _	 n  d S(#   u5   calculate the offset transform performed by the spineu   centeru   axesg      ą?u   zerou   datai    i   u   position should be 2-tupleu   outwardu   identityu   leftu   rightu   topu   bottomi’’’’i   g      R@u   postu2   unknown spine type "%s": no spine offset performedu   preN(   u   axesg      ą?(   u   datai    (   u   axesu   outwardu   data(   u   leftu   rightu   topu   bottom(   i’’’’i    (   i   i    (   i    i’’’’(   i    i   (   u   leftu   right(   u   bottomu   top(   u   rightu   top(   u   leftu   right(   u   bottomu   top(   RJ   R   R   RM   RN   RO   R>   R$   R%   t   _spine_transformR   t   ScaledTranslationR   t   dpi_scale_transt   warningst   warnRA   t   from_valuesRC   (   R   RP   RQ   RR   t
   offset_vect   offset_xt   offset_y(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   _calc_offset_transform>  sv    
		

		!	!		c         C` s”   | d k r n@ t  |  d k r0 t d   n  | d d k rO t d	   n  | |  _ |  j   |  j |  j    |  j d
 k	 r |  j j   n  t	 |  _
 d
 S(   up  set the position of the spine

        Spine position is specified by a 2 tuple of (position type,
        amount). The position types are:

        * 'outward' : place the spine out from the data area by the
          specified number of points. (Negative values specify placing the
          spine inward.)

        * 'axes' : place the spine at the specified Axes coordinate (from
          0.0-1.0).

        * 'data' : place the spine at the specified data coordinate.

        Additionally, shorthand notations define a special positions:

        * 'center' -> ('axes',0.5)
        * 'zero' -> ('data', 0.0)

        u   centeru   zeroi   u&   position should be 'center' or 2-tuplei    u   outwardu   axesu   datau:   position[0] should be one of 'outward', 'axes', or 'data' N(   u   centeru   zero(   u   outwardu   axesu   data(   RO   R!   R   R   R   t   get_spine_transformR   R   t   reset_ticksR+   R,   (   R   RP   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyRI     s    	
c         C` s   |  j    |  j S(   u   get the spine position(   RJ   R   (   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   get_positionÆ  s    
c         C` sa  |  j    |  j \ } } | d k r“ |  j j | |  j j |  j j } |  j d k rs t j | |  j j	  } n= |  j d k r t j |  j j	 |  } n t
 d |  j   | S|  j d k rŪ |  j j d d  } n: |  j d k r|  j j d d  } n t
 d |  j   | d	 k r%| S| d
 k r9| | S| d k rM| | St
 d |   d S(   u   get the spine transformu   datau   leftu   rightu   topu   bottomu   unknown spine spine_type: %st   whichu   gridu   identityu   postu   preu    unknown spine_transform type: %sN(   u   leftu   right(   u   topu   bottom(   u   leftu   right(   u   topu   bottom(   RJ   Rz   R   t
   transScalet   transLimitsR6   R   R$   t   blended_transform_factoryR   R!   t   get_yaxis_transformt   get_xaxis_transform(   R   t   whatt   howt
   data_xformt   resultt   base_transform(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyR   “  s6    
	c         C` s:   |  j  d k r t d   n  | | f |  _ t |  _ d S(   u   Set the bounds of the spine.u   circleu5   set_bounds() method incompatible with circular spinesN(   R   R!   R   R+   R,   (   R   Rf   Rg   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt
   set_boundsŁ  s
    c         C` s   |  j  S(   u   Get the bounds of the spine.(   R   (   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt
   get_boundsį  s    c         K` sÓ   | d k r$ t  j d
 d g  } n| | d k rH t  j d d g  } nX | d k rl t  j d d g  } n4 | d k r t  j d d g  } n t d |   |  | | | |  } | j t d	 j |   | S(   uA   
        (staticmethod) Returns a linear :class:`Spine`.
        u   leftg        i   u   rightg      š?u   bottomu   topu"   unable to make path for spine "%s"u   axes.spines.{0}(   g        i   (   g        i   (   g      š?i   (   g      š?i   (   i   g        (   i   g        (   i   g      š?(   i   g      š?(   R4   R    R!   t   set_visibleR   t   format(   t   clsR   R   R'   R   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   linear_spineå  s    c   
      K` sD   t  j j | |  } |  | | | |  }	 |	 j | | | |  |	 S(   u>   
        (classmethod) Returns an arc :class:`Spine`.
        (   R4   R    R5   R;   (
   R   R   R   R7   R8   R9   R:   R'   R   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt	   arc_spineś  s    c         K` s>   t  j j   } d } |  | | | |  } | j | |  | S(   uC   
        (staticmethod) Returns a circular :class:`Spine`.
        u   circle(   R4   R    t   unit_circleR<   (   R   R   R7   R8   R'   R   R   R   (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   circular_spine  s
    c         C` s   |  j  |  t |  _ d S(   uö   
        Set the edgecolor.

        ACCEPTS: matplotlib color arg or sequence of rgba tuples

        .. seealso::

            :meth:`set_facecolor`, :meth:`set_edgecolor`
               For setting the edge or face color individually.
        N(   R   R+   R,   (   R   t   c(    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt	   set_color  s    (!   t   __name__t
   __module__t   __doc__R   R   t   dedent_interpdR
   R)   R.   R;   R<   R=   RF   RG   RH   RJ   RL   RK   RS   Rv   R   Rw   R   RI   R   R   R   R   t   classmethodR   R   R   R   (    (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyR      s6   	/				
									l	J	'		%		(   t
   __future__R    R   R   R   RM   R   t   matplotlib.artistR   R   t   matplotlib.transformst
   transformsR$   t   matplotlib.patchest   patchest   mpatchest   matplotlib.pathR   R4   t   numpyR[   R}   R   t   PatchR   (    (    (    s0   lib/python2.7/site-packages/matplotlib/spines.pyt   <module>   s   "	