
 m[c           @` sN  d  Z  d d l m Z m Z m Z m Z d d l Z d d l Z d d l m	 Z	 d d l
 Z d d l m Z d d l m Z m Z m Z d d l m Z d d	 l m Z d
 e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d e f d     YZ! d  e f d!     YZ" d" e" f d#     YZ# d$ e f d%     YZ$ d& e" f d'     YZ% d( e% f d)     YZ& d* e" f d+     YZ' d, e" f d-     YZ( d. e f d/     YZ) d S(0   u  
GUI neutral widgets
===================

Widgets that are designed to work for any of the GUI backends.
All of these widgets require you to predefine a :class:`matplotlib.axes.Axes`
instance and pass that as the first arg.  matplotlib doesn't try to
be too smart with respect to layout -- you will have to figure out how
wide and tall you want your Axes to be to accommodate your widget.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   zip(   t   rcParamsi   (   t   Circlet	   Rectanglet   Ellipse(   t   Line2D(   t   blended_transform_factoryt   LockDrawc           B` sD   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   u  
    Some widgets, like the cursor, draw onto the canvas, and this is not
    desirable under all circumstances, like when the toolbar is in
    zoom-to-rect mode and drawing a rectangle.  The module level "lock"
    allows someone to grab the lock and prevent other widgets from
    drawing.  Use ``matplotlib.widgets.lock(someobj)`` to prevent
    other widgets from drawing while you're interacting with the canvas.
    c         C` s   d  |  _ d  S(   N(   t   Nonet   _owner(   t   self(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   __init__%   s    c         C` s+   |  j  |  s t d   n  | |  _ d S(   u   reserve the lock for *o*u   already lockedN(   t	   availablet
   ValueErrorR   (   R   t   o(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   __call__(   s    c         C` s+   |  j  |  s t d   n  d |  _ d S(   u   release the locku   you do not own this lockN(   R   R   R   R   (   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   release.   s    c         C` s   |  j    p |  j |  S(   u   drawing is available to *o*(   t   lockedt   isowner(   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   4   s    c         C` s   |  j  | k S(   u!   Return True if *o* owns this lock(   R   (   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   8   s    c         C` s   |  j  d k	 S(   u5   Return True if the lock is currently held by an ownerN(   R   R   (   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   <   s    (	   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR      s   					t   Widgetc           B` sS   e  Z d  Z e Z e Z e Z d   Z d   Z e	 e d   d d Z
 d   Z RS(   u5   
    Abstract base class for GUI neutral widgets
    c         C` s   | |  _  d S(   u*   Set whether the widget is active.
        N(   t   _active(   R   t   active(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt
   set_activeI   s    c         C` s   |  j  S(   u*   Get whether the widget is active.
        (   R   (   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt
   get_activeN   s    c         C` s   |  j  |  S(   N(   R   (   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   <lambda>T   s    t   docu   Is the widget active?c         C` s   |  j  S(   u   Return True if event should be ignored.

        This method (or a version of it) should be called at the beginning
        of any event callback.
        (   R   (   R   t   event(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   ignoreW   s    (   R   R   R   t   Truet   drawont   eventsonR   R   R   t   propertyR   R"   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   A   s   			t
   AxesWidgetc           B` s)   e  Z d  Z d   Z d   Z d   Z RS(   u  Widget that is connected to a single
    :class:`~matplotlib.axes.Axes`.

    To guarantee that the widget remains responsive and not garbage-collected,
    a reference to the object should be maintained by the user.

    This is necessary because the callback registry
    maintains only weak-refs to the functions, which are member
    functions of the widget.  If there are no references to the widget
    object it may be garbage collected which will disconnect the
    callbacks.

    Attributes:

    *ax* : :class:`~matplotlib.axes.Axes`
        The parent axes for the widget
    *canvas* : :class:`~matplotlib.backend_bases.FigureCanvasBase` subclass
        The parent figure canvas for the widget.
    *active* : bool
        If False, the widget does not respond to events.
    c         C` s%   | |  _  | j j |  _ g  |  _ d  S(   N(   t   axt   figuret   canvast   cids(   R   R(   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   v   s    	c         C` s)   |  j  j | |  } |  j j |  d S(   u   Connect callback with an event.

        This should be used in lieu of `figure.canvas.mpl_connect` since this
        function stores callback ids for later clean up.
        N(   R*   t   mpl_connectR+   t   append(   R   R!   t   callbackt   cid(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   connect_event{   s    c         C` s(   x! |  j  D] } |  j j |  q
 Wd S(   u-   Disconnect all events created by this widget.N(   R+   R*   t   mpl_disconnect(   R   t   c(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   disconnect_events   s    (   R   R   R   R   R0   R3   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR'   `   s   			t   Buttonc           B` sM   e  Z d  Z d	 d d d  Z d   Z d   Z d   Z d   Z d   Z	 RS(
   u  
    A GUI neutral button.

    For the button to remain responsive you must keep a reference to it.
    Call :meth:`on_clicked` to connect to the button.

    Attributes
    ----------
    ax :
        The :class:`matplotlib.axes.Axes` the button renders into.
    label :
        A :class:`matplotlib.text.Text` instance.
    color :
        The color of the button when not hovering.
    hovercolor :
        The color of the button when hovering.
    u   0.85u   0.95c      
   C` s   t  j |  |  | d
 k	 r, | j |  n  | j d d | d d d d d | j |  _ d |  _ i  |  _ |  j	 d |  j
  |  j	 d |  j  |  j	 d	 |  j  | j t  | j |  | j g   | j g   | |  _ | |  _ | |  _ d
 S(   u}  
        Parameters
        ----------
        ax : matplotlib.axes.Axes
            The :class:`matplotlib.axes.Axes` instance the button
            will be placed into.

        label : str
            The button text. Accepts string.

        image : array, mpl image, Pillow Image
            The image to place in the button, if not *None*.
            Can be any legal arg to imshow (numpy array,
            matplotlib Image instance, or Pillow Image).

        color : color
            The color of the button when not activated

        hovercolor : color
            The color of the button when the mouse is over it
        g      ?t   verticalalignmentu   centert   horizontalalignmentt	   transformi    u   button_press_eventu   button_release_eventu   motion_notify_eventN(   R'   R   R   t   imshowt   textt	   transAxest   labelt   cntt	   observersR0   t   _clickt   _releaset   _motiont   set_navigatet   Falset   set_facecolort
   set_xtickst
   set_ytickst   colort
   hovercolort
   _lastcolor(   R   R(   R;   t   imageRF   RG   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR      s&    				c         C` se   |  j  |  r d  S| j |  j k r) d  S|  j s6 d  S| j j |  j k ra | j j |  j  n  d  S(   N(   R"   t   inaxesR(   R%   R*   t   mouse_grabbert
   grab_mouse(   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR>      s    	c         C` s   |  j  |  r d  S| j j |  j k r, d  S| j j |  j  |  j sL d  S| j |  j k rb d  Sx* t j |  j	  D] \ } } | |  qu Wd  S(   N(
   R"   R*   RK   R(   t   release_mouseR%   RJ   t   sixt	   iteritemsR=   (   R   R!   R/   t   func(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR?      s    	c         C` s   |  j  |  r d  S| j |  j k r1 |  j } n	 |  j } | |  j k r |  j j |  | |  _ |  j r |  j j j	 j
   q n  d  S(   N(   R"   RJ   R(   RG   RF   RH   RC   R$   R)   R*   t   draw(   R   R!   R2   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR@      s    			c         C` s)   |  j  } | |  j | <|  j  d 7_  | S(   u   
        When the button is clicked, call this *func* with event.

        A connection id is returned. It can be used to disconnect
        the button from its callback.
        i   (   R<   R=   (   R   RP   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt
   on_clicked   s    	c         C` s&   y |  j  | =Wn t k
 r! n Xd S(   u,   remove the observer with connection id *cid*N(   R=   t   KeyError(   R   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt
   disconnect   s    N(
   R   R   R   R   R   R>   R?   R@   RR   RT   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR4      s   .	
			t   Sliderc        	   B` se   e  Z d  Z d d e e d
 d
 e d
 d  Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(   uB  
    A slider representing a floating point range.

    Create a slider from *valmin* to *valmax* in axes *ax*. For the slider to
    remain responsive you must maintain a reference to it. Call
    :meth:`on_changed` to connect to the slider event.

    Attributes
    ----------
    val : float
        Slider value.
    g      ?u   %1.2fc      
   K` sJ  t  j |  |  |	 d k	 rJ t |	 d  rJ t d j t |	     n  |
 d k	 r t |
 d  r t d j t |
     n  | |  _ | |  _ |	 |  _	 |
 |  _
 t |  _ | |  _ | |  _ | |  _ |  j |  } | d k r | } n  | |  _ | |  _ | j | | d d |  |  _ | j | d d d d d d |  _ | |  _ | j g   | j | | f  | j g   | j t  |  j d	 |  j  |  j d
 |  j  | r|  j d |  j  n  | j d d | d | j d d d d |  _  | j d d | | d | j d d d d |  _! d |  _" i  |  _# |  j$ |  d S(   ul  
        Parameters
        ----------
        ax : Axes
            The Axes to put the slider in.

        label : str
            Slider label.

        valmin : float
            The minimum value of the slider.

        valmax : float
            The maximum value of the slider.

        valinit : float, optional, default: 0.5
            The slider initial position.

        valfmt : str, optional, default: "%1.2f"
            Used to format the slider value, fprint format string.

        closedmin : bool, optional, default: True
            Indicate whether the slider interval is closed on the bottom.

        closedmax : bool, optional, default: True
            Indicate whether the slider interval is closed on the top.

        slidermin : Slider, optional, default: None
            Do not allow the current slider to have a value less than
            the value of the Slider `slidermin`.

        slidermax : Slider, optional, default: None
            Do not allow the current slider to have a value greater than
            the value of the Slider `slidermax`.

        dragging : bool, optional, default: True
            If True the slider can be dragged by the mouse.

        valstep : float, optional, default: None
            If given, the slider will snap to multiples of `valstep`.

        Notes
        -----
        Additional kwargs are passed on to ``self.poly`` which is the
        :class:`~matplotlib.patches.Rectangle` that draws the slider
        knob.  See the :class:`~matplotlib.patches.Rectangle` documentation for
        valid property names (e.g., `facecolor`, `edgecolor`, `alpha`).
        u   valu$   Argument slidermin ({}) has no 'val'u$   Argument slidermax ({}) has no 'val'i    i   RF   u   rt   lwu   button_press_eventu   button_release_eventu   motion_notify_eventg{Gzg      ?R7   R5   u   centerR6   u   rightgRQ?u   leftN(%   R'   R   R   t   hasattrR   t   formatt   typet	   closedmint	   closedmaxt	   slidermint	   slidermaxRB   t   drag_activet   valmint   valmaxt   valstept   _value_in_boundst   valt   valinitt   axvspant   polyt   axvlinet   vlinet   valfmtRE   t   set_xlimRD   RA   R0   t   _updateR9   R:   R;   t   valtextR<   R=   t   set_val(   R   R(   R;   R_   R`   Rd   Ri   RZ   R[   R\   R]   t   draggingRa   t   kwargs(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     sR    3													$				c         C` s  |  j  r= t j | |  j |  j   |  j  } | |  j 7} n  | |  j k re |  j sY d S|  j } n( | |  j k r |  j s d S|  j } n  |  j d k	 r | |  j j	 k r |  j s d S|  j j	 } n  |  j
 d k	 r| |  j
 j	 k r|  j s d S|  j
 j	 } n  | S(   u*    Makes sure self.val is with given bounds.N(   Ra   t   npt   roundR_   RZ   R`   R[   R\   R   Rc   R]   (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRb   t  s(    	$		!	!	c         C` s  |  j  |  r d S| j d k r& d S| j d k rf | j |  j k rf t |  _ | j j |  j  n  |  j ss d S| j d k s | j d k r | j |  j k r t	 |  _ | j j
 |  j  d S|  j | j  } | d k	 r | |  j k r |  j |  n  d S(   u   update the slider positionNi   u   button_press_eventu   button_release_event(   R"   t   buttont   nameRJ   R(   R#   R^   R*   RL   RB   RM   Rb   t   xdataR   Rc   Rm   (   R   R!   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRk     s$    !			c         C` s   |  j  j } | d f | d <| d f | d <| |  j  _ |  j j |  j |  |  j rn |  j j j j	   n  | |  _
 |  j s d Sx* t j |  j  D] \ } } | |  q Wd S(   uf   
        Set slider value to *val*

        Parameters
        ----------
        val : float
        i   i   i    i   N(   Rf   t   xyRl   t   set_textRi   R$   R(   R)   R*   t	   draw_idleRc   R%   RN   RO   R=   (   R   Rc   Ru   R/   RP   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRm     s    			c         C` s)   |  j  } | |  j | <|  j  d 7_  | S(   u  
        When the slider value is changed call *func* with the new
        slider value

        Parameters
        ----------
        func : callable
            Function to call when slider is changed.
            The function must accept a single float as its arguments.

        Returns
        -------
        cid : int
            Connection id (which can be used to disconnect *func*)
        i   (   R<   R=   (   R   RP   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt
   on_changed  s    	c         C` s&   y |  j  | =Wn t k
 r! n Xd S(   u   
        Remove the observer with connection id *cid*

        Parameters
        ----------
        cid : int
            Connection id of the observer to be removed
        N(   R=   RS   (   R   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRT     s    	c         C` s)   |  j  |  j k r% |  j |  j  n  d S(   u%   Reset the slider to the initial valueN(   Rc   Rd   Rm   (   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   reset  s    N(   R   R   R   R#   R   R   Rb   Rk   Rm   Rx   RT   Ry   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRU     s   	a					t   CheckButtonsc           B` sD   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   u  
    A GUI neutral set of check buttons.

    For the check buttons to remain responsive you must keep a
    reference to this object.

    The following attributes are exposed

     *ax*
        The :class:`matplotlib.axes.Axes` instance the buttons are
        located in

     *labels*
        List of :class:`matplotlib.text.Text` instances

     *lines*
        List of (line1, line2) tuples for the x's in the check boxes.
        These lines exist for each box, but have ``set_visible(False)``
        when its box is not checked.

     *rectangles*
        List of :class:`matplotlib.patches.Rectangle` instances

    Connect to the CheckButtons with the :meth:`on_clicked` method
    c         C` s  t  j |  |  | j g   | j g   | j t  t |  d k r d t |  d } t j d | | t |   } n d } d g } d } | j	   } g  |  _
 g  |  _ g  |  _ i d d 6d d	 6| j d
 6d d 6} x|t | |  D]k\ }	 }
 | j d |	 |
 d | j d d d d } | d | d } } d |	 | d } }	 t d | |	 f d | d | d d d | d | j  } t | | | g |	 | |	 g |  } t | | | g |	 |	 | g |  } | j | |  | j | |  |  j
 j |  |  j j |  |  j j | | f  | j |  | j |  | j |  | d 7} q W|  j d |  j  d |  _ i  |  _ d S(   u  
        Add check buttons to :class:`matplotlib.axes.Axes` instance *ax*

        *labels*
            A len(buttons) list of labels as strings

        *actives*
            A len(buttons) list of booleans indicating whether
             the button is active
        i   g      ?g      ?g      ?i    u   ku   colorg      ?u	   linewidthu	   transformu   buttu   solid_capstyleR7   R6   u   leftR5   u   centerg       @g?Ru   t   widtht   heightt	   edgecoloru   blackt	   facecoloru   button_press_eventN(   R'   R   RD   RE   RA   RB   t   lenRp   t   linspacet   get_facecolort   labelst   linest
   rectanglesR:   R   R9   R   R	   t   set_visibleR-   t	   add_patcht   add_lineR0   t   _clickedR<   R=   (   R   R(   R   t   activest   dyt   ysR<   t   axcolort
   lineparamst   yR;   t   tt   wt   ht   xt   pt   l1t   l2(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     sL    "					$&&	c         C` s   |  j  |  r d  S| j d k r& d  S| j |  j k r< d  Sx t t |  j |  j   D]_ \ } \ } } | j   j	 | j
 | j  s | j   j	 | j
 | j  rX |  j |  PqX qX Wd  Sd  S(   Ni   (   R"   Rr   RJ   R(   t	   enumerateR   R   R   t   get_window_extentt   containsR   R   R   (   R   R!   t   iR   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   =  s    .c         C` s   d | k o  t  |  j  k n r8 t d |   n  |  j | \ } } | j | j    | j | j    |  j r |  j j j	 j
   n  |  j s d Sx7 t j |  j  D]# \ } } | |  j | j    q Wd S(   u%  
        Directly (de)activate a check button by index.

        *index* is an index into the original label list
            that this object was constructed with.
            Raises ValueError if *index* is invalid.

        Callbacks will be triggered if :attr:`eventson` is True.

        i    u   Invalid CheckButton index: %dN(   R   R   R   R   R   t   get_visibleR$   R(   R)   R*   RQ   R%   RN   RO   R=   t   get_text(   R   t   indexR   R   R/   RP   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   M  s    %		c         C` s&   g  |  j  D] \ } } | j   ^ q
 S(   uX   
        returns a tuple of the status (True/False) of all of the check buttons
        (   R   R   (   R   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt
   get_statusg  s    c         C` s)   |  j  } | |  j | <|  j  d 7_  | S(   u   
        When the button is clicked, call *func* with button label

        A connection id is returned which can be used to disconnect
        i   (   R<   R=   (   R   RP   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRR   m  s    	c         C` s&   y |  j  | =Wn t k
 r! n Xd S(   u,   remove the observer with connection id *cid*N(   R=   RS   (   R   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRT   x  s    (	   R   R   R   R   R   R   R   RR   RT   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRz     s   	>				t   TextBoxc           B` s   e  Z d  Z d d d 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(   uo  
    A GUI neutral text input box.

    For the text box to remain responsive you must keep a reference to it.

    The following attributes are accessible:

      *ax*
        The :class:`matplotlib.axes.Axes` the button renders into.

      *label*
        A :class:`matplotlib.text.Text` instance.

      *color*
        The color of the text box when not hovering.

      *hovercolor*
        The color of the text box when hovering.

    Call :meth:`on_text_change` to be updated whenever the text changes.

    Call :meth:`on_submit` to be updated whenever the user hits enter or
    leaves the text entry field.
    u    u   .95u   1g{Gz?c      
   C` s  t  j |  |  d |  _ g  t D] } d | k r  | ^ q  |  _ | |  _ | j | d | d d d d d | j |  _ |  j |  j  |  _	 d	 |  _
 i  |  _ i  |  _ |  j j d	 d
  |  j j d	 d
  d	 |  _ |  j j d	 d	 d	  |  _ |  j j t  |  j d |  j  |  j d |  j  |  j d |  j  |  j d |  j  |  j d |  j  | j t  | j |  | j g   | j g   | |  _ | |  _  | |  _! t |  _" d S(   u6  
        Parameters
        ----------
        ax : matplotlib.axes.Axes
            The :class:`matplotlib.axes.Axes` instance the button
            will be placed into.

        label : str
            Label for this text box. Accepts string.

        initial : str
            Initial value in the text box

        color : color
            The color of the box

        hovercolor : color
            The color of the box when the mouse is over it

        label_pad : float
            the distance between the label and the right side of the textbox
        g?u   keymapg      ?R5   u   centerR6   u   rightR7   i    i   u   button_press_eventu   button_release_eventu   motion_notify_eventu   key_press_eventu   resize_eventN(#   R'   R   t   DIST_FROM_LEFTR   t   params_to_disableR9   R:   R;   t   _make_text_dispt	   text_dispR<   t   change_observerst   submit_observersR(   Rj   t   set_ylimt   cursor_indext   vlinest   cursorR   RB   R0   R>   R?   R@   t	   _keypresst   _resizeRA   RC   RD   RE   RF   RG   RH   t   capturekeystrokes(   R   R(   R;   t   initialRF   RG   t	   label_padt   key(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s<    	(								c      
   C` s1   |  j  j |  j d | d d d d d |  j  j S(   Ng      ?R5   u   centerR6   u   leftR7   (   R(   R9   R   R:   (   R   t   string(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    c         C` s  |  j  |  j  } t } | d k s: | d k s: | d k rO | d k } d } n  |  j |  } |  j j j j   | j   } |  j j	 j
   } | j |  } | j t  | r | d | d <n  |  j j t  |  j j | d	 | d
 | d  |  _ |  j j j j   d  S(   Nu    u    u     u   ,i    i   (   i    i    (   i   i    (   i   i    (   i    i   (   i   i   (   R9   R   RB   R   R(   R)   R*   RQ   R   t	   transDatat   invertedR7   R   R   R   (   R   t	   widthtextt   no_textt   wt_dispt   bbt   inv(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   _rendercursor  s     $	'c         C` s4   x- t  j |  j  D] \ } } | |  j  q Wd  S(   N(   RN   RO   R   R9   (   R   R/   RP   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   _notify_submit_observers   s    c         C` sC   |  j  |  r d  S| j j |  j k r, d  S| j j |  j  d  S(   N(   R"   R*   RK   R(   RM   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR?     s
    c         C` s
  |  j  |  r d  S|  j r| j } t |  d k rn |  j |  j  | |  j |  j |  _ |  j d 7_ nF| d k r |  j t |  j  k r|  j d 7_ qn| d k r |  j d k r|  j d 8_ qn | d k r d |  _ n | d k rt |  j  |  _ n | d k re|  j d k r|  j |  j d  |  j |  j |  _ |  j d 8_ qnO | d k r|  j t |  j  k r|  j |  j  |  j |  j d |  _ qn  |  j j   |  j |  j  |  _ |  j	   |  j
   | d	 k r|  j   qn  d  S(
   Ni   u   rightu   lefti    u   homeu   endu	   backspaceu   deleteu   enter(   R"   R   R   R   R9   R   R   t   removeR   R   t   _notify_change_observersR   (   R   R!   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     sB    		

c         C` sl   t  |  } |  j | k r d  S| |  _ |  j j   |  j |  j  |  _ |  j   |  j   |  j   d  S(   N(   t   strR9   R   R   R   R   R   R   (   R   Rc   t   newval(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRm   0  s    	

c         C` s4   x- t  j |  j  D] \ } } | |  j  q Wd  S(   N(   RN   RO   R   R9   (   R   R/   RP   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   ;  s    c         C` sE   t  |  _ i  |  _ x, |  j D]! } t | |  j | <g  t | <q Wd  S(   N(   R#   R   t   reset_paramsR   R   (   R   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   begin_typing?  s
    		c         C` s   t  } |  j r= x" |  j D] } |  j | t | <q Wt } n  t  |  _ |  j j t   |  j j	 j
 j   | r| |  j   n  d  S(   N(   RB   R   R   R   R   R#   R   R   R(   R)   R*   RQ   R   (   R   t   notifysubmitR   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   stop_typingH  s    			c         C` s   t  |  j  d k r! d |  _ n |  j j   } |  j j } |  j j j   } | j | j |   } | d } | d } | | | | } | d k  r d } n  | d k r d } n  t	 t  |  j  |  |  _ |  j
   d  S(   Ni    i   (   i    i    (   i   i    (   R   R9   R   R   R   R(   R   R   R7   t   intR   (   R   R   R   t   transR   t
   text_startt   text_endt   ratio(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   position_cursorY  s    

		c         C` s   |  j  |  r d  S| j |  j k r3 |  j   d  S|  j s@ d  S| j j |  j k rk | j j |  j  n  |  j s |  j	 | j
  n  |  j | j
  d  S(   N(   R"   RJ   R(   R   R%   R*   RK   RL   R   R   R   R   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR>   s  s    
		c         C` s   |  j    d  S(   N(   R   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    c         C` s   |  j  |  r d  S| j |  j k r1 |  j } n	 |  j } | |  j k r |  j j |  | |  _ |  j r |  j j j	 j
   q n  d  S(   N(   R"   RJ   R(   RG   RF   RH   RC   R$   R)   R*   RQ   (   R   R!   R2   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR@     s    			c         C` s)   |  j  } | |  j | <|  j  d 7_  | S(   u   
        When the text changes, call this *func* with event.

        A connection id is returned which can be used to disconnect.
        i   (   R<   R   (   R   RP   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   on_text_change  s    	c         C` s)   |  j  } | |  j | <|  j  d 7_  | S(   u   
        When the user hits enter or leaves the submision box, call this
        *func* with event.

        A connection id is returned which can be used to disconnect.
        i   (   R<   R   (   R   RP   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt	   on_submit  s    	c         C` s@   x9 |  j  |  j f D]% } y | | =Wq t k
 r7 q Xq Wd S(   u,   remove the observer with connection id *cid*N(   R   R   RS   (   R   R/   t   reg(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRT     s
    (   R   R   R   R   R   R   R   R?   R   Rm   R   R   R   R   R>   R   R@   R   R   RT   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s&   D					%											t   RadioButtonsc           B` sA   e  Z d  Z d d d  Z d   Z d   Z d   Z d   Z RS(   ua  
    A GUI neutral radio button.

    For the buttons to remain responsive
    you must keep a reference to this object.

    The following attributes are exposed:

     *ax*
        The :class:`matplotlib.axes.Axes` instance the buttons are in

     *activecolor*
        The color of the button when clicked

     *labels*
        A list of :class:`matplotlib.text.Text` instances

     *circles*
        A list of :class:`matplotlib.patches.Circle` instances

     *value_selected*
        A string listing the current value selected

    Connect to the RadioButtons with the :meth:`on_clicked` method
    i    u   bluec         C` s  t  j |  |  | |  _ d |  _ | j g   | j g   | j t  d t	 |  d } t
 j d | | t	 |   } d } | j   } g  |  _ g  |  _ x t | |  D] \ }	 }
 | j d |	 |
 d | j d d d d	 } | | k r|
 |  _ | } n | } t d
 d |	 f d d d d d | d | j  } |  j j |  |  j j |  | j |  | d 7} q W|  j d |  j  d |  _ i  |  _ d S(   u3  
        Add radio buttons to :class:`matplotlib.axes.Axes` instance *ax*

        *labels*
            A len(buttons) list of labels as strings

        *active*
            The index into labels for the button that is active

        *activecolor*
            The color of the button when clicked
        g      ?i   i    g      ?R7   R6   u   leftR5   u   centerRu   g333333?t   radiusg?R}   u   blackR~   u   button_press_eventN(   R'   R   t   activecolorR   t   value_selectedRD   RE   RA   RB   R   Rp   R   R   R   t   circlesR   R9   R:   R   R-   R   R0   R   R<   R=   (   R   R(   R   R   R   R   R   R<   R   R   R;   R   R~   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s:    								c         ` s  |  j  |  r d  S| j d k r& d  S| j |  j k r< d  S|  j j j   j | j | j f  } t	 j
 | d | d g      f d   } xn t t |  j |  j   D]M \ } \ } } | j   j | j | j  s | |  r |  j |  Pq q Wd  Sd  S(   Ni   i    c         ` sO   t  j |  j d |  j d g  }   | } t  j t  j | |   |  j k  S(   Ni    i   (   Rp   t   arrayt   centert   sqrtt   dotR   (   R   t   pcirct   d(   t   pclicked(    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   inside  s    #
(   R"   Rr   RJ   R(   R:   R   t   transform_pointR   R   Rp   R   R   R   R   R   R   R   R   (   R   R!   Ru   R   R   R   R   (    (   R   s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    '.*c         C` s  d | k o  t  |  j  k n r8 t d |   n  |  j | j   |  _ xQ t |  j  D]@ \ } } | | k r |  j } n |  j j	   } | j
 |  q^ W|  j r |  j j j j   n  |  j s d Sx7 t j |  j  D]# \ } } | |  j | j    q Wd S(   u"  
        Trigger which radio button to make active.

        *index* is an index into the original label list
            that this object was constructed with.
            Raise ValueError if the index is invalid.

        Callbacks will be triggered if :attr:`eventson` is True.

        i    u   Invalid RadioButton index: %dN(   R   R   R   R   R   R   R   R   R(   R   RC   R$   R)   R*   RQ   R%   RN   RO   R=   (   R   R   R   R   RF   R/   RP   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    %		c         C` s)   |  j  } | |  j | <|  j  d 7_  | S(   u   
        When the button is clicked, call *func* with button label

        A connection id is returned which can be used to disconnect
        i   (   R<   R=   (   R   RP   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRR   3  s    	c         C` s&   y |  j  | =Wn t k
 r! n Xd S(   u,   remove the observer with connection id *cid*N(   R=   RS   (   R   R/   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRT   >  s    (   R   R   R   R   R   R   RR   RT   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s   3			t   SubplotToolc           B` sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   uU   
    A tool to adjust the subplot params of a :class:`matplotlib.figure.Figure`.
    c         ` s\  |   _   j d d d d  d d d     Y}  j d    _   j j d    j j t  t   j d	 d
 d | j j	 d t   _
   j
 j   j   j d    _   j j t  t   j d d
 d | j j d t   _   j j   j   j d    _   j j t  t   j d d
 d | j j d t   _   j j   j   j d    _   j j t  t   j d d
 d | j j d t   _   j j   j   j d    _   j j t  t   j d d
 d | j j d t   _   j j   j   j d    _   j j t  t   j d d
 d | j j d t   _   j j   j     j   j
 _!   j
   j _"   j   j _!   j   j _"  j# d d d d g  } t$ | d    _%   j
   j   j   j   j   j f      f d   }  j j& } t  j _&   j% j' |  |  j _& d S(    u  
        *targetfig*
            The figure instance to adjust.

        *toolfig*
            The figure instance to embed the subplot tool into. If
            *None*, a default figure will be created. If you are using
            this from the GUI
        t   leftg?t   rightg?t
   toolbarfmtc           B` s   e  Z d    Z d   Z RS(   c         S` s   | |  _  d  S(   N(   t   slider(   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   Z  s    c         S` s*   d |  j  j j   |  j  j f } | | S(   Nu   %s=%s(   R   R;   R   Ri   (   R   R   R   t   fmt(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   ]  s    (   R   R   R   R   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   Y  s   	i  u'   Click on slider to adjust subplot paramu   lefti    i   R[   i  u   bottomi  u   rightRZ   i  u   topi  u   wspacei  u   hspaceg?g?g333333?g333333?u   Resetc         ` s     j  } t   _  g  } x'  D] } | j | j   t | _  q Wx  D] } | j   qI Wx& t  |  D] \ } } | | _  qm W|   _    j  r  j j     j j j   n  d  S(   N(   R$   RB   R-   Ry   R   R*   RQ   t	   targetfig(   R!   t
   thisdrawont   bsR   t   b(   R   t   sliderst   toolfig(    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRP     s    				N(    ((   R   t   subplots_adjustt   add_subplott   axleftt	   set_titleRA   RB   RU   t   subplotparsR   t
   sliderleftRx   t   funcleftt   axbottomt   bottomt   sliderbottomt
   funcbottomt   axrightR   t   sliderrightt	   funcrightt   axtopt   topt	   slidertopt   functopt   axwspacet   wspacet   sliderwspacet
   funcwspacet   axhspacet   hspacet   sliderhspacet
   funchspaceR]   R\   t   add_axesR4   t   buttonresett   validateRR   (   R   R   R   R   t   baxRP   R   (    (   R   R   R   s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   J  sl    				c         C` s3   |  j  j d |  |  j r/ |  j  j j   n  d  S(   NR   (   R   R   R$   R*   RQ   (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    	c         C` s3   |  j  j d |  |  j r/ |  j  j j   n  d  S(   NR   (   R   R   R$   R*   RQ   (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    	c         C` s3   |  j  j d |  |  j r/ |  j  j j   n  d  S(   NR   (   R   R   R$   R*   RQ   (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    	c         C` s3   |  j  j d |  |  j r/ |  j  j j   n  d  S(   NR   (   R   R   R$   R*   RQ   (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    	c         C` s3   |  j  j d |  |  j r/ |  j  j j   n  d  S(   NR   (   R   R   R$   R*   RQ   (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    	c         C` s3   |  j  j d |  |  j r/ |  j  j j   n  d  S(   NR   (   R   R   R$   R*   RQ   (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    	(
   R   R   R   R   R   R   R   R   R   R   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   F  s   	r					t   Cursorc           B` s;   e  Z d  Z e e e d  Z d   Z d   Z d   Z RS(   u  
    A horizontal and vertical line that spans the axes and moves with
    the pointer.  You can turn off the hline or vline respectively with
    the following attributes:

      *horizOn*
        Controls the visibility of the horizontal line

      *vertOn*
        Controls the visibility of the horizontal line

    and the visibility of the cursor itself with the *visible* attribute.

    For the cursor to remain responsive you must keep a reference to
    it.
    c         K` s   t  j |  |  |  j d |  j  |  j d |  j  t |  _ | |  _ | |  _ | o` |  j	 j
 |  _ |  j r| t | d <n  | j | j   d d t | |  _ | j | j   d d t | |  _ d |  _ t |  _ d S(   u   
        Add a cursor to *ax*.  If ``useblit=True``, use the backend-dependent
        blitting features for faster updates.  *lineprops* is a dictionary of
        line properties.
        u   motion_notify_eventu
   draw_eventu   animatedi    t   visibleN(   R'   R   R0   t   onmovet   clearR#   R  t   horizOnt   vertOnR*   t   supports_blitt   useblitt   axhlinet
   get_yboundRB   t   linehRg   t
   get_xboundt   linevR   t
   backgroundt	   needclear(   R   R(   R  R  R	  t	   lineprops(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    				%%	c         C` s^   |  j  |  r d S|  j r: |  j j |  j j  |  _ n  |  j j t	  |  j
 j t	  d S(   u   clear the cursorN(   R"   R	  R*   t   copy_from_bboxR(   t   bboxR  R  R   RB   R  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s    	c         C` s  |  j  |  r d S|  j j j |   s, d S| j |  j k r |  j j t  |  j	 j t  |  j
 r |  j j   t |  _
 n  d St |  _
 |  j s d S|  j j | j | j f  |  j	 j | j | j f  |  j j |  j o |  j  |  j	 j |  j o|  j  |  j   d S(   u*   on mouse motion draw the cursor if visibleN(   R"   R*   t
   widgetlockR   RJ   R(   R  R   RB   R  R  RQ   R#   R  t	   set_xdataRt   t	   set_ydatat   ydataR  R  Rk   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s&    			c         C` s~   |  j  rm |  j d  k	 r. |  j j |  j  n  |  j j |  j  |  j j |  j  |  j j	 |  j j
  n |  j j   t S(   N(   R	  R  R   R*   t   restore_regionR(   t   draw_artistR  R  t   blitR  Rw   RB   (   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRk   '  s    	(	   R   R   R   R#   RB   R   R  R  Rk   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s
   			t   MultiCursorc           B` sM   e  Z d  Z e e e d  Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   u  
    Provide a vertical (default) and/or horizontal line cursor shared between
    multiple axes.

    For the cursor to remain responsive you must keep a reference to
    it.

    Example usage::

        from matplotlib.widgets import MultiCursor
        from pylab import figure, show, np

        t = np.arange(0.0, 2.0, 0.01)
        s1 = np.sin(2*np.pi*t)
        s2 = np.sin(4*np.pi*t)
        fig = figure()
        ax1 = fig.add_subplot(211)
        ax1.plot(t, s1)


        ax2 = fig.add_subplot(212, sharex=ax1)
        ax2.plot(t, s2)

        multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1,
                            horizOn=False, vertOn=True)
        show()

    c         K` s@  | |  _  | |  _ | |  _ | |  _ | d j   \ } } | d j   \ }	 }
 d | | } d |	 |
 } t |  _ | o |  j  j |  _	 d  |  _ t |  _ |  j	 r t | d <n  | r g  | D] } | j | d t | ^ q |  _ n	 g  |  _ | r)g  | D] } | j | d t | ^ q |  _ n	 g  |  _ |  j   d  S(   Nig      ?u   animatedR  (   R*   t   axesR  R  t   get_xlimt   get_ylimR#   R  R  R	  R   R  RB   R  Rg   R   R
  t   hlinest   connect(   R   R*   R  R	  R  R  R  t   xmint   xmaxt   ymint   ymaxt   xmidt   ymidR(   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   S  s.    								.	.	c         C` s:   |  j  j d |  j  |  _ |  j  j d |  j  |  _ d S(   u   connect eventsu   motion_notify_eventu
   draw_eventN(   R*   R,   R  t
   _cidmotionR  t   _ciddraw(   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   v  s    c         C` s*   |  j  j |  j  |  j  j |  j  d S(   u   disconnect eventsN(   R*   R1   R'  R(  (   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRT   |  s    c         C` si   |  j  |  r d S|  j r= |  j j |  j j j  |  _ n  x% |  j |  j D] } | j	 t
  qN Wd S(   u   clear the cursorN(   R"   R	  R*   R  R)   R  R  R   R  R   RB   (   R   R!   t   line(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s    	!c         C` s   |  j  |  r d  S| j d  k r& d  S|  j j j |   s? d  St |  _ |  j sU d  S|  j	 r x= |  j
 D]/ } | j | j | j f  | j |  j  qh Wn  |  j r x= |  j D]/ } | j | j | j f  | j |  j  q Wn  |  j   d  S(   N(   R"   RJ   R   R*   R  R   R#   R  R  R  R   R  Rt   R   R  R  R  R  Rk   (   R   R!   R)  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s$    				c         C` s   |  j  r |  j d  k	 r. |  j j |  j  n  |  j rm x3 t |  j |  j  D] \ } } | j	 |  qM Wn  |  j
 r x3 t |  j |  j  D] \ } } | j	 |  q Wn  |  j j |  j j j  n |  j j   d  S(   N(   R	  R  R   R*   R  R  R   R  R   R  R  R  R  R)   R  Rw   (   R   R(   R)  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRk     s    		"	"(   R   R   R   R#   RB   R   R   RT   R  R  Rk   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  6  s   #			
	t   _SelectorWidgetc           B` s   e  Z e d 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 d   Z d   Z d   Z d   Z RS(   c      	   C` s   t  j |  |  t |  _ | |  _ | o1 |  j j |  _ |  j   t	 d d d d d d d d  |  _
 |  j
 j | pw i   d  |  _ g  |  _ t | t  r | g |  _ n	 | |  _ d  |  _ d  |  _ d  |  _ t   |  _ d  S(	   Nt   moveu    R  u   escapet   squareu   shiftR   u   control(   R'   R   R#   R  t   onselectR*   R  R	  t   connect_default_eventst   dictt   state_modifier_keyst   updateR   R  t   artistst
   isinstanceR   t   validButtonst
   eventpresst   eventreleaset   _prev_eventt   sett   state(   R   R(   R-  R	  Rr   R0  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s"    		
						c         C` s*   t  j |  |  | r& |  j d   n  d  S(   N(   R'   R   t   update_backgroundR   (   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    c         C` s+   |  j  r' |  j j |  j j  |  _ n  d S(   u!   force an update of the backgroundN(   R	  R*   R  R(   R  R  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR:    s    	c         C` s   |  j  d |  j  |  j  d |  j  |  j  d |  j  |  j  d |  j  |  j  d |  j  |  j  d |  j  |  j  d |  j  d S(	   u+   Connect the major canvas events to methods.u   motion_notify_eventu   button_press_eventu   button_release_eventu
   draw_eventu   key_press_eventu   key_release_eventu   scroll_eventN(   R0   R  t   pressR   R:  t   on_key_presst   on_key_releaset	   on_scroll(   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR.    s    c         C` s   |  j  s |  j j   r t S|  j j j |   s7 t St | d  sR d | _	 n  |  j
 d k	 rz | j	 |  j
 k rz t Sn  |  j d k r | j |  j k S| j	 |  j j	 k r t S| j |  j k p | j	 |  j j	 k S(   u*   return *True* if *event* should be ignoredu   buttonN(   R   R(   R   R#   R*   R  R   RW   R   Rr   R4  R5  RJ   RB   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR"     s    c         C` s   |  j  j   s t S|  j r~ |  j d k	 rA |  j j |  j  n  x! |  j D] } |  j  j	 |  qK W|  j j
 |  j  j  n |  j j   t S(   uT   draw using newfangled blit or oldfangled draw depending on
        useblit

        N(   R(   R   RB   R	  R  R   R*   R  R2  R  R  R  Rw   (   R   t   artist(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR1    s    	c         C` s   | j  d k r d S|  j j   \ } } |  j j   \ } } t | | j   } t | |  } t | | j  } t | |  } | | f S(   u.   Get the xdata and ydata for event, with limitsN(   NN(   Rt   R   R(   R  R  t   maxt   minR  (   R   R!   t   x0t   x1t   y0t   y1Rt   R  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt	   _get_data  s    c         C` sR   | j  d k r |  j } n t j |  } |  j |  \ | _  | _ | |  _ | S(   u   Clean up an event

        Use prev event if there is no xdata
        Limit the xdata and ydata to the axes limits
        Set the prev event
        N(   Rt   R   R7  t   copyRF  R  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   _clean_event#  s    	c         C` s   |  j  |  s |  j |  } | |  _ | |  _ | j p< d } | j d d  } | |  j d k rw |  j j d  n  |  j	 |  t
 St S(   u"   Button press handler and validatoru    u   ctrlu   controlu   move(   R"   RH  R5  R7  R   t   replaceR0  R9  t   addt   _pressR#   RB   (   R   R!   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR;  3  s    		c         C` s   d S(   u   Button press handlerN(    (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRK  B  s    c         C` sh   |  j  |  rd |  j rd |  j |  } | |  _ |  j |  d |  _ d |  _ |  j j d  t St	 S(   u*   Button release event handler and validatoru   moveN(
   R"   R5  RH  R6  R?   R   R9  t   discardR#   RB   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   F  s    			c         C` s   d S(   u   Button release event handlerN(    (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR?   R  s    c         C` s=   |  j  |  r9 |  j r9 |  j |  } |  j |  t St S(   u'   Cursor move event handler and validator(   R"   R5  RH  t   _onmoveR#   RB   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  V  s
    c         C` s   d S(   u   Cursor move event handlerN(    (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRM  ^  s    c         C` s#   |  j  |  s |  j |  n  d S(   u(   Mouse scroll event handler and validatorN(   R"   t
   _on_scroll(   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR>  b  s    c         C` s   d S(   u   Mouse scroll event handlerN(    (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRN  g  s    c         C` s   |  j  r | j p d } | j d d  } | |  j d k rl x |  j D] } | j t  qG W|  j   d Sx< |  j j   D]+ \ } } | | k r| |  j	 j
 |  q| q| W|  j |  n  d S(   u?   Key press event handler and validator for all selection widgetsu    u   ctrlu   controlu   clearN(   R   R   RI  R0  R2  R   RB   R1  t   itemsR9  RJ  t   _on_key_press(   R   R!   R   R?  R9  t   modifier(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR<  k  s    	
c         C` s   d S(   uM   Key press event handler - use for widget-specific key press actions.
        N(    (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRP  z  s    c         C` sk   |  j  rg | j p d } x< |  j j   D]+ \ } } | | k r( |  j j |  q( q( W|  j |  n  d S(   u'   Key release event handler and validatoru    N(   R   R   R0  RO  R9  RL  t   _on_key_release(   R   R!   R   R9  RQ  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR=    s    	c         C` s   d S(   u   Key release event handlerN(    (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRR    s    c         C` s.   | |  _  x |  j D] } | j |  q Wd S(   u#    Set the visibility of our artists N(   R  R2  R   (   R   R  R?  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    	N(   R   R   RB   R   R   R   R:  R.  R"   R1  RF  RH  R;  RK  R   R?   R  RM  R>  RN  R<  RP  R=  RR  R   (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR*    s,   			
	!																t   SpanSelectorc           B` sV   e  Z d  Z d e d d e d d  Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   u(  
    Visually select a min/max range on a single axis and call a function with
    those values.

    To guarantee that the selector remains responsive, keep a reference to it.

    In order to turn off the SpanSelector, set `span_selector.active=False`. To
    turn it back on, set `span_selector.active=True`.

    Parameters
    ----------
    ax :  :class:`matplotlib.axes.Axes` object

    onselect : func(min, max), min/max are floats

    direction : "horizontal" or "vertical"
      The axis along which to draw the span selector

    minspan : float, default is None
     If selection is less than *minspan*, do not call *onselect*

    useblit : bool, default is False
      If True, use the backend-dependent blitting features for faster
      canvas updates.

    rectprops : dict, default is None
      Dictionary of :class:`matplotlib.patches.Patch` properties

    onmove_callback : func(min, max), min/max are floats, default is None
      Called on mouse move while the span is being selected

    span_stays : bool, default is False
      If True, the span stays visible after the mouse is released

    button : int or list of ints
      Determines which mouse buttons activate the span selector
        1 = left mouse button

        2 = center mouse button (scroll wheel)

        3 = right mouse button


    Examples
    --------
    >>> import matplotlib.pyplot as plt
    >>> import matplotlib.widgets as mwidgets
    >>> fig, ax = plt.subplots()
    >>> ax.plot([1, 2, 3], [10, 50, 100])
    >>> def onselect(vmin, vmax):
            print(vmin, vmax)
    >>> rectprops = dict(facecolor='blue', alpha=0.5)
    >>> span = mwidgets.SpanSelector(ax, onselect, 'horizontal',
                                     rectprops=rectprops)
    >>> fig.show()

    See also: :doc:`/gallery/widgets/span_selector`

    c
   
      C` s   t  j |  | | d | d |	 | d  k rC t d d d d  } n  |  j | d <| d k rk t d
   n  | |  _ d  |  _ d  |  _ | |  _	 | |  _
 | |  _ | |  _ d |  _ d  |  _ |  j |  d  S(   NR	  Rr   R~   u   redt   alphag      ?u   animatedu
   horizontalu   verticalu,   direction must be 'horizontal' or 'vertical'i    (   u
   horizontalu   vertical(   i    i    (   R*  R   R   R/  R	  R   t	   directiont   rectt   pressvt	   rectpropst   onmove_callbackt   minspant
   span_stayst   prevR*   t   new_axes(
   R   R(   R-  RU  RZ  R	  RX  RY  R[  Rr   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s"    									c      	   C` sY  | |  _  |  j | j j k	 rV |  j d k	 r: |  j   n  | j j |  _ |  j   n  |  j d k r t |  j  j |  j  j	  } d \ } } n' t |  j  j	 |  j  j  } d \ } } t
 d	 | | d | d t |  j |  _ |  j r3t
 d
 | | d | d t |  j |  _ |  j j t  |  j  j |  j  n  |  j  j |  j  |  j g |  _ d S(   u)   Set SpanSelector to operate on a new Axesu
   horizontali    i   R7   R  N(   i    i   (   i   i    (   i    i    (   i    i    (   R(   R*   R)   R   R3   R.  RU  R
   R   R:   R   RB   RX  RV  R[  t	   stay_rectt   set_animatedR   R2  (   R   R(   R   R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR]    s4    		c         C` s   t  j |  |  p |  j S(   u*   return *True* if *event* should be ignored(   R*  R"   R  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR"     s    c         C` s   |  j  j |  j  |  j rH |  j j t  |  j rH |  j j   qH n  |  j	 |  \ } } |  j
 d k rx | |  _ n	 | |  _ t S(   u   on button press eventu
   horizontal(   RV  R   R  R[  R^  RB   R	  R*   RQ   RF  RU  RW  (   R   R!   Rt   R  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRK    s    			c         C` st  |  j  d k r d St |  _ |  j j t  |  j r |  j j |  j j	    |  j j
 |  j j    |  j j |  j j    |  j j |  j j    |  j j t  n  |  j j   |  j  } |  j |  \ } } |  j d k r | p |  j d } n | p|  j d } | | k r+| | } } n  | | } |  j d k	 rW| |  j k  rWd S|  j | |  d |  _  t S(   u   on button release eventNu
   horizontali    i   (   RW  R   RB   t
   buttonDownRV  R   R[  R^  t   set_xt   get_xt   set_yt   get_yt	   set_widtht	   get_widtht
   set_heightt
   get_heightR#   R*   Rw   RF  RU  R\  RZ  R-  (   R   R!   t   vminRt   R  t   vmaxt   span(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR?   !  s0    			
	c         C` s  |  j  d k r d S|  j |  \ } } | d k r8 d S| | f |  _ |  j d k r_ | } n | } | |  j  } } | | k r | | } } n  |  j d k r |  j j |  |  j j | |  n$ |  j j |  |  j j	 | |  |  j
 d k	 r|  j  } |  j |  \ } }	 |  j d k r=| p7|  j d }
 n |	 pM|  j d }
 | |
 k rl|
 | } }
 n  |  j
 | |
  n  |  j   t S(   u   on motion notify eventNu
   horizontali    i   (   RW  R   RF  R\  RU  RV  Ra  Re  Rc  Rg  RY  R1  RB   (   R   R!   R   R   t   vt   minvt   maxvRi  Rt   R  Rj  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRM  A  s8    		
N(   R   R   R   R   RB   R   R]  R"   RK  R?   RM  (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRS    s   8		!			 t   ToolHandlesc           B` se   e  Z d  Z d d	 e d  Z e d    Z e d    Z d	 d  Z	 d   Z
 d   Z d   Z RS(
   u  Control handles for canvas tools.

    Parameters
    ----------
    ax : :class:`matplotlib.axes.Axes`
        Matplotlib axes where tool handles are displayed.
    x, y : 1D arrays
        Coordinates of control handles.
    marker : str
        Shape of marker used to display handle. See `matplotlib.pyplot.plot`.
    marker_props : dict
        Additional marker properties. See :class:`matplotlib.lines.Line2D`.
    u   oc         C` s   | |  _  t d | d d d d d d d d	 d
 t d d  } | j | d  k	 rT | n i   t | | d | | |  _ |  j  j |  j  |  j |  _ d  S(   Nt   markert
   markersizei   t   mfcu   wt   lsu   noneRT  g      ?R  R;   u
   _nolegend_t   animated(	   R(   R/  RB   R1  R   R	   t   _markersR   R?  (   R   R(   R   R   Rp  t   marker_propsR	  t   props(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   x  s    	c         C` s   |  j  j   S(   N(   Ru  t	   get_xdata(   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    c         C` s   |  j  j   S(   N(   Ru  t	   get_ydata(   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    c         C` s>   | d k	 r* | } t j | | g  } n  |  j j |  d S(   u    Set x and y positions of handlesN(   R   Rp   R   Ru  t   set_data(   R   t   ptsR   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRz    s    c         C` s   |  j  j |  d  S(   N(   Ru  R   (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    c         C` s   |  j  j |  d  S(   N(   Ru  R_  (   R   Rc   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR_    s    c         C` s   t  j |  j |  j f  } |  j j j |  } | | | f } | j d k r t  j t  j	 | d d d  } t  j
 |  t  j |  f Sd t  j t  j	 | d   f Sd S(   u1   Return index and pixel distance to closest index.i   t   axisi   i    N(   Rp   t	   transposeR   R   R(   R   R7   t   ndimR   t   sumt   argminRA  (   R   R   R   R{  t   difft   dist(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   closest  s    "N(   R   R   R   R   R#   R   R&   R   R   Rz  R   R_  R  (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRo  i  s   
		t   RectangleSelectorc           B` s   e  Z d  Z e Z d d d e d d d d d d e d d  Z d   Z d   Z	 d   Z
 e d    Z e d	    Z e d
    Z e d    Z e d    Z e j d    Z d   Z d   Z e d    Z RS(   u  
    Select a rectangular region of an axes.

    For the cursor to remain responsive you must keep a reference to
    it.

    Example usage::

        from matplotlib.widgets import  RectangleSelector
        from pylab import *

        def onselect(eclick, erelease):
          'eclick and erelease are matplotlib events at press and release'
          print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata))
          print(' endposition   : (%f, %f)' % (erelease.xdata, erelease.ydata))
          print(' used button   : ', eclick.button)

        def toggle_selector(event):
            print(' Key pressed.')
            if event.key in ['Q', 'q'] and toggle_selector.RS.active:
                print(' RectangleSelector deactivated.')
                toggle_selector.RS.set_active(False)
            if event.key in ['A', 'a'] and not toggle_selector.RS.active:
                print(' RectangleSelector activated.')
                toggle_selector.RS.set_active(True)

        x = arange(100)/(99.0)
        y = sin(x)
        fig = figure
        ax = subplot(111)
        ax.plot(x,y)

        toggle_selector.RS = RectangleSelector(ax, onselect, drawtype='line')
        connect('key_press_event', toggle_selector)
        show()
    u   boxu   datai
   c      
   C` s6  t  j |  | | d | d |
 d | d) |  _ t |  _ | |  _ | d k r^ d } t |  _ n  | d k r | d) k r t d d d	 d
 d d d t  } n  |  j	 | d <| |  _
 |  j d* d d d t |  j
 |  _ |  j j |  j  n  | d k r|| d) k r&t d d
 d d d d d d  } n  |  j	 | d <| |  _ t d d g d d g d t |  j |  _ |  j j |  j  n  | |  _ | |  _ |	 d+ k rt d   n  |	 |  _ | |  _ | |  _ | d) k rt d d  } n t d | j d d   } d d d  d! g |  _ |  j \ } } t |  j | | d" | d |  j	 |  _ d# d$ d% d& g |  _ |  j \ } } t |  j | | d' d( d" | d |  j	 |  _ |  j \ } } t |  j | g | g d' d( d" | d |  j	 |  _  d) |  _! |  j |  j  j" |  j j" |  j j" g |  _# |  j s)|  j g |  _# n  d) |  _$ d) S(,   u  
        Create a selector in *ax*.  When a selection is made, clear
        the span and call onselect with::

          onselect(pos_1, pos_2)

        and clear the drawn box/line. The ``pos_1`` and ``pos_2`` are
        arrays of length 2 containing the x- and y-coordinate.

        If *minspanx* is not *None* then events smaller than *minspanx*
        in x direction are ignored (it's the same for y).

        The rectangle is drawn with *rectprops*; default::

          rectprops = dict(facecolor='red', edgecolor = 'black',
                           alpha=0.2, fill=True)

        The line is drawn with *lineprops*; default::

          lineprops = dict(color='black', linestyle='-',
                           linewidth = 2, alpha=0.5)

        Use *drawtype* if you want the mouse to draw a line,
        a box or nothing between click and actual position by setting

        ``drawtype = 'line'``, ``drawtype='box'`` or ``drawtype = 'none'``.
        Drawing a line would result in a line from vertex A to vertex C in
        a rectangle ABCD.

        *spancoords* is one of 'data' or 'pixels'.  If 'data', *minspanx*
        and *minspanx* will be interpreted in the same coordinates as
        the x and y axis. If 'pixels', they are in pixels.

        *button* is a list of integers indicating which mouse buttons should
        be used for rectangle selection.  You can also specify a single
        integer if only a single button is desired.  Default is *None*,
        which does not limit which button can be used.

        Note, typically:
         1 = left mouse button
         2 = center mouse button (scroll wheel)
         3 = right mouse button

        *interactive* will draw a set of handles and allow you interact
        with the widget after it is drawn.

        *state_modifier_keys* are keyboard modifiers that affect the behavior
        of the widget.

        The defaults are:
        dict(move=' ', clear='escape', square='shift', center='ctrl')

        Keyboard modifiers, which:
        'move': Move the existing shape.
        'clear': Clear the current shape.
        'square': Makes the shape square.
        'center': Make the initial point the center of the shape.
        'square' and 'center' can be combined.
        R	  Rr   R0  u   noneu   lineu   boxR~   u   redR}   u   blackRT  g?t   fillu   animatedi    i   R  RF   t	   linestyleu   -t	   linewidthi   g      ?u   datau   pixelsu'   'spancoords' must be 'data' or 'pixels't   mecu   ru	   edgecoloru   NWu   NEu   SEu   SWRv  u   Wu   Nu   Eu   SRp  u   sN(   i    i    (   u   datau   pixels(%   R*  R   R   t   to_drawR#   R  t   interactiveRB   R/  R	  RX  t   _shape_klassR(   R   R  R	   R   t   minspanxt   minspanyR   t
   spancoordst   drawtypet   maxdistt   gett   _corner_ordert   cornersRo  t   _corner_handlest   _edge_ordert   edge_centerst   _edge_handlesR   t   _center_handlet   active_handleR?  R2  t   _extents_on_press(   R   R(   R-  R  R  R  R	  R  RX  R  Rr   R  Rv  R  R0  Rw  t   xct   yct   xet   ye(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     sr    A													c         C` sk   |  j  r( |  j j   r( |  j |  n	 d |  _ |  j d k sJ |  j  rW |  j   n  |  j |  j  d S(   u   on button press eventN(	   R  R  R   t   _set_active_handleR   R  R1  R   R  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRK  V  s    	c         C` sQ  |  j  s |  j j t  n  |  j \ } } } } | |  j _ | |  j _ |  j j	 j
 | | g  } | \ |  j _ |  j _ | |  j _ | |  j _ |  j j	 j
 | | g  } | \ |  j _ |  j _ |  j d k r|  j j |  j j } }	 |  j j |  j j }
 } nP |  j d k rO|  j j |  j j } }	 |  j j |  j j }
 } n t d   | |
 k rw|
 | } }
 n  |	 | k r| |	 }	 } n  |
 | } | |	 } |  j d k	 o| |  j k  } |  j d k	 o| |  j k  } |  j d k r-| s| r-x |  j D] } | j t  qW|  j   d S|  j |  j |  j  |  j   t S(   u   on button release eventu   datau   pixelsu%   spancoords must be "data" or "pixels"u   noneN(   R  R  R   RB   t   extentsR5  Rt   R  R(   R   R   R   R   R6  R  R   R  R   R  R  R2  R1  R-  (   R   R!   RC  t   x2RE  t   y2t   xy1t   xy2R!  R#  R"  R$  t   spanxt   spanyt	   xproblemst	   yproblemsR?  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR?   e  sD    	



c         C` s  |  j  r |  j  d k r |  j \ } } } } |  j  d d g |  j k rV | j } n  |  j  d d g |  j k r| j } qn0d |  j k s |  j  d k r|  j d k	 r|  j \ } } } } | j |  j j } | j |  j j } | | 7} | | 7} | | 7} | | 7} n|  j j |  j j g } |  j j |  j j	 g }	 | j | d d } | j | d	 d } d
 |  j k r-t
 | j |	 d  }
 t
 | j	 |	 d	  } |
 sd St t
 |
  t
 |   } t
 |
  | k  r| | t
 |
  d 9} n  t
 |  | k  r-| | t
 |  d 9} q-n  d |  j k rS| d 9} | d 9} n  | d c | 7<| d	 c | 7<| d | | d | | d	 | | d	 | f \ } } } } | | | | f |  _ d S(   u,   on motion notify event if box/line is wantedu   Cu   Eu   Wu   Nu   Su   movei    g       @i   u   squareNgư>u   centeri   (   R  R  R  Rt   R  R9  R   R5  R   R   t   absR@  R  (   R   R!   RC  R  RE  R  t   dxR   R   t
   center_pixt   dx_pixt   dy_pixt   maxd(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRM    sJ    



(c   	      C` s   |  j  d k r[ |  j j   } |  j j   } |  j j   } |  j j   } | | | | f S|  j j   \ } } t |  t |  } } t |  t |  } } | | | | | | f Sd  S(   Nu   box(	   R  R  Rb  Rd  Rf  Rh  t   get_dataRA  R@  (	   R   RB  RD  R{   R|   R   R   RC  RE  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt
   _rect_bbox  s    c         C` sS   |  j  \ } } } } | | | | | | f } | | | | | | f } | | f S(   u7   Corners of rectangle from lower left, moving clockwise.(   R  (   R   RB  RD  R{   R|   R  R  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s    c   	      C` so   |  j  \ } } } } | d } | d } | | | | | | | f } | | | | | | | f } | | f S(   u8   Midpoint of rectangle edges from left, moving clockwise.g       @(   R  (	   R   RB  RD  R{   R|   R   R   R  R  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s    

c         C` s/   |  j  \ } } } } | | d | | d f S(   u   Center of rectangleg       @(   R  (   R   RB  RD  R{   R|   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR     s    c   	      C` s]   |  j  \ } } } } t | | | g  \ } } t | | | g  \ } } | | | | f S(   u    Return (xmin, xmax, ymin, ymax).(   R  t   sorted(	   R   RB  RD  R{   R|   R!  R"  R#  R$  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s    c         C` sd   |  j  |  |  j j |  j   |  j j |  j   |  j j |  j   |  j |  j	  |  j
   d  S(   N(   t
   draw_shapeR  Rz  R  R  R  R  R   R   R  R1  (   R   R  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s    c         C` sG  | \ } } } } t  | | g  \ } } t  | | g  \ } }	 t  |  j j    }
 t  |  j j    } t |
 d |  } t | d |  } t | |
 d  } t |	 | d  }	 |  j d k r|  j j |  |  j j	 |  |  j j
 | |  |  j j |	 |  n1 |  j d k rC|  j j | | g | |	 g  n  d  S(   Ni    i   u   boxu   line(   R  R(   R  R  R@  RA  R  R  Ra  Rc  Re  Rg  Rz  (   R   R  RB  RC  RD  RE  R!  R"  R#  R$  t   xlimt   ylim(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  		  s     c         C` su  |  j  j | j | j  \ } } |  j j | j | j  \ } } |  j j | j | j  \ } } d |  j k r d |  _ |  j |  _	 ny | |  j
 d k  r d |  _ nZ | |  j
 k r | |  j
 k r d |  _ d S| | k  r |  j | |  _ n |  j | |  _ |  j \ } }	 }
 } |  j d
 k r:|	 | j } }	 n  |  j d k r\| | j }
 } n  | |	 |
 | f |  _	 d S(   u:   Set active handle based on the location of the mouse eventu   moveu   Ci   Nu   Wu   SWu   NWu   Nu   NE(   u   Wu   SWu   NW(   u   Nu   NWu   NE(   R  R  R   R   R  R  R9  R  R  R  R  R   R  R  Rt   R  (   R   R!   t   c_idxt   c_distt   e_idxt   e_distt   m_idxt   m_distRC  R  RE  R  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  	  s(    !!!		c         C` sr   t  |  j d  rX |  j j j   } | j |  j j    j \ } } t j	 | | g  St j	 |  j j
    Sd S(   u  
        Returns numpy.ndarray of shape (2,5) containing
        x (``RectangleSelector.geometry[1,:]``) and
        y (``RectangleSelector.geometry[0,:]``)
        coordinates of the four corners of the rectangle starting
        and ending in the top left corner.
        u	   get_vertsN(   RW   R  R(   R   R   R7   t	   get_vertst   TRp   R   R  (   R   t   xfmR   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   geometry=	  s
    	!N(   R   R   R   R   R  R   RB   R   RK  R?   RM  R&   R  R  R  R   R  t   setterR  R  R  (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR    s&   $					4	7
		t   EllipseSelectorc           B` s,   e  Z d  Z e Z d   Z e d    Z RS(   u  
    Select an elliptical region of an axes.

    For the cursor to remain responsive you must keep a reference to
    it.

    Example usage::

        from matplotlib.widgets import  EllipseSelector
        from pylab import *

        def onselect(eclick, erelease):
          'eclick and erelease are matplotlib events at press and release'
          print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata))
          print(' endposition   : (%f, %f)' % (erelease.xdata, erelease.ydata))
          print(' used button   : ', eclick.button)

        def toggle_selector(event):
            print(' Key pressed.')
            if event.key in ['Q', 'q'] and toggle_selector.ES.active:
                print(' EllipseSelector deactivated.')
                toggle_selector.RS.set_active(False)
            if event.key in ['A', 'a'] and not toggle_selector.ES.active:
                print(' EllipseSelector activated.')
                toggle_selector.ES.set_active(True)

        x = arange(100)/(99.0)
        y = sin(x)
        fig = figure
        ax = subplot(111)
        ax.plot(x,y)

        toggle_selector.ES = EllipseSelector(ax, onselect, drawtype='line')
        connect('key_press_event', toggle_selector)
        show()
    c         C` s)  | \ } } } } t  | | g  \ } } t  | | g  \ } }	 | | | d | | | d g }
 | | d } |	 | d } |  j d k r |
 |  j _ d | |  j _ d | |  j _ ne t j t j d  d  } | t j	 |  |
 d } | t j
 |  |
 d } |  j j | |  d  S(   Ng       @u   boxi   i   i   i    i   (   R  R  R  R   R{   R|   Rp   t   deg2radt   aranget   cost   sinRz  (   R   R  RC  R  RE  R  R!  R"  R#  R$  R   t   aR   t   radR   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  u	  s    $c   	      C` s   |  j  d k rY |  j j \ } } |  j j } |  j j } | | d | | d | | f S|  j j   \ } } t |  t |  } } t |  t |  } } | | | | | | f Sd  S(   Nu   boxg       @(   R  R  R   R{   R|   R  RA  R@  (	   R   R   R   R{   R|   RB  RC  RD  RE  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  	  s     (   R   R   R   R   R  R  R&   R  (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  N	  s   $	t   LassoSelectorc           B` sP   e  Z d  Z d e d d d  Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   u   
    Selection curve of an arbitrary shape.

    For the selector to remain responsive you must keep a reference to it.

    The selected path can be used in conjunction with `~.Path.contains_point`
    to select data points from an image.

    In contrast to `Lasso`, `LassoSelector` is written with an interface
    similar to `RectangleSelector` and `SpanSelector`, and will continue to
    interact with the axes until disconnected.

    Example usage::

        ax = subplot(111)
        ax.plot(x,y)

        def onselect(verts):
            print(verts)
        lasso = LassoSelector(ax, onselect)

    Parameters
    ----------
    ax : :class:`~matplotlib.axes.Axes`
        The parent axes for the widget.
    onselect : function
        Whenever the lasso is released, the *onselect* function is called and
        passed the vertices of the selected path.
    button : List[Int], optional
        A list of integers indicating which mouse buttons should be used for
        rectangle selection. You can also specify a single integer if only a
        single button is desired.  Default is ``None``, which does not limit
        which button can be used.

        Note, typically:

        - 1 = left mouse button
        - 2 = center mouse button (scroll wheel)
        - 3 = right mouse button

    c         C` s   t  j |  | | d | d | d  |  _ | d  k r@ t   } n  | rS t | d <n  t g  g  |  |  _ |  j j t	  |  j
 j |  j  |  j g |  _ d  S(   NR	  Rr   u   animated(   R*  R   R   t   vertsR/  R#   R	   R)  R   RB   R(   R   R2  (   R   R(   R-  R	  R  Rr   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   	  s    	c         C` s   |  j  |  d  S(   N(   R;  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   onpress	  s    c         C` s)   |  j  |  g |  _ |  j j t  d  S(   N(   RF  R  R)  R   R#   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRK  	  s    c         C` s   |  j  |  d  S(   N(   R   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt	   onrelease	  s    c         C` sn   |  j  d  k	 r; |  j  j |  j |   |  j |  j   n  |  j j g  g  g  |  j j t  d  |  _  d  S(   N(	   R  R   R-   RF  R-  R)  Rz  R   RB   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR?   	  s    c         C` sY   |  j  d  k r d  S|  j  j |  j |   |  j j t t |  j      |  j   d  S(   N(	   R  R   R-   RF  R)  Rz  t   listR   R1  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRM  	  s
    N(   R   R   R   R   R#   R   R  RK  R  R?   RM  (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  	  s   )					t   PolygonSelectorc           B` sq   e  Z d  Z e d d d d  Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z e d
    Z RS(   uq  Select a polygon region of an axes.

    Place vertices with each mouse click, and make the selection by completing
    the polygon (clicking on the first vertex). Hold the *ctrl* key and click
    and drag a vertex to reposition it (the *ctrl* key is not necessary if the
    polygon has already been completed). Hold the *shift* key and click and
    drag anywhere in the axes to move all vertices. Press the *esc* key to
    start a new polygon.

    For the selector to remain responsive you must keep a reference to
    it.

    Parameters
    ----------
    ax : :class:`~matplotlib.axes.Axes`
        The parent axes for the widget.
    onselect : function
        When a polygon is completed or modified after completion,
        the `onselect` function is called and passed a list of the vertices as
        ``(xdata, ydata)`` tuples.
    useblit : bool, optional
    lineprops : dict, optional
        The line for the sides of the polygon is drawn with the properties
        given by `lineprops`. The default is ``dict(color='k', linestyle='-',
        linewidth=2, alpha=0.5)``.
    markerprops : dict, optional
        The markers for the vertices of the polygon are drawn with the
        properties given by `markerprops`. The default is ``dict(marker='o',
        markersize=7, mec='k', mfc='k', alpha=0.5)``.
    vertex_select_radius : float, optional
        A vertex is selected (to complete the polygon or to move a vertex)
        if the mouse click is within `vertex_select_radius` pixels of the
        vertex. The default radius is 15 pixels.

    Examples
    --------
    :doc:`/gallery/widgets/polygon_selector_demo`
    i   c         C` sq  t  d d d d d d d d d	 d d
 d  } t j |  | | d | d | d g d g |  _ |  _ t |  _ | d  k r t  d d d d d d d d  } n  |  j | d <t	 |  j |  j |  |  _
 |  j j |  j
  | d  k r	t  d d d | j d d   } n  t |  j |  j |  j d |  j d | |  _ d |  _ | |  _ |  j
 |  j j g |  _ |  j t  d  S(   NR  u   escapet   move_vertexu   controlt   move_allu   shiftR+  u   not-applicableR,  R   R	  R0  i    RF   u   kR  u   -R  i   RT  g      ?u   animatedR  Rr  u   colorRv  i(   R/  R*  R   t   _xst   _ysRB   t   _polygon_completedR   R	  R	   R)  R(   R   R  Ro  t   _polygon_handlest   _active_handle_idxt   vertex_select_radiusR?  R2  R   R#   (   R   R(   R-  R	  R  t   markerpropsR  R0  (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   
  s,    		$$			c         C` s   |  j  s d |  j k rl t |  j  d k rl |  j j | j | j  \ } } | |  j k  rl | |  _	 ql n  |  j |  j
 |  _ |  _ d S(   u   Button press event handleru   move_vertexi    N(   R  R9  R   R  R  R  R   R   R  R  R  t   _xs_at_presst   _ys_at_press(   R   R!   t   h_idxt   h_dist(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRK  7
  s    !c         C` s   |  j  d k r d |  _  n t |  j  d k rp |  j d |  j d k rp |  j d |  j d k rp t |  _ nW |  j r d |  j k r d |  j k r |  j j d | j  |  j j d | j	  n  |  j r |  j
 |  j  n  d S(   u   Button release event handleri    ii   u   move_allu   move_vertexN(   R  R   R  R  R#   R  R9  t   insertRt   R  R-  R  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR?   C
  s    
	c         C` s3   |  j  |  s/ |  j |  } |  j |  t St S(   u'   Cursor move event handler and validator(   R"   RH  RM  R#   RB   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  Y
  s
    c   	      C` s  |  j  d k ru |  j  } | j | j |  j | <|  j | <| d k r|  j r| j | j |  j d <|  j d <qnd |  j k r|  j r| j |  j j } | j |  j j } xGt t	 |  j   D]6 } |  j
 | | |  j | <|  j | | |  j | <q Wn |  j s-d |  j k s-d |  j k r1d S|  j j   j |  j d |  j d f  \ } } t j | | j d | | j d  } t	 |  j  d k r| |  j k  r|  j d |  j d |  j d <|  j d <n! | j | j |  j d <|  j d <|  j   d S(   u   Cursor move event handleri    iu   move_allu   move_vertexNi   i   (   R  Rt   R  R  R  R  R9  R5  t   rangeR   R  R  R)  t   get_transformR7   Rp   R   R   R   R  t   _draw_polygon(	   R   R!   t   idxR  R   t   kRB  RD  t   v0_dist(    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRM  e
  s*    	!'	)$,!c         C` sZ   |  j  rV d |  j k s( d |  j k rV |  j d  |  j d  |  _ |  _ |  j   n  d S(   u   Key press event handleru   move_vertexu   move_alliN(   R  R9  R  R  R  (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRP  
  s    
!c         C` s   |  j  rs | j |  j j d  k s@ | j |  j j d  k rs |  j j | j  |  j j | j  |  j	   nb | j |  j j d  k r |  j
 |  } | j g | j g |  _ |  _ t |  _  |  j t  n  d S(   u   Key release event handleru   move_vertexu   move_allu   clearN(   R  R   R0  R  R  R-   Rt   R  R  R  RH  RB   R   R#   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyRR  
  s    
	c         C` s   |  j  j |  j |  j  |  j sk t |  j  d k r |  j d |  j d k r |  j d |  j d k r |  j j |  j d  |  j d   n |  j j |  j |  j  |  j   d S(   u5   Redraw the polygon based on the new vertex positions.i   ii    N(   R)  Rz  R  R  R  R   R  R1  (   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  
  s    	$c         C` s!   t  t |  j d  |  j d    S(   u   Get the polygon vertices.

        Returns
        -------
        list
            A list of the vertices of the polygon as ``(xdata, ydata)`` tuples.
        i(   R  R   R  R  (   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  
  s    	N(   R   R   R   RB   R   R   RK  R?   R  RM  RP  RR  R  R&   R  (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  	  s   &"				&				t   Lassoc           B` s/   e  Z d  Z d e d  Z d   Z d   Z RS(   u  Selection curve of an arbitrary shape.

    The selected path can be used in conjunction with
    :func:`~matplotlib.path.Path.contains_point` to select data points
    from an image.

    Unlike :class:`LassoSelector`, this must be initialized with a starting
    point `xy`, and the `Lasso` events are destroyed upon release.

    Parameters
    ----------
    ax : `~matplotlib.axes.Axes`
        The parent axes for the widget.
    xy : array
        Coordinates of the start of the lasso.
    callback : callable
        Whenever the lasso is released, the `callback` function is called and
        passed the vertices of the selected path.
    c      	   C` s   t  j |  |  | o |  j j |  _ |  j rL |  j j |  j j  |  _ n  | \ } } | | f g |  _	 t
 | g | g d d d d d d |  _ |  j j |  j  | |  _ |  j d |  j  |  j d |  j  d  S(	   NR  u   -RF   u   blackRV   i   u   button_release_eventu   motion_notify_event(   R'   R   R*   R  R	  R  R(   R  R  R  R	   R)  R   R.   R0   R  R  (   R   R(   Ru   R.   R	  R   R   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR   
  s    	*	c         C` s   |  j  |  r d  S|  j d  k	 r |  j j | j | j f  t |  j  d k rf |  j |  j  n  |  j j	 j
 |  j  n  d  |  _ |  j   d  S(   Ni   (   R"   R  R   R-   Rt   R  R   R.   R(   R   R   R)  R3   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  
  s    	c         C` s   |  j  |  r d  S|  j d  k r& d  S| j |  j k r< d  S| j d k rO d  S|  j j | j | j f  |  j	 j
 t t |  j     |  j r |  j j |  j  |  j j |  j	  |  j j |  j j  n |  j j   d  S(   Ni   (   R"   R  R   RJ   R(   Rr   R-   Rt   R  R)  Rz  R  R   R	  R*   R  R  R  R  R  Rw   (   R   R!   (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  
  s    	N(   R   R   R   R   R#   R   R  R  (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyR  
  s   	(*   R   t
   __future__R    R   R   R   RG  RN   t	   six.movesR   t   numpyRp   t
   matplotlibR   t   patchesR   R   R   R   R	   t
   transformsR
   t   objectR   R   R'   R4   RU   Rz   R   R   R   R  R  R*  RS  Ro  R  R  R  R  R  (    (    (    s1   lib/python2.7/site-packages/matplotlib/widgets.pyt   <module>
   s<   "&*z 2[x; GW