
 m[c           @` s  d  Z  d d l m Z m Z m Z m Z d d l Z d d l m Z m	 Z	 d d l
 Z
 d d l j Z d d l j Z d d l j Z d d l j Z d d l Z d d l m Z m Z m Z d d l m Z d d l m Z m  Z  d d l! m" Z" d d	 l! m# Z# d d
 l$ m% Z% d d l m& Z' d d l m( Z( e) Z* d   Z& d d  Z+ d d  Z, d e j- f d     YZ. d e. f d     YZ/ d e/ f d     YZ0 d e/ f d     YZ1 d e. f d     YZ2 d e. f d     YZ3 d e. f d     YZ4 d  e. f d!     YZ5 d" e. f d#     YZ6 d$ e6 f d%     YZ7 d& e. f d'     YZ8 d( e j- e( f d)     YZ9 d* e: f d+     YZ; d, e; f d-     YZ< d. e; f d/     YZ= e> d0 k rd d l? j@ ZA eA jB d1  ZC eC jD   eA jE d2  ZF eG   ZH e jI d3  jJ d4 d4  d5 ZK e8 eK d6 d7 d8 d d9 d eH ZM eF jN eM  eM jO dN  e8 eK d6 d7 d8 d d9 d eH ZP e9 eP dO d< dP d> d? d@ dA dB eQ dC dD dE eG dF dG dH dI  dJ d dK eG dL dM  ZR eF jN eR  eA jS   eA jT   n  d S(Q   u  
The OffsetBox is a simple container artist. The child artist are meant
to be drawn at a relative position to its parent.  The [VH]Packer,
DrawingArea and TextArea are derived from the OffsetBox.

The [VH]Packer automatically adjust the relative postisions of their
children, which should be instances of the OffsetBox. This is used to
align similar artists together, e.g., in legend.

The DrawingArea can contain any Artist as a child. The
DrawingArea has a fixed width and height. The position of children
relative to the parent is fixed.  The TextArea is contains a single
Text instance. The width and height of the TextArea instance is the
width and height of the its child text.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   xranget   zip(   t   Bboxt   BboxBaset   TransformedBbox(   t   FontProperties(   t   FancyBboxPatcht   FancyArrowPatch(   t   rcParams(   t	   docstring(   t	   BboxImage(   t   bbox_artist(   t   _AnnotationBasec          O` s   t  r t |  |   n  d  S(   N(   t   DEBUGt   mbbox_artist(   t   argst   kwargs(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR   /   s    u   fixedc   
      C` s  t  |    \ } } | d k r| t j d g g  | D] } | | ^ q1  } | d  } | d k rr | d | } n  | | f S| d k r| d k r d } n  t |  d k r | t |  t |  d } n d } t j d g g  | D] } | | ^ q  } | d  } | | f S| d k rt |  }	 | d k rR|	 | t |  } n | t |  |	 } |	 | t j t |   } | | f St d | f   d S(	   u  
    Geiven a list of (width, xdescent) of each boxes, calculate the
    total width and the x-offset positions of each items according to
    *mode*. xdescent is analogous to the usual descent, but along the
    x-direction. xdescent values are currently ignored.

    *wd_list* : list of (width, xdescent) of boxes to be packed.
    *sep* : spacing between boxes
    *total* : Intended total length. None if not used.
    *mode* : packing mode. 'fixed', 'expand', or 'equal'.
    u   fixedi    iu   expandi   u   equalu   Unknown mode : %sN(	   R   t   npt   cumsumt   Nonet   lent   sumt   maxt   aranget
   ValueError(
   t   wd_listt   totalt   sept   modet   w_listt   d_listt   wt   offsets_t   offsetst   maxh(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   _get_packed_offsets8   s0    -

	!-


u   baselinec         C` sY  | d k r% t d   |  D  } n  | d k r t d   |  D  } t d   |  D  } | | } g  |  D] \ } } d ^ qn } n | d k r d } g  |  D] \ } } | ^ q } n | d k r d } g  |  D] \ } } | | | ^ q } nS | d
 k r9d } g  |  D] \ } } | | d | ^ q} n t d | f   | | | f S(   u)  
    Given a list of (height, descent) of each boxes, align the boxes
    with *align* and calculate the y-offsets of each boxes.
    total width and the offset positions of each items according to
    *mode*. xdescent is analogous to the usual descent, but along the
    x-direction. xdescent values are currently ignored.

    *hd_list* : list of (width, xdescent) of boxes to be aligned.
    *sep* : spacing between boxes
    *height* : Intended total length. None if not used.
    *align* : align mode. 'baseline', 'top', 'bottom', or 'center'.
    c         s` s   |  ] \ } } | Vq d  S(   N(    (   t   .0t   ht   d(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pys	   <genexpr>x   s    u   baselinec         s` s   |  ] \ } } | | Vq d  S(   N(    (   R(   R)   R*   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pys	   <genexpr>{   s    c         s` s   |  ] \ } } | Vq d  S(   N(    (   R(   R)   R*   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pys	   <genexpr>|   s    g        u   leftu   topu   rightu   bottomu   centerg      ?u   Unknown Align mode : %sN(   u   leftu   top(   u   rightu   bottom(   R   R   R   (   t   hd_listt   heightt   alignt   height_descentt   descentR)   R*   R%   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   _get_aligned_offsetsi   s$    
""*.t	   OffsetBoxc           B` s   e  Z d  Z d   Z d   Z d   Z d   Z e j j	 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 RS(   u   
    The OffsetBox is a simple container artist. The child artist are meant
    to be drawn at a relative position to its parent.
    c         O` s<   t  t |   j | |   |  j t  g  |  _ d |  _ d  S(   Ni    (   i    i    (   t   superR1   t   __init__t   set_clip_ont   Falset	   _childrent   _offset(   t   selfR   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3      s    	c         C` s^   t  j j |   } d d l m } d d  l } | d } | j |  rZ | |  | d <n  | S(   Ni   (   t   _InstanceMethodPickleri    u   _offset(   t   martistt   Artistt   __getstate__t   cbookR9   t   inspectt   ismethod(   R8   t   stateR9   R>   t   offset(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR<      s    
c         C` sM   | |  _  d d l m } t |  j |  r@ |  j j   |  _ n  t |  _ d  S(   Ni   (   R9   (   t   __dict__R=   R9   t
   isinstanceR7   t   get_instancemethodt   Truet   stale(   R8   R@   R9   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   __setstate__   s
    	c         C` s;   t  j j |  |  x! |  j   D] } | j |  q  Wd S(   u^   
        Set the figure

        accepts a class:`~matplotlib.figure.Figure` instance
        N(   R:   R;   t
   set_figuret   get_children(   R8   t   figt   c(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRH      s    c         C` sI   t  j j j |  |  x, |  j   D] } | d  k	 r# | | _ q# q# Wd  S(   N(   R:   R;   t   axest   fsetRI   R   (   R8   t   axRK   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRL      s    c         C` sF   x9 |  j    D]+ } | j |  \ } } | r | | f Sq Wt i  f S(   N(   RI   t   containsR5   (   R8   t
   mouseeventRK   t   at   b(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRO      s
    c         C` s   | |  _  t |  _ d S(   uT   
        Set the offset

        accepts x, y, tuple, or a callable object.
        N(   R7   RE   RF   (   R8   t   xy(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt
   set_offset   s    	c         C` s/   t  |  j  r( |  j | | | | |  S|  j S(   uC   
        Get the offset

        accepts extent of the box
        (   t   callableR7   (   R8   t   widthR,   t   xdescentt   ydescentt   renderer(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt
   get_offset   s    (c         C` s   | |  _  t |  _ d S(   u6   
        Set the width

        accepts float
        N(   RV   RE   RF   (   R8   RV   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt	   set_width   s    	c         C` s   | |  _  t |  _ d S(   u7   
        Set the height

        accepts float
        N(   R,   RE   RF   (   R8   R,   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt
   set_height   s    	c         C` s&   g  |  j  D] } | j   r
 | ^ q
 S(   u?   
        Return a list of visible artists it contains.
        (   R6   t   get_visible(   R8   RK   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_visible_children   s    c         C` s   |  j  S(   u7   
        Return a list of artists it contains.
        (   R6   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRI      s    c         C` s   t  d   d  S(   Nu    (   t	   Exception(   R8   RY   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_extent_offsets   s    c         C` s.   |  j  |  \ } } } } } | | | | f S(   u@   
        Return with, height, xdescent, ydescent of box
        (   R`   (   R8   RY   R#   R)   t   xdt   ydR%   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt
   get_extent   s    c   	      C` s`   |  j  |  \ } } } } } |  j | | | | |  \ } } t j j | | | | | |  S(   u8   
        get the bounding box in display space.
        (   R`   RZ   t   mtransformsR   t   from_bounds(	   R8   RY   R#   R)   Ra   Rb   R%   t   pxt   py(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_window_extent  s    !c      	   C` s   |  j  |  \ } } } } } |  j | | | | |  \ } } xQ t |  j   |  D]: \ }	 \ }
 } |	 j | |
 | | f  |	 j |  qU Wt |  | d t d t d d  t |  _	 d S(   um   
        Update the location of children if necessary and draw them
        to the given *renderer*.
        t   fillt   propst   padg        N(
   R`   RZ   R   R^   RT   t   drawR   R5   t   dictRF   (   R8   RY   RV   R,   RW   RX   R%   Rf   Rg   RK   t   oxt   oy(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRl     s    !("(   t   __name__t
   __module__t   __doc__R3   R<   RG   RH   R:   R;   RL   t   setterRO   RT   RZ   R[   R\   R^   RI   R`   Rc   Rh   Rl   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR1      s"   				
				
									t
   PackerBasec           B` s&   e  Z d d d d d d d d   Z RS(   c         C` sV   t  t |   j   | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _	 d S(   u  
        Parameters
        ----------
        pad : float, optional
            Boundary pad.

        sep : float, optional
            Spacing between items.

        width : float, optional

        height : float, optional
           Width and height of the container box, calculated if
           `None`.

        align : str, optional
            Alignment of boxes. Can be one of ``top``, ``bottom``,
            ``left``, ``right``, ``center`` and ``baseline``

        mode : str, optional
            Packing mode.

        Notes
        -----
        *pad* and *sep* need to given in points and will be scale with
        the renderer dpi, while *width* and *height* need to be in
        pixels.
        N(
   R2   Rt   R3   R,   RV   R   Rk   R    R-   R6   (   R8   Rk   R   RV   R,   R-   R    t   children(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3   "  s    						N(   Rp   Rq   R   R3   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRt   !  s   t   VPackerc           B` s5   e  Z d  Z d d d d d d d d  Z d   Z RS(   u   
    The VPacker has its children packed vertically. It automatically
    adjust the relative positions of children in the drawing time.
    u   baselineu   fixedc         C` s,   t  t |   j | | | | | | |  d S(   up  
        Parameters
        ----------
        pad : float, optional
            Boundary pad.

        sep : float, optional
            Spacing between items.

        width : float, optional

        height : float, optional

            width and height of the container box, calculated if
            `None`.

        align : str, optional
            Alignment of boxes.

        mode : str, optional
            Packing mode.

        Notes
        -----
        *pad* and *sep* need to given in points and will be scale with
        the renderer dpi, while *width* and *height* need to be in
        pixels.
        N(   R2   Rv   R3   (   R8   Rk   R   RV   R,   R-   R    Ru   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3   R  s    c         C` s  | j  d  } |  j | } |  j | } |  j d k	 r xH |  j   D]7 } t | t  rE | j d k rE | j	 |  j  qE qE Wn  g  |  j   D] } | j
 |  ^ q } g  | D]( \ } } }	 }
 | | |	 | |
 f ^ q } g  | D] \ } } }	 }
 | |	 f ^ q } t | |  j |  j  \ } } } g  | D] \ } } }	 }
 | |
 f ^ q3} t | |  j | |  j  \ } } | g  | D] \ } } }	 }
 |
 ^ q} | | d } | | } | | } | d | | d | | | | | t t | |   f S(   uN   
        update offset of childrens and return the extents of the box
        g      ?u   expandi    i   N(   t   points_to_pixelsRk   R   RV   R   R^   RC   Rt   R    R[   Rc   R0   R-   R'   R,   t   listR   (   R8   RY   t   dpicorRk   R   RK   t   whd_listR#   R)   Ra   Rb   R   RV   RW   t   xoffsetst	   pack_listR,   t	   yoffsets_t   yoffsetsRX   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR`   u  s0    %5++)

N(   Rp   Rq   Rr   R   R3   R`   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRv   M  s
   !t   HPackerc           B` s5   e  Z d  Z d d d d d d d d  Z d   Z RS(   u   
    The HPacker has its children packed horizontally. It automatically
    adjusts the relative positions of children at draw time.
    u   baselineu   fixedc         C` s,   t  t |   j | | | | | | |  d S(   uW  
        Parameters
        ----------
        pad : float, optional
            Boundary pad.

        sep : float, optional
            Spacing between items.

        width : float, optional

        height : float, optional
           Width and height of the container box, calculated if
           `None`.

        align : str
           Alignment of boxes.

        mode : str
           Packing mode.

        Notes
        -----
        *pad* and *sep* need to given in points and will be scale with
        the renderer dpi, while *width* and *height* need to be in
        pixels.
        N(   R2   R   R3   (   R8   Rk   R   RV   R,   R-   R    Ru   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3     s    c         C` s  | j  d  } |  j | } |  j | } g  |  j   D] } | j |  ^ q6 } | sr d | d | | | g  f S|  j d k r t d   | D  } t d   | D  } | | }	 n |  j d | }	 g  | D] \ }
 } } } | | f ^ q } t | |  j |  j	  \ }	 } } g  | D] \ }
 } } } |
 | f ^ q} t
 | |  j | |  j  \ } } | g  | D] \ }
 } } } | ^ qm} | d d } | | } | d | |	 d | | | | | t t | |   f S(   uM   
        update offset of children and return the extents of the box
        g      ?i   c         s` s%   |  ] \ } } } } | | Vq d  S(   N(    (   R(   R#   R)   Ra   Rb   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pys	   <genexpr>  s    c         s` s!   |  ] \ } } } } | Vq d  S(   N(    (   R(   R#   R)   Ra   Rb   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pys	   <genexpr>  s    i    N(   Rw   Rk   R   R^   Rc   R,   R   R   R0   R-   R'   RV   R    Rx   R   (   R8   RY   Ry   Rk   R   RK   Rz   R.   RX   R,   R#   R)   Ra   Rb   R+   R~   R|   RV   t	   xoffsets_R{   RW   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR`     s2    %++)
N(   Rp   Rq   Rr   R   R3   R`   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s
   t	   PaddedBoxc           B` sA   e  Z d e d d   Z d   Z d   Z d d  Z d   Z RS(   c         C` s   t  t |   j   | |  _ | g |  _ t d d d d d d d d d d	 d
 d d t  |  _ |  j j d d d | d k	 r |  j j
 |  n  | |  _ d S(   u   
        *pad* : boundary pad

        .. note::
          *pad* need to given in points and will be
          scale with the renderer dpi, while *width* and *height*
          need to be in pixels.
        RS   g        RV   g      ?R,   t	   facecoloru   wt	   edgecoloru   kt   mutation_scalei   t   snapu   squareRk   i    N(   g        g        (   R2   R   R3   Rk   R6   R
   RE   t   patcht   set_boxstyleR   t   updatet
   _drawFrame(   R8   t   childRk   t
   draw_framet   patch_attrs(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3     s    
	c         C` sl   | j  d  } |  j | } |  j d j |  \ } } } } | d | | d | | | | | d g f S(   uN   
        update offset of childrens and return the extents of the box
        g      ?i    i   (   i    i    (   Rw   Rk   R6   Rc   (   R8   RY   Ry   Rk   R#   R)   Ra   Rb   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR`     s    "c         C` s   |  j  |  \ } } } } } |  j | | | | |  \ } } xD t |  j   |  D]- \ }	 \ }
 } |	 j | |
 | | f  qU W|  j |  x! |  j   D] }	 |	 j |  q Wt |  _ d S(   um   
        Update the location of children if necessary and draw them
        to the given *renderer*.
        N(	   R`   RZ   R   R^   RT   R   Rl   R5   RF   (   R8   RY   RV   R,   RW   RX   R%   Rf   Rg   RK   Rn   Ro   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRl     s    !(c         C` sK   |  j  j | j | j | j | j  | r> |  j  j |  n  t |  _ d  S(   N(	   R   t
   set_boundst   x0t   y0RV   R,   t   set_mutation_scaleRE   RF   (   R8   t   bboxt   fontsize(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   update_frame,  s
    c         C` s<   |  j  |  } |  j |  |  j r8 |  j j |  n  d  S(   N(   Rh   R   R   R   Rl   (   R8   RY   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR   4  s    	N(	   Rp   Rq   R   R5   R3   R`   Rl   R   R   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s
   		t   DrawingAreac           B` s   e  Z d  Z d d e d  Z e d    Z e j d    Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z RS(   u   
    The DrawingArea can contain any Artist as a child. The DrawingArea
    has a fixed width and height. The position of children relative to
    the parent is fixed. The children can be clipped at the
    boundaries of the parent.
    g        c         C` s   t  t |   j   | |  _ | |  _ | |  _ | |  _ | |  _ t j	   |  _
 |  j
 j   |  j
 j d d  t j	   |  _ d S(   u   
        *width*, *height* : width and height of the container box.
        *xdescent*, *ydescent* : descent of the box in x- and y-direction.
        *clip* : Whether to clip the children
        i    N(   R2   R   R3   RV   R,   RW   RX   t   _clip_childrenRd   t   Affine2Dt   offset_transformt   cleart	   translatet   dpi_transform(   R8   RV   R,   RW   RX   t   clip(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3   E  s    					c         C` s   |  j  S(   ul   
        If the children of this DrawingArea should be clipped
        by DrawingArea bounding box.
        (   R   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   clip_children[  s    c         C` s   t  |  |  _ t |  _ d  S(   N(   t   boolR   RE   RF   (   R8   t   val(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR   c  s    c         C` s   |  j  |  j S(   uf   
        Return the :class:`~matplotlib.transforms.Transform` applied
        to the children
        (   R   R   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_transformh  s    c         C` s   d S(   u+   
        set_transform is ignored.
        N(    (   R8   t   t(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   set_transformo  s    c         C` s>   | |  _  |  j j   |  j j | d | d  t |  _ d S(   uj   
        set offset of the container.

        Accept : tuple of x,y coordinate in display units.
        i    i   N(   R7   R   R   R   RE   RF   (   R8   RS   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRT   u  s    	c         C` s   |  j  S(   u1   
        return offset of the container.
        (   R7   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRZ     s    c         C` sN   |  j  |  \ } } } } |  j   \ } } t j j | | | | | |  S(   u8   
        get the bounding box in display space.
        (   Rc   RZ   Rd   R   Re   (   R8   RY   R#   R)   Ra   Rb   Rn   Ro   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRh     s    c         C` s;   | j  d  } |  j | |  j | |  j | |  j | f S(   u@   
        Return with, height, xdescent, ydescent of box
        g      ?(   Rw   RV   R,   RW   RX   (   R8   RY   t   dpi_cor(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRc     s    c         C` sy   |  j  j |  | j   s2 | j |  j    n  |  j d k	 rP |  j | _ n  |  j } | d k	 ru | j |  n  d S(   u?   Add any :class:`~matplotlib.artist.Artist` to the container boxN(	   R6   t   appendt   is_transform_setR   R   RL   R   t   figureRH   (   R8   RQ   RJ   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt
   add_artist  s    	c      	   C` s   | j  d  } |  j j   |  j j | |  t j t j d d g d |  j g |  j	 |  j g |  j	 d g g  |  j
    } xJ |  j D]? } |  j r | j p | j r | j |  n  | j |  q Wt |  | d t d t d d  t |  _ d S(   u#   
        Draw the children
        g      ?i    Ri   Rj   Rk   g        N(   Rw   R   R   t   scaleRd   t   TransformedPatht   mpatht   PathR,   RV   R   R6   R   t   clipboxt	   _clippatht   set_clip_pathRl   R   R5   Rm   RF   (   R8   RY   R   t   tpathRK   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRl     s    "(   Rp   Rq   Rr   R5   R3   t   propertyR   Rs   R   R   RT   RZ   Rh   Rc   R   Rl   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR   =  s   									t   TextAreac           B` s   e  Z d  Z d d e 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   
    The TextArea is contains a single Text instance. The text is
    placed at (0,0) with baseline+left alignment. The width and height
    of the TextArea instance is the width and height of the its child
    text.
    c         C` s   | d k r i  } n  d | k r. d | d <n  t j d d | |  |  _ t j |   |  j g |  _ t j   |  _	 |  j	 j
   |  j	 j d d  t j   |  _ |  j j |  j	 |  j  | |  _ | |  _ d S(   u  
        Parameters
        ----------
        s : str
            a string to be displayed.

        textprops : `~matplotlib.font_manager.FontProperties`, optional

        multilinebaseline : bool, optional
            If `True`, baseline for multiline text is adjusted so that
            it is (approximatedly) center-aligned with singleline
            text.

        minimumdescent : bool, optional
            If `True`, the box has a minimum descent of "p".
        u   vau   baselinei    N(   R   t   mtextt   Textt   _textR1   R3   R6   Rd   R   R   R   R   t   _baseline_transformR   t   _multilinebaselinet   _minimumdescent(   R8   t   st	   textpropst   multilinebaselinet   minimumdescent(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3     s    		c         C` s   |  j  j |  t |  _ d S(   u&   Set the text of this area as a string.N(   R   t   set_textRE   RF   (   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s    c         C` s   |  j  j   S(   u5   Returns the string representation of this area's text(   R   t   get_text(   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s    c         C` s   | |  _  t |  _ d S(   u   
        Set multilinebaseline .

        If True, baseline for multiline text is
        adjusted so that it is (approximatedly) center-aligned with
        singleline text.
        N(   R   RE   RF   (   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   set_multilinebaseline  s    	c         C` s   |  j  S(   u)   
        get multilinebaseline .
        (   R   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_multilinebaseline  s    c         C` s   | |  _  t |  _ d S(   u   
        Set minimumdescent .

        If True, extent of the single line text is adjusted so that
        it has minimum descent of "p"
        N(   R   RE   RF   (   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   set_minimumdescent
  s    	c         C` s   |  j  S(   u%   
        get minimumdescent.
        (   R   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_minimumdescent  s    c         C` s   d S(   u+   
        set_transform is ignored.
        N(    (   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s    c         C` s>   | |  _  |  j j   |  j j | d | d  t |  _ d S(   uk   
        set offset of the container.

        Accept : tuple of x,y coordinates in display units.
        i    i   N(   R7   R   R   R   RE   RF   (   R8   RS   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRT      s    	c         C` s   |  j  S(   u1   
        return offset of the container.
        (   R7   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRZ   ,  s    c         C` sN   |  j  |  \ } } } } |  j   \ } } t j j | | | | | |  S(   u8   
        get the bounding box in display space.
        (   Rc   RZ   Rd   R   Re   (   R8   RY   R#   R)   Ra   Rb   Rn   Ro   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRh   2  s    c         C` s.  |  j  j |  j  j   \ } } | j d |  j  j d t \ } } } |  j  j |  \ } } }	 | j | j }
 } | d d } |  j j	   t
 |  d k r |  j r d | d | | } |  j j d |	 |  | }	 n? t | | | |	  } |  j   rt |	 |  }	 n  | |	 } |
 | d |	 f S(   Nu   lpt   ismathii    i   g      ?g        (   R   t   is_math_textt   get_text_width_height_descentt   _fontpropertiesR5   t   _get_layoutRV   R,   R   R   R   R   R   R   R   (   R8   RY   t
   clean_lineR   t   _t   h_t   d_R   t   infoR*   R#   R)   t   linet   d_newt   h_d(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRc   :  s     !	
c      	   C` s?   |  j  j |  t |  | d t d t d d  t |  _ d S(   u#   
        Draw the children
        Ri   Rj   Rk   g        N(   R   Rl   R   R5   Rm   RF   (   R8   RY   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRl   Z  s    "N(   Rp   Rq   Rr   R   RE   R3   R   R   R   R   R   R   R   RT   RZ   Rh   Rc   Rl   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s    (					
						 t   AuxTransformBoxc           B` s_   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   uY  
    Offset Box with the aux_transform . Its children will be
    transformed with the aux_transform first then will be
    offseted. The absolute coordinate of the aux_transform is meaning
    as it will be automatically adjust so that the left-lower corner
    of the bounding box of children will be set to (0,0) before the
    offset transform.

    It is similar to drawing area, except that the extent of the box
    is not predetermined but calculated from the window extent of its
    children. Furthermore, the extent of the children will be
    calculated in the transformed coordinate.
    c         C` se   | |  _  t j |   t j   |  _ |  j j   |  j j d d  t j   |  _ |  j j   d  S(   Ni    (	   t   aux_transformR1   R3   Rd   R   R   R   R   t   ref_offset_transform(   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3   s  s    	c         C` s0   |  j  j |  | j |  j    t |  _ d S(   u?   Add any :class:`~matplotlib.artist.Artist` to the container boxN(   R6   R   R   R   RE   RF   (   R8   RQ   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s    c         C` s   |  j  |  j |  j S(   uf   
        Return the :class:`~matplotlib.transforms.Transform` applied
        to the children
        (   R   R   R   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s    c         C` s   d S(   u+   
        set_transform is ignored.
        N(    (   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s    c         C` s>   | |  _  |  j j   |  j j | d | d  t |  _ d S(   uj   
        set offset of the container.

        Accept : tuple of x,y coordinate in display units.
        i    i   N(   R7   R   R   R   RE   RF   (   R8   RS   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRT     s    	c         C` s   |  j  S(   u1   
        return offset of the container.
        (   R7   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRZ     s    c         C` sN   |  j  |  \ } } } } |  j   \ } } t j j | | | | | |  S(   u8   
        get the bounding box in display space.
        (   Rc   RZ   Rd   R   Re   (   R8   RY   R#   R)   Ra   Rb   Rn   Ro   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRh     s    c         C` s   |  j  j   } |  j j   |  j  j   g  |  j D] } | j |  ^ q3 } t j j |  } |  j j	 | j
 | j  |  j  j |   } |  j  j |  | j | j d d f S(   Ng        (   R   t	   to_valuesR   R   R6   Rh   Rd   R   t   unionR   R   R   t   matrix_from_valuest
   set_matrixRV   R,   (   R8   RY   t   _offRK   t   bboxest   ubt   mtx(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRc     s    %c      	   C` sP   x |  j  D] } | j |  q
 Wt |  | d t d t d d  t |  _ d S(   u#   
        Draw the children
        Ri   Rj   Rk   g        N(   R6   Rl   R   R5   Rm   RF   (   R8   RY   RK   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRl     s    "(   Rp   Rq   Rr   R3   R   R   R   RT   RZ   Rh   Rc   Rl   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR   e  s   									t   AnchoredOffsetboxc           B` s   e  Z d  Z d Z i
 d d 6d d 6d d 6d d	 6d d
 6d d 6d d 6d d 6d d 6d d 6Z d d d# d# e d# d# d  Z d   Z d   Z	 d   Z
 d   Z d   Z d# d  Z d   Z d# d  Z d# d   Z d!   Z d"   Z RS($   u7  
    An offset box placed according to the legend location
    loc. AnchoredOffsetbox has a single child. When multiple children
    is needed, use other OffsetBox class to enclose them.  By default,
    the offset box is anchored against its parent axes. You may
    explicitly specify the bbox_to_anchor.
    i   i   u   upper righti   u
   upper lefti   u
   lower lefti   u   lower rightu   righti   u   center lefti   u   center righti   u   lower centeri	   u   upper centeri
   u   centerg?g      ?c	   
      K` s~  t  t |   j |	   |  j | |  |  j |  t | t j  r y |  j | } Wq t	 k
 r t
 d | d j |  j  f   q Xn  | |  _ | |  _ | |  _ | d k r t d t d  |  _ nM t | t  rt |   |  _ d | k r|  j j t d  qn	 | |  _ t d d d d	 d
 d	 d d d d d |  j j   d t  |  _ |  j j d d d | |  _ d S(   u  
        loc is a string or an integer specifying the legend location.
        The valid location codes are::

        'upper right'  : 1,
        'upper left'   : 2,
        'lower left'   : 3,
        'lower right'  : 4,
        'right'        : 5, (same as 'center right', for back-compatibility)
        'center left'  : 6,
        'center right' : 7,
        'lower center' : 8,
        'upper center' : 9,
        'center'       : 10,

        pad : pad around the child for drawing a frame. given in
          fraction of fontsize.

        borderpad : pad between offsetbox frame and the bbox_to_anchor,

        child : OffsetBox instance that will be anchored.

        prop : font property. This is only used as a reference for paddings.

        frameon : draw a frame box if True.

        bbox_to_anchor : bbox to anchor. Use self.axes.bbox if None.

        bbox_transform : with which the bbox_to_anchor will be transformed.

        u4   Unrecognized location "%s". Valid locations are
	%s
u   
	t   sizeu   legend.fontsizeu   sizeRS   g        RV   g      ?R,   R   u   wR   u   kR   R   u   squareRk   i    N(   g        g        (   R2   R   R3   t   set_bbox_to_anchort	   set_childRC   t   sixt   string_typest   codest   KeyErrorR   t   joint   loct	   borderpadRk   R   R	   R   t   propRm   t   set_sizeR
   t   get_size_in_pointsRE   R   R   R   (
   R8   R   Rk   R   R   R   t   frameont   bbox_to_anchort   bbox_transformR   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3     s4    %#				c         C` s1   | |  _  | d k	 r$ |  j | _ n  t |  _ d S(   u   set the child to be anchoredN(   t   _childR   RL   RE   RF   (   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR   /  s    	c         C` s   |  j  S(   u   return the child(   R   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt	   get_child6  s    c         C` s
   |  j  g S(   u   return the list of children(   R   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRI   :  s    c         C` sn   |  j    j |  \ } } } } | j |  j j    } |  j | } | d | | d | | | | | f S(   uq   
        return the extent of the artist. The extent of the child
        added with the pad is returned
        i   (   R   Rc   Rw   R   R   Rk   (   R8   RY   R#   R)   Ra   Rb   R   Rk   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRc   >  s    !c         C` sI   |  j  d k r |  j j S|  j } | d k r5 |  j  St |  j  |  Sd S(   uB   
        return the bbox that the legend will be anchored
        N(   t   _bbox_to_anchorR   RL   R   t   _bbox_to_anchor_transformR   (   R8   t	   transform(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_bbox_to_anchorI  s    
		c         C` s   | d k s t | t  r' | |  _ nu y t |  } Wn' t k
 r` t d t |    n X| d k r | d | d d d g } n  t j	 |   |  _ | |  _
 t |  _ d S(   uF  
        set the bbox that the child will be anchored.

        *bbox* can be a Bbox instance, a list of [left, bottom, width,
        height], or a list of [left, bottom] where the width and
        height will be assumed to be zero. The bbox will be
        transformed to display coordinate by the given transform.
        u   Invalid argument for bbox : %si   i    i   N(   R   RC   R   R   R   t	   TypeErrorR   t   strR   Re   R   RE   RF   (   R8   R   R   t   l(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR   W  s    		c         C` sg   |  j  |  |  j |  \ } } } } |  j | | | | |  \ } } t j | | | | | |  S(   u8   
        get the bounding box in display space.
        (   t   _update_offset_funcRc   RZ   R   Re   (   R8   RY   R#   R)   Ra   Rb   Rn   Ro   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRh   p  s    !c         C` sG   | d k r' | j |  j j    } n  | |  d  } |  j |  d S(   us   
        Update the offset func which depends on the dpi of the
        renderer (because of the padding).
        c         S` sd   t  j d d |  |  } | j | } | j   }	 | j | j | |	 |  \ }
 } |
 | | | f S(   Ni    (   R   Re   R   R   t   _get_anchored_bboxR   (   R#   R)   Ra   Rb   RY   R   R8   R   R   R   R   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR7     s    N(   R   Rw   R   R   RT   (   R8   RY   R   R7   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR   y  s
    c         C` sB   |  j  j | j | j | j | j  | r> |  j  j |  n  d  S(   N(   R   R   R   R   RV   R,   R   (   R8   R   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s    c   
      C` s   |  j    s d S| j |  j j    } |  j | |  |  j rs |  j |  } |  j | |  |  j j	 |  n  |  j
 |  \ } } } } |  j | | | | |  \ } }	 |  j   j | |	 f  |  j   j	 |  t |  _ d S(   u   draw the artistN(   R]   Rw   R   R   R   R   Rh   R   R   Rl   Rc   RZ   R   RT   R5   RF   (
   R8   RY   R   R   RV   R,   RW   RX   Rf   Rg   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRl     s    	!c         C` s   | t  d d  k s t  t d  \ } } } } }	 }
 } } } } } i
 d | 6d | 6d | 6d |	 6d |
 6d | 6d | 6d	 | 6d
 | 6d | 6} | | } | j |  } | j | d | } | j | j f S(   u{   
        return the position of the bbox anchored at the parentbbox
        with the loc code, with the borderpad.
        i   i   u   NEu   NWu   SWu   SEu   Eu   Wu   Su   Nu   Ct	   container(   t   ranget   AssertionErrorR   t   paddedt   anchoredR   R   (   R8   R   R   t
   parentbboxR   t   BESTt   URt   ULt   LLt   LRt   Rt   CLt   CRt   LCt   UCt   Ct   anchor_coefsRK   R   t   anchored_box(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s     -


N(   Rp   Rq   Rr   t   zorderR   R   RE   R3   R   R   RI   Rc   R   R   Rh   R   R   Rl   R   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR     s6   

	D								t   AnchoredTextc           B` s    e  Z d  Z d d d d  Z RS(   u&   
    AnchoredOffsetbox with Text.
    g?g      ?c   	      K` s   | d k r i  } n  d d d d h } | t |  @rG t j d  n  t | d | d t |  _ |  j j j   } t	 t
 |   j | d | d	 | d
 |  j d | | d S(   u*  
        Parameters
        ----------
        s : string
            Text.

        loc : str
            Location code.

        pad : float, optional
            Pad between the text and the frame as fraction of the font
            size.

        borderpad : float, optional
            Pad between the frame and the axes (or *bbox_to_anchor*).

        prop : `matplotlib.font_manager.FontProperties`
            Font properties.

        Notes
        -----
        Other keyword parameters of `AnchoredOffsetbox` are also
        allowed.
        u   hau   horizontalalignmentu   vau   verticalalignmentuS   Mixing horizontalalignment or verticalalignment with AnchoredText is not supported.R   R   Rk   R   R   R   N(   R   t   sett   warningst   warnR   R5   t   txtR   t   get_fontpropertiesR2   R	  R3   (	   R8   R   R   Rk   R   R   R   t	   badkwargst   fp(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3     s    	N(   Rp   Rq   Rr   R   R3   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR	    s   t   OffsetImagec        
   B` s}   e  Z d  d d d d d  d e e d 	 Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z RS(   i   g      @c         K` s   t  j |   |
 |  _ t d |  j d | d | d | d | d | d | d |	 |  |  _ |  j g |  _ |  j |  |  j |  d  S(	   NR   t   cmapt   normt   interpolationt   origint
   filternormt	   filterradt   resample(	   R1   R3   t   _dpi_corR   Rh   t   imageR6   t   set_zoomt   set_data(   R8   t   arrt   zoomR  R  R  R  R  R  R  R   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3     s    	c         C` s2   t  j |  |  _ |  j j |  j  t |  _ d  S(   N(   R   t   asarrayt   _dataR  R  RE   RF   (   R8   R  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR    s    c         C` s   |  j  S(   N(   R   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_data  s    c         C` s   | |  _  t |  _ d  S(   N(   t   _zoomRE   RF   (   R8   R  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR    s    	c         C` s   |  j  S(   N(   R"  (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_zoom"  s    c         C` s   |  j  S(   u1   
        return offset of the container.
        (   R7   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRZ   4  s    c         C` s
   |  j  g S(   N(   R  (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRI   :  s    c         C` sN   |  j  |  \ } } } } |  j   \ } } t j j | | | | | |  S(   u8   
        get the bounding box in display space.
        (   Rc   RZ   Rd   R   Re   (   R8   RY   R#   R)   Ra   Rb   Rn   Ro   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRh   =  s    c   	      C` sy   |  j  r | j d  } n d } |  j   } |  j   } | j d  \ } } | | | | | | } } | | d d f S(   Ng      ?i   i    (   R  Rw   R#  R!  t   shape(	   R8   RY   R   R  t   datat   nyt   nxR#   R)   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRc   E  s    	c         C` s   |  j  j |  t |  _ d S(   u#   
        Draw the children
        N(   R  Rl   R5   RF   (   R8   RY   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRl   R  s    N(   Rp   Rq   R   R5   RE   R3   R  R!  R  R#  RZ   RI   Rh   Rc   Rl   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR    s$   								t   AnnotationBboxc           B` s   e  Z d  Z d Z d   Z e j d d d e d d d d d d d 
  Z	 e
 d    Z e j d    Z e
 d	    Z e j d
    Z d   Z d   Z d   Z d d  Z d d  Z d   Z d   Z d   Z RS(   uD   
    Annotation-like class, but with offsetbox instead of Text.
    i   c         C` s   d |  j  d |  j  d f S(   Nu   AnnotationBbox(%g,%g)i    i   (   RS   (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   __str__a  s    u   datag?g      ?c         K` se  t  j j |  |  t j |  | d | d | | |  _ | |  _ |  j |  | d k rf | |  _ n	 | |  _ | d k r | |  _	 n	 | |  _	 | d k	 r |  j j
 d d  |  _ t d d |  j  |  _ n d |  _ d |  _ |	 |  _ t d d d	 d
 d d
 d d d d d |  j j   d t  |  _ |  j j d d | |
 rX|  j j |
   n  | |  _ d S(   uo  
        *offsetbox* : OffsetBox instance

        *xycoords* : same as Annotation but can be a tuple of two
           strings which are interpreted as x and y coordinates.

        *boxcoords* : similar to textcoords as Annotation but can be a
           tuple of two strings which are interpreted as x and y
           coordinates.

        *box_alignment* : a tuple of two floats for a vertical and
           horizontal alignment of the offset box w.r.t. the *boxcoords*.
           The lower-left corner is (0.0) and upper-right corner is (1.1).

        other parameters are identical to that of Annotation.
        t   xycoordst   annotation_clipu   relposg      ?i    i   RS   g        RV   g      ?R,   R   u   wR   u   kR   R   u   squareRk   N(   g      ?g      ?(   i    i    (   i   i   (   g        g        (   R:   R;   R3   R   t	   offsetboxt
   arrowpropst   set_fontsizeR   t   xyboxt	   boxcoordst   popt   _arrow_relposR   t   arrow_patcht   _box_alignmentR
   R   R   RE   R   R   R
  R   (   R8   R,  RS   R/  R*  R0  R   Rk   R+  t   box_alignmentt	   bboxpropsR-  R   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3   d  s<    									c         C` s   |  j  S(   N(   R/  (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   xyann  s    c         C` s   | |  _  t |  _ d  S(   N(   R/  RE   RF   (   R8   R7  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR7    s    	c         C` s   |  j  S(   N(   R0  (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt	   anncoords  s    c         C` s   | |  _  t |  _ d  S(   N(   R0  RE   RF   (   R8   t   coords(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR8    s    	c         C` s"   |  j  j |  \ } } | | f S(   N(   R,  RO   (   R8   t   eventR   t   tinfo(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRO     s    c         C` s2   |  j  |  j g } |  j r. | j |  j  n  | S(   N(   R,  R   R3  R   (   R8   Ru   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRI     s    	c         C` sI   |  j  d  k	 r" |  j  j |  n  |  j j |  t j j |  |  d  S(   N(   R3  R   RH   R,  R:   R;   (   R8   RJ   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRH     s    c         C` s8   | d k r t d } n  t d |  |  _ t |  _ d S(   u(   
        set fontsize in points
        u   legend.fontsizeR   N(   R   R   R	   R   RE   RF   (   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR.    s    c         C` s   |  j  j   S(   u+   
        return fontsize in points
        (   R   R   (   R8   R   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_fontsize  s    c         C` sd   |  j  |  } |  j | |  | j |  j    } |  j j |  |  j r` |  j j |  n  d S(   uQ   
        Update the pixel positions of the annotated point and the text.
        N(   t   _get_position_xyt   _update_position_xyboxRw   R<  R   R   R3  (   R8   RY   t   xy_pixelR   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   update_positions  s    	c         C` s1  |  j  \ } } t |  j t  r| |  j \ } } |  j | | | |  \ } } |  j | | | |  \ }	 }
 | |
 } } n! |  j | | | |  j  \ } } |  j j |  \ } } } } |  j \ } } |  j j | | | | | | | | f  |  j j	 |  } |  j
 j | j | j | j | j  | \ } } | | } } |  j r-| | } } |  j j   } |  j } | j | j | d } | j | j | d } |  j j | | f | | f  |  j j   } | j d |  } | j |  } |  j j |  | j d |  j
  } |  j j |  n  d S(   u`   
        Update the pixel positions of the annotation text and the arrow
        patch.
        i    i   u   mutation_scaleu   patchAN(   R/  RC   R0  t   tuplet   _get_xyR,  Rc   R4  RT   Rh   R   R   R   R   RV   R,   R-  t   copyR2  R3  t   set_positionsR   R   R1  Rw   R   t
   set_patchA(   R8   RY   R?  t   xt   yt   xcoordt   ycoordt   x1t   y1t   x2t   y2t   ox0t   oy0R#   R)   Ra   Rb   t   _fwt   _fhR   t   ox1t   oy1R   R   R*   t   relpost   fsR   t   patchA(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR>    s8    !.		c         C` s   | d k	 r | |  _ n  |  j   s( d S|  j |  } |  j | |  sM d S|  j |  |  j d k	 r |  j j d k r |  j d k	 r |  j |  j _ n  |  j j |  n  |  j	 r |  j
 j |  n  |  j j |  t |  _ d S(   uN   
        Draw the :class:`Annotation` object to the given *renderer*.
        N(   R   t	   _rendererR]   R=  t	   _check_xyR@  R3  R   Rl   R   R   R,  R5   RF   (   R8   RY   R?  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRl   0  s     !	N(   g      ?g      ?(   Rp   Rq   Rr   R  R)  R   t   dedent_interpdR   RE   R3   R   R7  Rs   R8  RO   RI   RH   R.  R<  R@  R>  Rl   (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR(  [  s2   	@	
		
		<t   DraggableBasec           B` sk   e  Z d  Z e d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z RS(   u/  
    helper code for a draggable artist (legend, offsetbox)
    The derived class must override following two method.

      def save_offset(self):
          pass

      def update_offset(self, dx, dy):
          pass

    *save_offset* is called when the object is picked for dragging and it
    is meant to save reference position of the artist.

    *update_offset* is called during the dragging. dx and dy is the pixel
     offset from the point where the mouse drag started.

    Optionally you may override following two methods.

      def artist_picker(self, artist, evt):
          return self.ref_artist.contains(evt)

      def finalize_offset(self):
          pass

    *artist_picker* is a picker method that will be
     used. *finalize_offset* is called when the mouse is released. In
     current implementation of DraggableLegend and DraggableAnnotation,
     *update_offset* places the artists simply in display
     coordinates. And *finalize_offset* recalculate their position in
     the normalized axes coordinate and set a relavant attribute.

    c         C` s   | |  _  t |  _ |  j  j j |  _ | o3 |  j j |  _ |  j j d |  j  } |  j j d |  j	  } | j
 |  j  | | g |  _ d  S(   Nu
   pick_eventu   button_release_event(   t
   ref_artistR5   t
   got_artistR   t   canvast   supports_blitt	   _use_blitt   mpl_connectt   on_pickt
   on_releaset
   set_pickert   artist_pickert   cids(   R8   R[  t   use_blitt   c2t   c3(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3   n  s    		c         C` sM   |  j  rI | j |  j } | j |  j } |  j | |  |  j j   n  d  S(   N(   R\  RF  t   mouse_xRG  t   mouse_yt   update_offsetR]  Rl   (   R8   t   evtt   dxt   dy(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt	   on_motion{  s
    	c         C` s   |  j  r | j |  j } | j |  j } |  j | |  |  j j |  j  |  j	 j
 |  j	 j j  |  j j |  j	 j j  n  d  S(   N(   R\  RF  Ri  RG  Rj  Rk  R]  t   restore_regiont
   backgroundR[  Rl   R   t   _cachedRenderert   blitR   (   R8   Rl  Rm  Rn  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   on_motion_blit  s    	c         C` s   | j  |  j k r | j j |  _ | j j |  _ t |  _ |  j	 r |  j j
 t  |  j j   |  j j |  j j j  |  _ |  j j |  j j j  |  j j |  j j j  |  j j d |  j  |  _ n |  j j d |  j  |  _ |  j   n  d  S(   Nu   motion_notify_event(   t   artistR[  RP   RF  Ri  RG  Rj  RE   R\  R_  t   set_animatedR]  Rl   t   copy_from_bboxR   R   Rq  Rr  Rs  R`  Rt  t   _c1Ro  t   save_offset(   R8   Rl  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRa    s     			c         C` sR   |  j  rN |  j   t |  _  |  j j |  j  |  j rN |  j j t  qN n  d  S(   N(	   R\  t   finalize_offsetR5   R]  t   mpl_disconnectRx  R_  R[  Rv  (   R8   R:  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRb    s    	
		c         C` sY   x! |  j  D] } |  j j |  q
 Wy |  j } Wn t k
 rD n X|  j j |  d S(   u   disconnect the callbacksN(   Re  R]  R{  Rx  t   AttributeError(   R8   t   cidt   c1(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt
   disconnect  s    c         C` s   |  j  j |  S(   N(   R[  RO   (   R8   Ru  Rl  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRd    s    c         C` s   d  S(   N(    (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRy    s    c         C` s   d  S(   N(    (   R8   Rm  Rn  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRk    s    c         C` s   d  S(   N(    (   R8   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRz    s    (   Rp   Rq   Rr   R5   R3   Ro  Rt  Ra  Rb  R  Rd  Ry  Rk  Rz  (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRZ  M  s    										t   DraggableOffsetBoxc           B` s/   e  Z e d   Z d   Z d   Z d   Z RS(   c         C` s#   t  j |  | d | | |  _ d  S(   NRf  (   RZ  R3   R,  (   R8   R[  R,  Rf  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3     s    c         C` sq   |  j  } | j j } | j |  \ } } } } | j | | | | |  } | \ |  _ |  _ |  j  j |  d  S(   N(   R,  R   Rr  Rc   RZ   t   offsetbox_xt   offsetbox_yRT   (   R8   R,  RY   R#   R)   Ra   Rb   RA   (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRy    s    	c         C` s.   |  j  | |  j | f } |  j j |  d  S(   N(   R  R  R,  RT   (   R8   Rm  Rn  t   loc_in_canvas(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRk    s    c   
      C` sW   |  j  } | j j } | j |  \ } } } } | j \ } } | | | | f }	 |	 S(   N(   R,  R   Rr  Rc   R7   (
   R8   R,  RY   R#   R)   Ra   Rb   Rn   Ro   R  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   get_loc_in_canvas  s    	(   Rp   Rq   R5   R3   Ry  Rk  R  (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR    s   		t   DraggableAnnotationc           B` s&   e  Z e d   Z d   Z d   Z RS(   c         C` s#   t  j |  | d | | |  _ d  S(   NRf  (   RZ  R3   t
   annotation(   R8   R  Rf  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR3     s    c         C` s1   |  j  } | j   j | j  \ |  _ |  _ d  S(   N(   R  R   R   R7  Rn   Ro   (   R8   t   ann(    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRy    s    	c         C` s?   |  j  } | j   j   j |  j | |  j | f  | _ d  S(   N(   R  R   t   invertedR   Rn   Ro   R7  (   R8   Rm  Rn  R  (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyRk    s    	(   Rp   Rq   R5   R3   Ry  Rk  (    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyR    s   	u   __main__i   iy   i   i   g      p@R  i   R  R  id   g      ?R/  i   R*  u   dataR0  u   offset pointsR   Rk   g?R6  t   boxstyleu   roundt   fcu   yR   R-  t
   arrowstyleu   ->(   id   id   (   g      ?g      ?(   i   i   (U   Rr   t
   __future__R    R   R   R   R   t	   six.movesR   R   R  t   matplotlib.transformst
   transformsRd   t   matplotlib.artistRu  R:   t   matplotlib.textt   textR   t   matplotlib.patht   pathR   t   numpyR   R   R   R   t   matplotlib.font_managerR	   t   matplotlib.patchesR
   R   t
   matplotlibR   R   t   matplotlib.imageR   R   R   R   R5   R   R'   R0   R;   R1   Rt   Rv   R   R   R   R   R   R   R	  R  R(  t   objectRZ  R  R  Rp   t   matplotlib.pyplott   pyplott   pltR   RJ   t   clft   subplotRN   Rm   R   R   t   reshapeRQ   R   t   myimageR   RT   t   myimage2RE   R  Rl   t   show(    (    (    s3   lib/python2.7/site-packages/matplotlib/offsetbox.pyt   <module>   s   "		1%,NOSk-ft
					
