
1aGc           @   s  d  Z  d d k l Z d d k Z d d k Z d d k Z d d k Z d d k l Z d d k l	 Z	 d d k l
 Z
 d d k Z d d k l Z d d k	 l Z l Z l Z l Z d d	 k l Z d d
 k l Z l Z d d k l Z l Z l Z d d k l Z d d k i Z e d  Z d   Z  e d d d d  Z! d e i" d <d e f d     YZ# e i$ e#  e i" d <d e# f d     YZ% e i$ e%  e i" d <d e# f d     YZ& e& i' i  e i" d <d S(   s   
Figure and Axes text
i(   t   divisionN(   t   verbose(   t   cbook(   t   rcParams(   t   Artist(   t	   enumeratet   is_string_liket   maxdictt
   is_numlike(   t   FontProperties(   t   bbox_artistt   YAArrow(   t   lbwh_to_bboxt   bbox_allt   identity_transform(   t   Line2Dc         K   s/   | d j	 o |  i |  n |  i |  |  S(   s7   Return an override dict.  See 'text' docstring for infoN(   t   Nonet   update(   t   overridet   fontdictt   kwargs(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   _process_text_args   s    c         C   sB   |  d j o
 d } n$ |  d j o
 d } n t |   } | d S(   s   return the text angle as floatt
   horizontalg        t   verticalg     V@ih  N(   R   N(   R   t   float(   t   rotationt   angle(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_rotation!   s    

i    i   s      alpha: float
    animated: [True | False]
    backgroundcolor: any matplotlib color
    bbox: rectangle prop dict plus key 'pad' which is a pad in points
    clip_box: a matplotlib.transform.Bbox instance
    clip_on: [True | False]
    color: any matplotlib color
    family: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
    figure: a matplotlib.figure.Figure instance
    fontproperties: a matplotlib.font_manager.FontProperties instance
    horizontalalignment or ha: [ 'center' | 'right' | 'left' ]
    label: any string
    linespacing: float
    lod: [True | False]
    multialignment: ['left' | 'right' | 'center' ]
    name or fontname: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
    position: (x,y)
    rotation: [ angle in degrees 'vertical' | 'horizontal'
    size or fontsize: [ size in points | relative size eg 'smaller', 'x-large' ]
    style or fontstyle: [ 'normal' | 'italic' | 'oblique']
    text: string
    transform: a matplotlib.transform transformation instance
    variant: [ 'normal' | 'small-caps' ]
    verticalalignment or va: [ 'center' | 'top' | 'bottom' | 'baseline' ]
    visible: [True | False]
    weight or fontweight: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
    x: float
    y: float
    zorder: any number
    t   Textc           B   sI  e  Z d  Z d Z d   Z d d d d> d d d> d> d> d> d 
 Z e i e i  e	 i
 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 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> 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.   Z0 d/   Z1 d0   Z2 d1   Z3 d2   Z4 d3   Z5 d4   Z6 d5   Z7 d6   Z8 d7   Z9 d8   Z: d9   Z; d:   Z< d;   Z= d<   Z> d=   Z? RS(?   sK   
    Handle storing and drawing of text in window or data coordinates

    i   c         C   s   d |  i  |  i  |  i f S(   Ns   Text(%g,%g,%s)(   t   _yt   _text(   t   self(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   __str__V   s    i    t    t   bottomt   leftc         K   s  t  i |   t d  |  _ | | |  _ |  _ | d j o t d } n | d j o t   } n t	 |  o t |  } n |  i
 |  |  i |  | |  _ | |  _ | |  _ |	 |  _ | |  _ d |  _ d |  _ |
 d j o
 d }
 n |
 |  _ |  i |  d S(   sl   
        Create a Text instance at x,y with string text.

        Valid kwargs are
        %(Text)s
        i   s
   text.colorg333333?N(   R   t   __init__R   t   cachedt   _xR   R   R   R	   R   t   set_textt	   set_colort   _verticalalignmentt   _horizontalalignmentt   _multialignmentt	   _rotationt   _fontpropertiest   _bboxt	   _renderert   _linespacingR   (   R   t   xt   yt   textt   colort   verticalalignmentt   horizontalalignmentt   multialignmentt   fontpropertiesR   t   linespacingR   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR$   Y   s&    							
	c         C   s   t  |  i  o |  i |  |  Sn y" |  i   i   \ } } } } Wn t h  f Sn X| | } | | } | | f | | f | | f | | f f } | i | i }	 }
 t i |	 |
 |  } | h  f S(   sU   Test whether the mouse event occurred in the patch.

        Returns T/F, {}
        (	   t   callablet	   _containst   get_window_extentt
   get_boundst   FalseR1   R2   t   nxutilst   pnpoly(   R   t
   mouseeventt   lt   bt   wt   ht   rt   tt   xyvertsR1   R2   t   inside(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   contains   s    $"

*c         C   s+   |  i    \ } } |  i   i | | f  S(   sC   get the (possibly unit converted) transformed x,y in display coords(   t   get_positiont   get_transformt   xy_tup(   R   R1   R2   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   _get_xy_display   s    c         C   s&   |  i  d  j	 o |  i  Sn |  i Sd  S(   N(   R+   R   R*   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   _get_multialignment   s    c         C   s   t  |  i  S(   s   return the text angle as float(   R   R,   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR      s    c         C   sz   t  i |  |  | i |  _ | i |  _ | i |  _ | i |  _ | i i   |  _ | i |  _ | i	 |  _	 | i
 |  _
 d S(   s"   Copy properties from other to selfN(   R   t   update_fromt   _colorR+   R)   R*   R-   t   copyR,   t   _pickerR0   (   R   t   other(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRP      s    c   2      C   s  |  i    } |  i i |  o |  i | Sn g  } |  i   \ } } d } d } | | } }	 |  i i d  }
 g  } | i d |  i d t \ } } } | |  i	 } d  } x |
 D] } | i | |  i d |  i |  \ } } } | d  j o | | } n | i | | f  | i | | | | | f  | | 8} t | |  } q W| d d }	 | d d | d d } | |	 } | | } |  i | |	  } | |	 f | | f | | f | |	 f f } g  } t |
  d j o |  i   } x | D]v \ } } } } } | d j o | d	 | d	 } n" | d
 j o | | } n d } | | 7} | i | | f  qWn7 g  } | D]" \ } } } } } | | | f q|~ } g  } | D]: \ } } | t i | t i | g | g d g g   q~ } g  } | D] }  | t |  d d  q ~ }! g  }" | D] }  |" t |  d d  q/~" }# t |!  t |!  } } t |#  t |#  }	 } | | } | |	 } |  i }$ |  i }% |  i   \ }& }' |$ d j o |& | | d	 } n* |$ d
 j o |& | | } n |& | } |% d j o |' |	 | d	 } nM |% d j o |' |	 | } n. |% d j o |' |	 | | } n |' |	 } | | 7} | | 7} |	 | 7}	 | | 7} t | |	 | |  }( g  }) | D]: \ } } |) t i | t i | g | g d g g   q~) }* g  }+ |* D] }  |+ t |  d d  | q~+ }& g  }, |* D] }  |, t |  d d  | qA~, }' g  }- t |& |'  D] }. |- |  i   i |.  q}~- }* t |*   \ }/ }0 |( t |
 | |/ |0  f }1 |1 |  i | <|1 S(   Ni    s   
t   lpt   ismathii   i   t   centerg       @t   rightt   topt   baseline(   t   get_prop_tupR%   t   has_keyRN   R   t   splitt   get_text_width_height_descentR-   R>   R0   R   t   is_math_textt   appendt   maxt   get_rotation_matrixt   lenRO   t   npyt   dott   arrayR   t   minR*   R)   R   t   zipRL   t   inverse_xy_tup(2   R   t   renderert   keyt   horizLayoutt   thisxt   thisyt   widtht   heightt   xmint   ymint   linest   whst   tmpt   heighttt   blt   offsetyRZ   t   lineRD   RE   t   dt   ymaxt   xmaxt   Mt   cornersHorizt   offsetLayoutt   malignt   offsetxt   _[1]t   _[2]t   cornersRotatedt   _[3]t   vt   txst   _[4]t   tyst   halignt   valignt   txt   tyt   bboxt   _[5]t   xyst   _[6]t   _[7]t   _[8]t   xyt   xst   yst   ret(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   _get_layout   s    " '


* #
6N//

		#
##




N339c         C   s   | |  _  d S(   s  
        Draw a bounding box around self.  rect props are any settable
        properties for a rectangle, eg facecolor='red', alpha=0.5.

          t.set_bbox(dict(facecolor='red', alpha=0.5))

        ACCEPTS: rectangle prop dict plus key 'pad' which is a pad in points
        N(   R.   (   R   t	   rectprops(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_bbox  s    	c         C   s  | d  j	 o | |  _ n |  i   p d  Sn |  i d j o d  Sn | i   } | i |  i  | i |  i  |  i	   o | i
 |  i i    n |  i o t |  | |  i  n |  i   } |  i |  \ } } |  i   } t d o | i   \ } } xo | D]g \ }	 }
 } } | i | | f  \ } } | i   o | | } n | i | | | |	 |  i |  qWd  Sn x | D] \ }	 }
 } } | i | | f  \ } } | i   o  | i   \ } } | | } n | i | | | |	 |  i | d |  i |	  qWd  S(   NR!   s   text.usetexRV   (   R   R/   t   get_visibleR   t   new_gct   set_foregroundRQ   t	   set_alphat   _alphat   get_clip_ont   set_clip_rectanglet   clipboxR=   R.   R
   R   R   RL   R   t   get_canvas_width_heightRM   t   flipyt   draw_texR-   t	   draw_textR_   (   R   Rj   t   gcR   R   t   infot   transt   canvaswt   canvashRy   t   whR1   R2   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   draw*  sB    
  c         C   s   |  i  S(   s   Return the color of the text(   RQ   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt	   get_colorU  s    c         C   s   |  i  S(   s   Return the font object(   R-   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_font_propertiesY  s    c         C   s   |  i  i   d S(   s   Return the font name as stringi(   R-   t
   get_family(   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_name]  s    c         C   s   |  i  i   S(   s   Return the font style as string(   R-   t	   get_style(   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR   a  s    c         C   s   |  i  i   S(   s   Return the font size as integer(   R-   t   get_size_in_points(   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_sizee  s    c         C   s   |  i  i   S(   s   Get the font weight as string(   R-   t
   get_weight(   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR   i  s    c         C   s   |  i  i   d S(   s   alias for get_namei(   R-   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_fontnamem  s    c         C   s   |  i  i   S(   s   alias for get_style(   R-   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_fontstyleq  s    c         C   s   |  i  i   S(   s   alias for get_size(   R-   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_fontsizeu  s    c         C   s   |  i  i   S(   s   alias for get_weight(   R-   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_fontweighty  s    c         C   s
   |  i    S(   s!   alias for get_horizontalalignment(   t   get_horizontalalignment(   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_ha~  s    c         C   s   |  i  S(   s)   Return the horizontal alignment as string(   R*   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    c         C   s   |  i    i |  i |  i f  S(   sC   get the (possibly unit converted) transformed x,y in display coords(   RL   RM   R&   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRN     s    c         C   s:   t  |  i |  i   } t  |  i |  i   } | | f S(   s   Return x, y as tuple(   R   t   convert_xunitsR&   t   convert_yunitsR   (   R   R1   R2   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRK     s    c      	   C   sU   |  i    \ } } | | |  i |  i |  i |  i t |  i  |  i |  i   i	   f	 S(   s   
        Return a hashable tuple of properties

        Not intended to be human readable, but useful for backends who
        want to cache derived information about text (eg layouts) and
        need to know if the text has changed
        (
   RK   R   RQ   R)   R*   t   hashR-   R,   RL   t   as_vec6_val(   R   R1   R2   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR[     s
    c         C   s   |  i  S(   s   Get the text as string(   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_text  s    c         C   s
   |  i    S(   s   alias for getverticalalignment(   t   get_verticalalignment(   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   get_va  s    c         C   s   |  i  S(   s'   Return the vertical alignment as string(   R)   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    c         C   s   |  i    p t Sn |  i d j o) |  i   \ } } t | | d d  Sn | d  j	 o | |  _ n |  i d  j o t d   n |  i   } |  i	 |  i  \ } } | S(   NR!   i    s%   Cannot get window extent w/o renderer(
   R   t	   _unit_boxR   RN   R   R   R/   t   RuntimeErrorR   R   (   R   Rj   R   R   R   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR<     s    c         C   s   t  i d |  i   } t  i d d | g d d | g d d d g g  } t  i t  i |  t  i |  d g t  i |  t  i |  d g d d d g g  } t  i d d | g d d | g d d d g g  } t  i t  i | |  |  S(   Ng     f@i   i    (   Rd   t   piR   Rf   t   cost   sinRe   (   R   t   x0t   y0t   thetat   Torigint   Rt   Tback(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRb     s    %c         C   sI   |  i  d j o t d | d |  |  _  n |  i  i t d |   d S(   s   
        Set the background color of the text by updating the bbox (see set_bbox for more info)

        ACCEPTS: any matplotlib color
        t	   facecolort	   edgecolorN(   R.   R   t   dictR   (   R   R4   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_backgroundcolor  s    c         C   s=   y t  |  Wn t j
 o t |  } n X| |  _ d S(   s]   
        Set the foreground color of the text

        ACCEPTS: any matplotlib color
        N(   R   t	   TypeErrort   tupleRQ   (   R   R4   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR(     s
    c         C   s   |  i  |  d S(   s!   alias for set_horizontalalignmentN(   t   set_horizontalalignment(   R   t   align(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_ha  s    c         C   s:   d } | | j o t  d t |    n | |  _ d S(   sj   
        Set the horizontal alignment to one of

        ACCEPTS: [ 'center' | 'right' | 'left' ]
        RW   RX   R#   s&   Horizontal alignment must be one of %sN(   s   centers   rights   left(   t
   ValueErrort   strR*   (   R   R   t   legal(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    c         C   s   |  i  |  d S(   s   alias for set_verticalalignmentN(   t   set_multialignment(   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_ma  s    c         C   s:   d } | | j o t  d t |    n | |  _ d S(   s1  
        Set the alignment for multiple lines layout.  The layout of the
        bounding box of all the lines is determined bu the horizontalalignment
        and verticalalignment properties, but the multiline text within that
        box can be

        ACCEPTS: ['left' | 'right' | 'center' ]
        RW   RX   R#   s&   Horizontal alignment must be one of %sN(   s   centers   rights   left(   R   R   R+   (   R   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    	c         C   s   | |  _  d S(   sv   
        Set the line spacing as a multiple of the font size.
        Default is 1.2.

        ACCEPTS: float
        N(   R0   (   R   t   spacing(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_linespacing  s    c         C   s   |  i  i |  d S(   sx   
        Set the font family

        ACCEPTS: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
        N(   R-   t
   set_family(   R   t   fontname(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    c         C   s   |  i  i |  d S(   sY   
        Set the font variant, eg,

        ACCEPTS: [ 'normal' | 'small-caps' ]
        N(   R-   t   set_variant(   R   t   variant(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR      s    c         C   s   |  i  i |  d S(   sh   
        Set the font name,

        ACCEPTS: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
        N(   R-   R   (   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_name(  s    c         C   s   |  i  |  d S(   s   alias for set_nameN(   R   (   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_fontname0  s    c         C   s   |  i  i |  d S(   sY   
        Set the font style

        ACCEPTS: [ 'normal' | 'italic' | 'oblique']
        N(   R-   t	   set_style(   R   t	   fontstyle(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR   4  s    c         C   s   |  i  i |  d S(   s   alias for set_styleN(   R-   R   (   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_fontstyle<  s    c         C   s   |  i  i |  d S(   s   
        Set the font size, eg, 8, 10, 12, 14...

        ACCEPTS: [ size in points | relative size eg 'smaller', 'x-large' ]
        N(   R-   t   set_size(   R   t   fontsize(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR   @  s    c         C   s   |  i  i |  d S(   s   alias for set_sizeN(   R-   R   (   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_fontsizeH  s    c         C   s   |  i  i |  d S(   s   alias for set_weightN(   R-   t
   set_weight(   R   t   weight(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_fontweightL  s    c         C   s   |  i  i |  d S(   s}   
        Set the font weight

        ACCEPTS: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
        N(   R-   R   (   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR   P  s    c         C   s&   |  i  | d  |  i | d  d S(   sI   
        Set the xy position of the text

        ACCEPTS: (x,y)
        i    i   N(   t   set_xt   set_y(   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_positionX  s    c         C   s   | |  _  d S(   sH   
        Set the x position of the text

        ACCEPTS: float
        N(   R&   (   R   R1   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR   a  s    c         C   s   | |  _  d S(   sH   
        Set the y position of the text

        ACCEPTS: float
        N(   R   (   R   R2   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR   j  s    c         C   s   | |  _  d S(   sm   
        Set the rotation of the text

        ACCEPTS: [ angle in degrees 'vertical' | 'horizontal'
        N(   R,   (   R   t   s(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_rotations  s    c         C   s   |  i  |  d S(   s   alias for set_verticalalignmentN(   t   set_verticalalignment(   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_va}  s    c         C   s:   d } | | j o t  d t |    n | |  _ d S(   sk   
        Set the vertical alignment

        ACCEPTS: [ 'center' | 'top' | 'bottom' | 'baseline' ]
        RY   R"   RW   RZ   s$   Vertical alignment must be one of %sN(   s   tops   bottoms   centers   baseline(   R   R   R)   (   R   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    c         C   s   d | f |  _  d S(   sk   
        Set the text string s

        ACCEPTS: string or anything printable with '%s' conversion
        s   %sN(   R   (   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR'     s    c         C   sY   t  d o d Sn | i d  | i d  } | d j o | d d j o t Sn t S(   Ns   text.usetext   TeXt   $s   \$i    i   (   R   t   countt   TrueR>   (   R   R   t   dollar_count(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR_     s
    c         C   s*   t  |  o t |  } n | |  _ d S(   s   
        Set the font properties that control the text

        ACCEPTS: a matplotlib.font_manager.FontProperties instance
        N(   R   R	   R-   (   R   t   fp(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_fontproperties  s    N(@   t   __name__t
   __module__t   __doc__t   zorderR    R   R$   R   t   dedentt   artistt   kwdocdRJ   RN   RO   R   RP   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   RK   R[   R   R   R   R<   Rb   R   R(   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R'   R_   R   (    (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR   P   s   		 						o		+																																												
				t   TextWithDashc           B   s  e  Z d  Z d Z  d   Z d d d d d d d d d d d d d d d e d  Z d	   Z d
   Z d   Z	 d   Z
 d 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 d   Z d   Z d   Z RS(   s  
    This is basically a Text with a dash (drawn with a Line2D)
    before/after it. It is intended to be a drop-in replacement
    for Text, and should behave identically to Text when
    dashlength=0.0.

    The dash always comes between the point specified by
    set_position() and the text. When a dash exists, the
    text alignment arguments (horizontalalignment,
    verticalalignment) are ignored.

    dashlength is the length of the dash in canvas units.
    (default=0.0).

    dashdirection is one of 0 or 1, npy.where 0 draws the dash
    after the text and 1 before.
    (default=0).

    dashrotation specifies the rotation of the dash, and
    should generally stay None. In this case
    self.get_dashrotation() returns self.get_rotation().
    (I.e., the dash takes its rotation from the text's
    rotation). Because the text center is projected onto
    the dash, major deviations in the rotation cause
    what may be considered visually unappealing results.
    (default=None).

    dashpad is a padding length to add (or subtract) space
    between the text and the dash, in canvas units.
    (default=3).

    dashpush "pushes" the dash and text away from the point
    specified by set_position() by the amount in canvas units.
    (default=0)

    NOTE: The alignment of the two objects is based on the
    bbox of the Text, as obtained by get_window_extent().
    This, in turn, appears to depend on the font metrics
    as given by the rendering backend. Hence the quality
    of the "centering" of the label text with respect to
    the dash varies depending on the backend used.

    NOTE2: I'm not sure that I got the get_window_extent()
    right, or whether that's sufficient for providing the
    object bbox.
    t   textwithdashc         C   s   d |  i  |  i |  i f S(   Ns   TextWithDash(%g,%g,%s)(   R&   R   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR      s    i    R!   RW   g        i   c         C   s   t  i |  d | d | d | d | d | d | d | d | d	 |	 d
 |
 
t d | | f d | | f d d d d  |  _ t |  |  _ t |  |  _ | |  _ | |  _ | |  _	 | |  _
 | |  _ d  S(   NR1   R2   R3   R4   R5   R6   R7   R8   R   R9   t   xdatat   ydatat   kt	   linestylet   -(   R   R$   R   t   dashlineR   t   _dashxt   _dashyt   _dashlengtht   _dashdirectiont   _dashrotationt   _dashpadt	   _dashpush(   R   R1   R2   R3   R4   R5   R6   R7   R8   R   R9   t
   dashlengtht   dashdirectiont   dashrotationt   dashpadt   dashpusht   xaxis(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR$     s$    $				c         C   s:   t  |  i |  i   } t  |  i |  i   } | | f S(   s   Return x, y as tuple(   R   R   R
  R   R  (   R   R1   R2   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRK     s    c      
   C   sk   g  } t  i |   D] } | | q ~ } | i |  i |  i |  i |  i |  i |  i |  i	 g  t
 |  S(   s   
        Return a hashable tuple of properties

        Not intended to be human readable, but useful for backends who
        want to cache derived information about text (eg layouts) and
        need to know if the text has changed
        (   R   R[   t   extendR&   R   R  R  R  R  R  R   (   R   R   t   pt   props(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR[     s    *7c         C   sT   t    |  _ |  i |  t i |  |  |  i   d j o |  i i |  n d  S(   Ng        (   R   R%   t   update_coordsR   R   t   get_dashlengthR	  (   R   Rj   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s
    c          C   s  |  i    \ } } |  i   } | d j o | | |  _ |  _ d Sn |  i   } |  i   } |  i   } |  i   } t |  }	 t	 i
 |	 d | d }
 t	 i |
  t	 i |
  } } |  i   } t	 i | i | | f   } t	 i | | g  } | | | } | | | | } | i t |   \ } } | i t |   \ } } |  i i | | f | | f  t i |  d | } | i   | i   } } | d j o | } d } ng | d j o d } | } nJ | | } | } | | } | | j p | | j  o | } | | } n t	 i | | g  d } | d | t	 i t	 i | |   9} | | d d | } | i t |   \ } } | | |  _ |  _ t i |  d | } | i   |  _ |  i i | d | d f f t  t i |  d  t i |  d  d S(	   s   Computes the actual x,y coordinates for
        text based on the input x,y and the
        dashlength. Since the rotation is with respect
        to the actual canvas's coordinates we need to
        map back and forth.
        g        Ng     f@i   Rj   i   i    RW   (    RK   R  R&   R   t   get_dashrotationt   get_dashdirectiont   get_dashpadt   get_dashpushR   Rd   R   R   R   RL   Rf   RM   Ri   R   R	  t   set_dataR   R<   Ro   Rp   t   sqrtRe   t   deepcopyt   _twd_window_extentR   R>   R   R   (    R   Rj   t   dashxt   dashyR  R  R  R  R  R   R   t	   cos_thetat	   sin_thetat	   transformt   cxyt   cdt   c1t   c2t   x1t   y1t   x2t   y2t   weRD   RE   t   dxt   dyt	   tan_thetat   cwdt   cwt   newxt   newy(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR  %  sX    



'$c         C   sB   |  i  |  |  i   d j o t i |  d | Sn |  i Sd  S(   Ng        Rj   (   R  R  R   R<   R#  (   R   Rj   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR<   {  s    c         C   s   |  i  S(   N(   R  (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR    s    c         C   s   | |  _  d S(   sE   
        Set the length of the dash.

        ACCEPTS: float
        N(   R  (   R   t   dl(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_dashlength  s    c         C   s   |  i  S(   N(   R  (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR    s    c         C   s   | |  _  d S(   s  
        Set the direction of the dash following the text.
        1 is before the text and 0 is after. The default
        is 0, which is what you'd want for the typical
        case of ticks below and on the left of the figure.

        ACCEPTS: int
        N(   R  (   R   t   dd(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_dashdirection  s    	c         C   s)   |  i  d  j o |  i   Sn |  i  Sd  S(   N(   R  R   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR    s    c         C   s   | |  _  d S(   sG   
        Set the rotation of the dash.

        ACCEPTS: float
        N(   R  (   R   t   dr(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_dashrotation  s    c         C   s   |  i  S(   N(   R  (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR    s    c         C   s   | |  _  d S(   s   
        Set the "pad" of the TextWithDash, which
        is the extra spacing between the dash and
        the text, in canvas units.

        ACCEPTS: float
        N(   R  (   R   t   dp(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_dashpad  s    c         C   s   |  i  S(   N(   R  (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR    s    c         C   s   | |  _  d S(   s   
        Set the "push" of the TextWithDash, which
        is the extra spacing between the beginning
        of the dash and the specified position.

        ACCEPTS: float
        N(   R  (   R   R?  (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   set_dashpush  s    c         C   s&   |  i  | d  |  i | d  d S(   sR   
        Set the xy position of the TextWithDash.

        ACCEPTS: (x,y)
        i    i   N(   R   R   (   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    c         C   s   t  |  |  _ d S(   sQ   
        Set the x position of the TextWithDash.

        ACCEPTS: float
        N(   R   R
  (   R   R1   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    c         C   s   t  |  |  _ d S(   sQ   
        Set the y position of the TextWithDash.

        ACCEPTS: float
        N(   R   R  (   R   R2   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    c         C   s$   t  i |  |  |  i i |  d S(   s   
        Set the Transformation instance used by this artist.

        ACCEPTS: a matplotlib.transform transformation instance
        N(   R   t   set_transformR	  (   R   RG   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRB    s    c         C   s   |  i  S(   s   return the figure instance(   t   figure(   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt
   get_figure  s    c         C   s$   t  i |  |  |  i i |  d S(   su   
        Set the figure instance the artist belong to.

        ACCEPTS: a matplotlib.figure.Figure instance
        N(   R   t
   set_figureR	  (   R   t   fig(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRE    s    N(   R   R   R   R    R   R   R$   RK   R[   R   R  R<   R  R:  R  R<  R  R>  R  R@  R  RA  R   R   R   RB  RD  RE  (    (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR    sL   .						V								
									t
   Annotationc           B   su   e  Z d  Z d   Z d	 d d	 d	 d  Z e i e i  e i	 e _ d   Z
 d   Z d   Z d   Z d   Z RS(
   sq   
    A Text class to make annotating things in the figure: Figure,
    Axes, Point, Rectangle, etc... easier
    c         C   s"   d |  i  d |  i  d |  i f S(   Ns   Annotation(%g,%g,%s)i    i   (   R   R   (   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR      s    t   datac   
      K   s   | d j o
 | } n | d j o
 | } n | \ } }	 |  _ t i |  | |	 | |  | |  _ | |  _ d |  _ | |  _ | |  _ d S(   s	  
        Annotate the x,y point xy with text s at x,y location xytext
        (xytext if None defaults to xy and textcoords if None defaults
        to xycoords).

        arrowprops, if not None, is a dictionary of line properties
        (see matplotlib.lines.Line2D) for the arrow that connects
        annotation to the point.   Valid keys are

          - width : the width of the arrow in points
          - frac  : the fraction of the arrow length occupied by the head
          - headwidth : the width of the base of the arrow head in points
          - shrink: often times it is convenient to have the arrowtip
            and base a bit away from the text and point being
            annotated.  If d is the distance between the text and
            annotated point, shrink will shorten the arrow so the tip
            and base are shink percent of the distance d away from the
            endpoints.  ie, shrink=0.05 is 5%%
          - any key for matplotlib.patches.polygon

        xycoords and textcoords are strings that indicate the
        coordinates of xy and xytext.

           'figure points'   : points from the lower left corner of the figure
           'figure pixels'   : pixels from the lower left corner of the figure                           'figure fraction' : 0,0 is lower left of figure and 1,1 is upper, right
           'axes points'     : points from lower left corner of axes
           'axes pixels'     : pixels from lower left corner of axes
           'axes fraction'   : 0,1 is lower left of axes and 1,1 is upper right
           'data'            : use the coordinate system of the object being annotated (default)
           'offset points'     : Specify an offset (in points) from the xy value
           'polar'           : you can specify theta, r for the annotation, even
                               in cartesian plots.  Note that if you
                               are using a polar axes, you do not need
                               to specify polar for the coordinate
                               system since that is the native"data" coordinate system.

        If a points or pixels option is specified, values will be
        added to the left, bottom and if negative, values will be
        subtracted from the top, right.  Eg,

          # 10 points to the right of the left border of the axes and
          # 5 points below the top border
          xy=(10,-5), xycoords='axes points'

        Additional kwargs are Text properties:

        %(Text)s

        N(	   R   t   xytextR   R$   R   t
   arrowpropst   arrowt   xycoordst
   textcoords(
   R   R   R   RI  RL  RM  RJ  R   R1   R2   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR$     s    7

				c         C   s[   t  i |  |  \ } } |  i d  j	 o) |  i i |  \ } } | p | } n | | f S(   N(   R   RJ   RK  R   (   R   t   eventRG   t   tinfot   at   ainfo(    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRJ   A  s
    c         C   s   t  i |  |  d S(   sc   
        Set the artist's clip Bbox

        ACCEPTS: a matplotlib.transform.Bbox instance
        N(   R   t   set_clip_box(   R   R   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRR  I  s    c         C   sf  | d j oM |  i  i } t |  i |   } t |  i |   } | i | | f  Sn	| d j o |  i \ } } |  i d j o |  i | | d  Sn |  i | | |  i  \ } } |  i	 i
 i   } | | d 9} | | d 9} | | 7} | | 7} | | f SnX| d j oV | | } }	 |	 t i |  } |	 t i |  } |  i  i } | i | | f  Sn| d j o |  i	 i
 i   } |  i	 i i   \ }
 } } } |
 | }	 | | } | | d 9} | | d 9} | d j  o |	 | } n | d j  o | | } n | | f SnD| d j ov |  i	 i i   \ }
 } } } |
 | }	 | | } | d j  o |	 | } n | d j  o | | } n | | f Sn| d j o# |  i	 i } | i | | f  Sn| d	 j o |  i	 i
 i   } |  i  i i   \ }
 } } } |
 | }	 | | } | d j  o |	 | | d } n |
 | | d } | d j  o | | | d } n | | | d } | | f Sn | d
 j o |  i  i i   \ }
 } } } |
 | }	 | | } | d j  o |	 | } n |
 | } | d j  o | | } n | | } | | f Sn1 | d j o# |  i  i } | i | | f  Sn d  S(   NRH  s   offset pointsg      R@t   polars   figure pointsi    s   figure pixelss   figure fractions   axes pointss   axes pixelss   axes fraction(   t   axest	   transDataR   R   R   RM   R   RL  t   _get_xyRC  t   dpit   getRd   R   R   R   R=   t   transFiguret	   transAxes(   R   R1   R2   R   R   R2  R3  RW  R   RF   RB   RC   RD   RE   RG   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRV  Q  s    











c         C   s  |  i  \ } } |  i | | |  i  \ |  _ |  _ |  i \ } } |  i | | |  i  \ } } |  i o@| | } } |  i |  i	   \ } } } }	 |  i
 i i   }
 | | } | |	 } d | | } d | | } g  } | | | f D] } | t | |  | f q ~ } | i   | d \ } } g  } | | | f D] } | t | |  | f qB~ } | i   | d \ } } |  i i   } | i d d  } | i d d  } | i d d  } | i d	 d
  } t i | | | |  } t i | | d | | d  } | | t i |  } | | t i |  } t |  i
 i | | | | f | | | | f d | d | d | | |  _ |  i i |  i    n d  S(   Ng      ?i    Ro   i   t	   headwidthi   t   fracg?t   shrinkg        g       @(   RI  RV  RM  R&   R   R   RL  RJ  R<   R=   RC  RW  RX  t   abst   sortRR   t   popt   matht   atan2R!  R   R   R   RK  RR  t   get_clip_box(   R   Rj   R1   R2   R   R   RB   RC   RD   RE   RW  RF   RG   t   xct   ycR   t   valt   dsuRz   R   Ro   R[  R\  R]  R   R2  R3  (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyt   update_positions  s>    $
!

:
:
#1c         C   sE   |  i  |  |  i d  j	 o |  i i |  n t i |  |  d  S(   N(   Rh  RK  R   R   R   (   R   Rj   (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyR     s    N(   R   R   R   R    R   R$   R   R   R   R  RJ   RR  RV  Rh  R   (    (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pyRG    s   	?			`	,((   R   t
   __future__R    t   reRa  t   numpyRd   t
   matplotlibR   R   R   R   R   R   R   R   R   t   font_managerR	   t   patchesR
   R   t
   transformsR   R   R   Rs   R   t   matplotlib.nxutilsR?   R   R   R   R   R  R   t   kwdocR  RG  R$   (    (    (    s8   /Users/cmoad/workspace/matplotlib/lib/matplotlib/text.pys   <module>   s8   "
	
#  \ G