ó
ÄCõRc           @  sœ  d  Z  d d l m Z m Z d d l Z d d l Z d d l m Z d d l	 m
 Z
 m Z d d l m Z m Z m Z m Z d d l m Z d d l m Z d d	 l m Z m Z m Z m Z d d
 l m Z m Z m Z m Z d d l m  Z  m! Z! m" Z" d d l m# Z# m$ Z$ d d l% m& Z& m' Z' m( Z( m) Z) d d l% m* Z* d d l+ m, Z, m- Z- m. Z. d d l/ Z/ d e* f d „  ƒ  YZ0 d e
 f d „  ƒ  YZ1 d S(   s•  
The legend module defines the Legend class, which is responsible for
drawing legends associated with axes and/or figures.

The Legend class can be considered as a container of legend handles
and legend texts. Creation of corresponding legend handles from the
plot elements in the axes or figures (e.g., lines, patches, etc.) are
specified by the handler map, which defines the mapping between the
plot elements and the legend handlers to be used (the default legend
handlers are defined in the :mod:`~matplotlib.legend_handler` module). Note
that not all kinds of artist are supported by the legend yet (See
:ref:`plotting-guide-legend` for more information).
iÿÿÿÿ(   t   divisiont   print_functionN(   t   rcParams(   t   Artistt   allow_rasterization(   t   is_string_liket   iterablet   silent_listt   safezip(   t   FontProperties(   t   Line2D(   t   Patcht	   Rectanglet   Shadowt   FancyBboxPatch(   t   LineCollectiont   RegularPolyCollectiont   CircleCollectiont   PathCollection(   t   Bboxt   BboxBaset   TransformedBbox(   t   BboxTransformTot   BboxTransformFrom(   t   HPackert   VPackert   TextAreat   DrawingArea(   t   DraggableOffsetBox(   t   ErrorbarContainert   BarContainert   StemContainert   DraggableLegendc           B  s;   e  Z e d  d „ Z d „  Z d „  Z d „  Z d „  Z RS(   t   locc         C  sQ   | |  _  | d k r! | |  _ n t d | ƒ ‚ t j |  | | j d | ƒd S(   s¦   
        update : If "loc", update *loc* parameter of
                 legend upon finalizing. If "bbox", update
                 *bbox_to_anchor* parameter.
        R!   t   bboxs'   update parameter '%s' is not supported.t   use_blitN(   s   locs   bbox(   t   legendt   _updatet
   ValueErrorR   t   __init__t   _legend_box(   t   selfR$   R#   t   update(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR'   &   s    	
c         C  s   |  j  j | ƒ S(   N(   R$   t   contains(   R)   R$   t   evt(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   artist_picker7   s    c         C  sa   |  j  ƒ  } |  j d k r+ |  j | ƒ n2 |  j d k rJ |  j | ƒ n t d |  j ƒ ‚ d  S(   NR!   R"   s'   update parameter '%s' is not supported.(   t   get_loc_in_canvasR%   t   _update_loct   _update_bbox_to_anchort   RuntimeErrorR*   (   R)   t   loc_in_canvas(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   finalize_offset:   s    c         C  sz   |  j  j ƒ  } | j d k s- | j d k rO |  j  j d  ƒ |  j  j ƒ  } n  t | ƒ } t | j | ƒ ƒ |  j  _	 d  S(   Ni    (
   R$   t   get_bbox_to_anchort   widtht   heightt   set_bbox_to_anchort   NoneR   t   tuplet   transform_pointt   _loc(   R)   R2   R"   t   _bbox_transform(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR/   E   s    c         C  s2   |  j  j j } | j | ƒ } |  j  j | ƒ d  S(   N(   R$   t   axest	   transAxesR:   R7   (   R)   R2   t   trt   loc_in_bbox(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR0   R   s    (   t   __name__t
   __module__t   FalseR'   R-   R3   R/   R0   (    (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR    %   s
   			t   Legendc           B  s«  e  Z d  Z i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6Z d Z d „  Z d: d: d: d: d: d: d: d: d: d: d: d: d: d: d d: d: d: d: d: d: d: d: d: d „ Z d „  Z d „  Z	 d „  Z
 e e
 e	 ƒ Z d „  Z d „  Z e d „  ƒ Z d: d „ Z i
 e j ƒ  e 6e j ƒ  e 6e j ƒ  e 6e j ƒ  e 6e j ƒ  e 6e j ƒ  e 6e j ƒ  e  6e j d  e j! ƒ e" 6e j# ƒ  e$ 6e j% ƒ  e& 6Z' e( d! „  ƒ Z) e( d" „  ƒ Z* e( d# „  ƒ Z+ d$ „  Z, e- d% „  ƒ Z. d& „  Z/ d' „  Z0 d( „  Z1 d) „  Z2 d* „  Z3 d+ „  Z4 d, „  Z5 d- „  Z6 d: d. „ Z7 d/ „  Z8 d0 „  Z9 d1 „  Z: d2 „  Z; d3 „  Z< d: d4 „ Z= d5 „  Z> d: d6 „ Z? d7 „  Z@ d: eA d8 d9 „ ZB RS(;   s`  
    Place a legend on the axes at location loc.  Labels are a
    sequence of strings and loc can be a string or an integer
    specifying the legend location

    The location codes are::

      'best'         : 0, (only implemented for axis legends)
      'upper right'  : 1,
      'upper left'   : 2,
      'lower left'   : 3,
      'lower right'  : 4,
      'right'        : 5,
      'center left'  : 6,
      'center right' : 7,
      'lower center' : 8,
      'upper center' : 9,
      'center'       : 10,

    loc can be a tuple of the normalized coordinate values with
    respect its parent.

    i    t   besti   s   upper righti   s
   upper lefti   s
   lower lefti   s   lower righti   t   righti   s   center lefti   s   center righti   s   lower centeri	   s   upper centeri
   t   centerc         C  s   d S(   NRD   (    (   R)   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   __str__�   s    c   &      C  su  d d l  m } d d l m } t j |  ƒ |	 d4 k rs |
 d4 k	 rZ t d |
 ƒ |  _ qÀ t d t	 d ƒ |  _ nM t
 |	 t ƒ r· t |	 �  |  _ d |	 k rÀ |  j j t	 d ƒ qÀ n	 |	 |  _ |  j j ƒ  |  _ d d d d	 d
 d g } g  |  _ g  |  _ d4 |  _ | |  _ t ƒ  } xI | D]A }  | |  d4 k rEt	 d |  }! n
 | |  }! t |  |  |! ƒ qW| j }" t |" j |" j ƒ |  j }# x\ d d d d d g D]E }$ | |$ d4 k rÏt |  |$ t	 d |$ ƒ qžt |  |$ | |$ ƒ qžW~ t | ƒ } t | ƒ d k  rd } n  | |  _ |  j d k r<t d | ƒ ‚ n  | d4 k rft j d5 d6 d7 g ƒ |  _  n t j! | ƒ |  _  t" |  j# t |  j  ƒ ƒ d }% t j$ |  j  |% ƒ |  j#  |  _  d4 |  _% t
 | | ƒ røt& |  _' |  j( | ƒ |  j) | j* ƒ n4 t
 | | ƒ r t+ |  _' |  j) | ƒ n t, d ƒ ‚ | |  _- | d4 k rmt	 d } |  j' rm| d8 k rmd } qmn  t. | ƒ r| |  j/ k rõ|  j' rÃt0 j1 d | d j2 |  j/ j3 ƒ  ƒ f ƒ d } qt0 j1 d  | d j2 |  j/ j3 ƒ  ƒ f ƒ d } q|  j/ | } n  |  j' r1| d k r1t0 j1 d! ƒ d } n  | |  _4 |  j5 | | ƒ t6 d" d9 d$ d% d& d% d' t	 d( d) t	 d* d+ |  j d, t& ƒ |  _7 | d4 k r¤t	 d- } n  | rÉ|  j7 j8 d. d/ d d0 d1 ƒn |  j7 j8 d2 d/ d ƒ|  j9 |  j7 ƒ | |  _: | d4 k rt	 d3 |  _: n  |  j; | | ƒ | d4 k	 rF|  j< ƒ  j= | ƒ n  | |  _> |  j? | ƒ |  j |  _@ d4 |  _A d4 S(:   sÒ
  
        - *parent*: the artist that contains the legend
        - *handles*: a list of artists (lines, patches) to be added to the
                      legend
        - *labels*: a list of strings to label the legend

        Optional keyword arguments:

        ================   ====================================================
        Keyword            Description
        ================   ====================================================
        loc                a location code
        prop               the font property
        fontsize           the font size (used only if prop is not specified)
        markerscale        the relative size of legend markers vs. original
        numpoints          the number of points in the legend for line
        scatterpoints      the number of points in the legend for scatter plot
        scatteryoffsets    a list of yoffsets for scatter symbols in legend
        frameon            if True, draw a frame around the legend.
                           If None, use rc
        fancybox           if True, draw a frame with a round fancybox.
                           If None, use rc
        shadow             if True, draw a shadow behind legend
        framealpha         If not None, alpha channel for the frame.
        ncol               number of columns
        borderpad          the fractional whitespace inside the legend border
        labelspacing       the vertical space between the legend entries
        handlelength       the length of the legend handles
        handleheight       the length of the legend handles
        handletextpad      the pad between the legend handle and text
        borderaxespad      the pad between the axes and legend border
        columnspacing      the spacing between columns
        title              the legend title
        bbox_to_anchor     the bbox that the legend will be anchored.
        bbox_transform     the transform for the bbox. transAxes if None.
        ================   ====================================================


        The pad and spacing parameters are measured in font-size units.  e.g.,
        a fontsize of 10 points and a handlelength=5 implies a handlelength of
        50 points.  Values from rcParams will be used if None.

        Users can specify any arbitrary location for the legend using the
        *bbox_to_anchor* keyword argument. bbox_to_anchor can be an instance
        of BboxBase(or its derivatives) or a tuple of 2 or 4 floats.
        See :meth:`set_bbox_to_anchor` for more detail.

        The legend location can be specified by setting *loc* with a tuple of
        2 floats, which is interpreted as the lower-left corner of the legend
        in the normalized axes coordinate.
        iÿÿÿÿ(   t   Axes(   t   Figuret   sizes   legend.fontsizet	   numpointst   markerscalet   shadowt   columnspacingt   scatterpointst   handleheights   legend.t	   borderpadt   labelspacingt   handlelengtht   handletextpadt   borderaxespadi   i   i    s    numpoints must be > 0; it was %dg      @g       @g      @g      @s,   Legend needs either Axes or Figure as parents
   legend.locRE   s   upper rightsL   Unrecognized location "%s". Falling back on "best"; valid locations are
	%s
s   
	sS   Unrecognized location "%s". Falling back on "upper right"; valid locations are
	%s
si   Automatic legend placement (loc="best") not implemented for figure legend. Falling back on "upper right".t   xyg        R5   g      ð?R6   t	   facecolors   axes.facecolort	   edgecolors   axes.edgecolort   mutation_scalet   snaps   legend.fancyboxt   roundt   padt   rounding_sizegš™™™™™É?t   squares   legend.frameonNg      Ø?g      à?g      Ô?(   i    s   best(   g        g        (B   t   matplotlib.axesRI   t   matplotlib.figureRJ   R   R'   R8   R	   t   propR   t
   isinstancet   dictt   set_sizet   get_size_in_pointst	   _fontsizet   textst   legendHandlest   _legend_title_boxt   _handler_mapt   localst   setattrR"   t   minR5   R6   t   listt   lent   _ncolRL   R&   t   npt   arrayt   _scatteryoffsetst   asarrayt   intRP   t   tileR(   t   Truet   isaxest   set_axest
   set_figuret   figureRC   t	   TypeErrort   parentR   t   codest   warningst   warnt   joint   iterkeyst   _modeR7   R   t   legendPatcht   set_boxstylet   _set_artist_propst
   _drawFramet   _init_legend_boxt	   get_framet	   set_alphaR;   t	   set_titlet   _last_fontsize_pointst
   _draggable(&   R)   R~   t   handlest   labelsR!   RL   RM   RP   t   scatteryoffsetsRb   t   fontsizeRR   RS   RT   RQ   RU   RV   RO   t   ncolt   modet   fancyboxRN   t   titlet
   framealphat   bbox_to_anchort   bbox_transformt   frameont   handler_mapRI   RJ   t	   propnamest	   localdictt   namet   valueR"   t   axessize_fontsizet   vt   reps(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR'   „   sÂ    Z						
			 				
		 		 			

	
		c         C  sC   | j  |  j ƒ |  j r, | j |  j ƒ n  | j |  j ƒ  ƒ d S(   sE   
        set the boilerplate props for artists added to axes
        N(   R{   R|   Ry   Rz   R=   t   set_transformt   get_transform(   R)   t   a(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR‡   {  s    	c         C  sG   | |  _  | d k r! |  j } n	 |  j } |  j j | ƒ | |  _  d  S(   Ni    (   t	   _loc_realt   _findoffset_bestt   _findoffset_locR(   t
   set_offset(   R)   R!   t   _findoffset(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   _set_loc„  s    		c         C  s   |  j  S(   N(   R¦   (   R)   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   _get_loc•  s    c         C  s-   |  j  | | | ƒ \ } } | | | | f S(   s9   Helper function to locate the legend at its best position(   t   _find_best_position(   R)   R5   R6   t   xdescentt   ydescentt   renderert   oxt   oy(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR§   š  s    c         C  s¼   t  |  j ƒ rk t |  j ƒ d k rk |  j \ } } |  j ƒ  } | j | j | | j | j | }	 }
 n? t j	 d d | | ƒ } |  j
 |  j | |  j ƒ  | ƒ \ }	 }
 |	 | |
 | f S(   s<   Helper function to locate the legend using the location codei   i    (   R   R;   Rp   R4   t   x0R5   t   y0R6   R   t   from_boundst   _get_anchored_bbox(   R)   R5   R6   R®   R¯   R°   t   fxt   fyR"   t   xt   y(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR¨   Ÿ  s    $,	c         C  s(  |  j  ƒ  s d S| j d ƒ | j |  j ƒ } |  j d k rv d |  j |  j | } |  j j |  j	 ƒ  j
 | ƒ n  |  j j | ƒ } |  j j | j | j | j
 | j ƒ |  j j | ƒ |  j r|  j rô t |  j d d ƒ } | j | ƒ n  |  j j | ƒ n  |  j j | ƒ | j d ƒ d S(   s*   Draw everything that belongs to the legendNR$   t   expandi   iþÿÿÿ(   s   expand(   t   get_visiblet
   open_groupt   points_to_pixelsRg   R„   RV   RR   R(   t	   set_widthR4   R5   t   get_window_extentR…   t
   set_boundsR³   R´   R6   t   set_mutation_scaleRˆ   RN   R   t   drawt   close_group(   R)   R°   R’   R]   R"   RN   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyRÃ   ¯  s$     		c         C  s'   | d k r |  j S| j |  j ƒ Sd S(   sm   
        Return the approximate height of the text. This is used to place
        the legend handle.
        N(   R8   Rg   R¾   (   R)   R°   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   _approx_text_heightÑ  s    t   update_funcc         C  s   |  j  S(   sF   
        A class method that returns the default handler map.
        (   t   _default_handler_map(   t   cls(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   get_default_handler_mapï  s    c         C  s   | |  _  d S(   s@   
        A class method to set the default handler map.
        N(   RÇ   (   RÈ   R›   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   set_default_handler_mapö  s    c         C  s   |  j  j | ƒ d S(   sC   
        A class method to update the default handler map.
        N(   RÇ   R*   (   RÈ   R›   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   update_default_handler_mapý  s    c         C  s=   |  j  ƒ  } |  j r5 | j ƒ  } | j |  j ƒ | S| Sd S(   s)   
        return the handler map.
        N(   RÉ   Rk   t   copyR*   (   R)   t   default_handler_mapt   hm(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   get_legend_handler_map  s    	c         C  sf   |  j  ƒ  } | | k r% |  | } n= x: t | ƒ j ƒ  D]  } | |  k r8 |  | } Pq8 q8 Wd } | S(   s  
        return a legend handler from *legend_handler_map* that
        corresponds to *orig_handler*.

        *legend_handler_map* should be a dictionary object (that is
        returned by the get_legend_handler_map method).

        It first checks if the *orig_handle* itself is a key in the
        *legend_hanler_map* and return the associated value.
        Otherwise, it checks for each of the classes in its
        method-resolution-order. If no matching key is found, it
        returns None.
        N(   t   keyst   typet   mroR8   (   t   legend_handler_mapt   orig_handlet   legend_handler_keyst   handlert   handle_type(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   get_legend_handler  s    
c   !      C  sÒ  |  j  } g  } g  } t d d d d d |  j ƒ } g  } g  } d |  j ƒ  |  j d }	 |  j ƒ  |  j |	 }
 |  j ƒ  } xú t | | ƒ D]é \ } } |  j | | ƒ } | d k rä t	 j
 d t | ƒ f ƒ | j d ƒ q� n  t | d	 | d
 t d t ƒ} | j | j ƒ | j | ƒ t d |  j | d |
 d d d |	 ƒ } | |  | | | ƒ } | j | ƒ | j | ƒ q� Wt | ƒ d k r.t |  j t | ƒ ƒ } t t | ƒ | ƒ \ } } | | } t t d | | d | d ƒ | d g | ƒ } t t | | d t | ƒ | ƒ | g | ƒ } n g  g  } } t | | ƒ } g  } x´ | | D]¨ \ } } g  | | | | !D]: \ } } t d d d |  j | d | | g d d ƒ ^ qy} | d j ƒ  d j t ƒ | j t d d d |  j | d d d | ƒ ƒ q[W|  j d k rd } n d } |  j  | }  t d d d |  d d d | d | ƒ |  _! t d ƒ |  _" t d |  j# | d |  j | d d d |  j" |  j! g ƒ |  _$ |  j$ j% |  j& ƒ | |  _' | |  _( d S(   sæ   
        Initialize the legend_box. The legend_box is an instance of
        the OffsetBox, which is packed with legend handles and
        texts. Once packed, their location is calculated during the
        drawing time.
        t   verticalalignmentt   baselinet   horizontalalignmentt   leftt   fontpropertiesgffffffÖ?gffffffæ?sƒ   Legend does not support %s
Use proxy artist instead.

http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
t	   textpropst   multilinebaselinet   minimumdescentR5   R6   R®   g        R¯   i    i   R]   t   sept   childrent   aligniÿÿÿÿR»   t   fixedR”   t    RG   N()   Rg   Rd   Rb   RÅ   RQ   RÏ   t   zipRØ   R8   R€   R�   t   strt   appendR   Rx   t   _textR   RT   Rp   Rn   Rq   t   divmodR   t   rangeR   RU   t   get_childrent   set_minimumdescentRC   R   RS   R„   RO   t   _legend_handle_boxRj   RR   R(   R{   R|   Rh   Ri   (!   R)   R�   R�   R’   t	   text_listt   handle_listt
   label_propt
   labelboxest   handleboxest   descentR6   RÓ   RÔ   t   labRÖ   t   textboxt	   handleboxt   handleR“   t   nrowst   num_largecolt   num_smallcolt   largecolt   smallcolt   handle_labelt	   columnboxt   i0t   dit   ht   tt	   itemBoxesR”   Rá   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR‰   /  sŽ    	

		
	
	O		c         C  se  |  j  s t ‚ |  j } g  } g  } xZ | j D]O } t | t ƒ sI t ‚ | j ƒ  } | j ƒ  } | j | ƒ } | j	 | ƒ q. Wxˆ | j
 D]} } t | t ƒ s¦ t ‚ t | t ƒ rà | j ƒ  } | j	 | j ƒ  j | ƒ ƒ q‹ | j ƒ  } | j	 | j ƒ  j | ƒ ƒ q‹ Wy) t j g  | D] }	 |	 j ^ qƒ }
 Wn  t k
 rWt j g  ƒ }
 n X|
 | | g S(   s{  
        Returns list of vertices and extents covered by the plot.

        Returns a two long list.

        First element is a list of (x, y) vertices (in
        display-coordinates) covered by all the lines and line
        collections, in the legend's handles.

        Second element is a list of bounding boxes for all the patches in
        the legend's handles.
        (   Ry   t   AssertionErrorR~   t   linesRc   R
   t   get_pathR¤   t   transform_pathRè   t   patchesR   R   t   get_data_transformt   get_bboxt   transformedt   get_extentsRr   t   concatenatet   verticesR&   Rs   (   R)   t   axt   bboxesR  Rø   t   patht   transt   tpatht	   transformt   lR  (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   _auto_legend_data»  s,    	 )c         C  s   |  j  | ƒ d S(   s$   b is a boolean.  Set draw frame to bN(   t   set_frame_on(   R)   t   b(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt
   draw_frameç  s    c         C  s‘   g  } |  j  r" | j |  j  ƒ n  | j |  j ƒ  ƒ | j |  j ƒ  ƒ | j |  j ƒ  ƒ | j |  j ƒ  ƒ |  j r� | j |  j ƒ  ƒ n  | S(   s   return a list of child artists(	   R(   Rè   t   extendt	   get_linest   get_patchest	   get_textsRŠ   Rj   t	   get_title(   R)   Râ   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyRì   ë  s    		c         C  s   |  j  S(   s6   return the Rectangle instance used to frame the legend(   R…   (   R)   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyRŠ   ù  s    c         C  s)   g  |  j  D] } t | t ƒ r
 | ^ q
 S(   s5   return a list of lines.Line2D instances in the legend(   Ri   Rc   R
   (   R)   R  (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR  ý  s    c         C  s2   t  d g  |  j D] } t | t ƒ r | ^ q ƒ S(   s.   return a list of patch instances in the legendR   (   R   Ri   Rc   R   (   R)   R  (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR    s    c         C  s   t  d |  j ƒ S(   s1   return a list of text.Text instance in the legendt   Text(   R   Rh   (   R)   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR    s    c         C  s€   |  j  j j | ƒ | d k	 rS t | t ƒ r= t | �  } n  |  j  j j | ƒ n  | rl |  j  j t	 ƒ n |  j  j t
 ƒ d S(   sk   
        set the legend title. Fontproperties can be optionally set
        with *prop* parameter.
        N(   Rj   Ré   t   set_textR8   Rc   Rd   R	   t   set_fontpropertiest   set_visibleRx   RC   (   R)   R–   Rb   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyRŒ     s    c         C  s
   |  j  j S(   s)   return Text instance for the legend title(   Rj   Ré   (   R)   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR    s    c         O  s   |  j  j | | Ž  S(   s!   return a extent of the the legend(   R…   RÀ   (   R)   t   argst   kwargs(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyRÀ      s    c         C  s   |  j  S(   s;   
        Get whether the legend box patch is drawn
        (   Rˆ   (   R)   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   get_frame_on$  s    c         C  s   | |  _  d S(   sb   
        Set whether the legend box patch is drawn

        ACCEPTS: [ *True* | *False* ]
        N(   Rˆ   (   R)   R  (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR  *  s    c         C  s$   |  j  d k r |  j j S|  j  Sd S(   sB   
        return the bbox that the legend will be anchored
        N(   t   _bbox_to_anchorR8   R~   R"   (   R)   (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR4   2  s    
c         C  sã   | d k r d |  _ d St | t ƒ r4 | |  _ nu y t | ƒ } Wn' t k
 rm t d t | ƒ ƒ ‚ n X| d k r— | d | d d d g } n  t j	 | Œ  |  _ | d k rÊ t
 |  j j ƒ } n  t |  j | ƒ |  _ d S(   s>  
        set the bbox that the legend will be anchored.

        *bbox* can be a BboxBase instance, a tuple of [left, bottom,
        width, height] in the given transform (normalized axes
        coordinate if None), or a tuple of [left, bottom] where the
        width and height will be assumed to be zero.
        Ns   Invalid argument for bbox : %si   i    i   (   R8   R'  Rc   R   Rp   R}   R&   Rç   R   Rµ   R   R~   R"   R   (   R)   R"   R  R  (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR7   ;  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 ƒ } | j |  j | ƒ } | j | d | ƒ} | j | j f S(   s¾  
        Place the *bbox* inside the *parentbbox* according to a given
        location code. Return the (x,y) coordinate of the bbox.

        - loc: a location code in range(1, 11).
          This corresponds to the possible values for self._loc, excluding
          "best".

        - bbox: bbox to be placed, display coodinate units.
        - parentbbox: a parent box which will contain the bbox. In
            display coordinates.
        i   i   t   NEt   NWt   SWt   SEt   Et   Wt   St   Nt   Ct	   container(	   Rë   R  R¾   Rg   t   paddedRV   t   anchoredR³   R´   (   R)   R!   R"   t
   parentbboxR°   t   BESTt   URt   ULt   LLt   LRt   Rt   CLt   CRt   LCt   UCR0  t   anchor_coefst   cR’   R1  t   anchored_box(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR¶   Z  s"    -


c         C  s¦  |  j  s t ‚ |  j ƒ  \ } } } t j d d | | ƒ } | d k rŽ g  t d t |  j ƒ ƒ D]$ }	 |  j	 |	 | |  j
 ƒ  | ƒ ^ qa } n  g  }
 x½ | D]µ \ } } t j | | | | ƒ } d } | j | ƒ } | | j | ƒ 7} x* | D]" } | j | ƒ rî | d 7} qî qî W| | } } | d k r7| | f S|
 j | | | f f ƒ q› W|
 d } x+ |
 D]# } | d | d k  re| } qeqeW| d \ } } | | f S(   sÌ   
        Determine the best location to place the legend.

        `consider` is a list of (x, y) pairs to consider as a potential
        lower-left corner of the legend. All are display coords.
        i    i   N(   Ry   R  R  R   Rµ   R8   Rë   Rp   R   R¶   R4   t   count_containst   count_overlapst   intersects_bboxRè   (   R)   R5   R6   R°   t   considert   vertsR  R  R"   R¹   t
   candidatesR  R  t	   legendBoxt   badnesst   lineR±   R²   t   minCandidatet	   candidate(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR­   }  s2    C

c         C  s   |  j  j | ƒ S(   N(   R…   R+   (   R)   t   event(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyR+   ¹  s    R!   c         C  s‡   |  j  d k	 } | d k r% | } n  | rX |  j  d k r€ t |  | d | ƒ|  _  q€ n( |  j  d k	 rw |  j  j ƒ  n  d |  _  |  j  S(   s<  
        Set the draggable state -- if state is

          * None : toggle the current state

          * True : turn draggable on

          * False : turn draggable off

        If draggable is on, you can drag the legend on the canvas with
        the mouse.  The DraggableLegend helper instance is returned if
        draggable is on.

        The update parameter control which parameter of the legend changes
        when dragged. If update is "loc", the *loc* paramter of the legend
        is changed. If "bbox", the *bbox_to_anchor* parameter is changed.
        R*   N(   RŽ   R8   R    t
   disconnect(   R)   t   stateR#   R*   t   is_draggable(    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt	   draggable¼  s    
	N(C   RA   RB   t   __doc__R   t   zorderRH   R8   R'   R‡   R«   R¬   t   propertyR;   R§   R¨   R   RÃ   RÅ   t   legend_handlert   HandlerStemR   t   HandlerErrorbarR   t   HandlerLine2DR
   t   HandlerPatchR   t   HandlerLineCollectionR   t   HandlerRegularPolyCollectionR   t   HandlerCircleCollectionR   t   update_from_first_childR   t   HandlerTupleR9   t   HandlerPathCollectionR   RÇ   t   classmethodRÉ   RÊ   RË   RÏ   t   staticmethodRØ   R‰   R  R  Rì   RŠ   R  R  R  RŒ   R  RÀ   R&  R  R4   R7   R¶   R­   R+   RC   RQ  (    (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyRD   Z   s¤   

	Ó						"			Œ	,													#<	(2   RR  t
   __future__R    R   R€   t   numpyRr   t
   matplotlibR   t   matplotlib.artistR   R   t   matplotlib.cbookR   R   R   R   t   matplotlib.font_managerR	   t   matplotlib.linesR
   t   matplotlib.patchesR   R   R   R   t   matplotlib.collectionsR   R   R   R   t   matplotlib.transformsR   R   R   R   R   t   matplotlib.offsetboxR   R   R   R   R   t   matplotlib.containerR   R   R   RU  R    RD   (    (    (    sK   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/legend.pyt   <module>   s$   """"5