
 m[c           @` s   d  Z  d d l m Z m Z m Z m Z d d l Z d d l m Z d d l	 m
 Z
 d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l Z d d l m Z m Z m Z m Z m Z m Z 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) m* Z* y d d l+ m, Z, e- Z. [, Wn e/ k
 re0 Z. n Xi	 d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z1 i	 d d 6d d 6d d 6d d 6d  d 6d  d 6d  d 6d! d 6d! d 6Z2 e3 d"  Z4 d#   Z5 d$ e6 f d%     YZ7 d& e7 f d'     YZ8 d( e6 f d)     YZ9 d* e6 f d+     YZ: d, e6 f d-     YZ; d. e6 f d/     YZ< e j= d0  d1 e< f d2     Y Z> d3 e< f d4     YZ? d5 e< f d6     YZ@ d7 e< f d8     YZA d9 e< f d:     YZB d; eB f d<     YZC d= e< f d>     YZD d? eB f d@     YZE dA e6 f dB     YZF e3 dC  ZG dD eH f dE     YZI dF e6 f dG     YZJ e jK ZK dH e6 f dI     YZL dJ e6 f dK     YZM dL e6 f dM     YZN d S(N   ub  
Abstract base classes define the primitives that renderers and
graphics contexts must implement to serve as a matplotlib backend

:class:`RendererBase`
    An abstract base class to handle drawing/rendering operations.

:class:`FigureCanvasBase`
    The abstraction layer that separates the
    :class:`matplotlib.figure.Figure` from the backend specific
    details like a user interface drawing area

:class:`GraphicsContextBase`
    An abstract base class that provides color, line styles, etc...

:class:`Event`
    The base class for all of the matplotlib event
    handling.  Derived classes such as :class:`KeyEvent` and
    :class:`MouseEvent` store the meta data like keys and buttons
    pressed, x and y locations in pixel and
    :class:`~matplotlib.axes.Axes` coordinates.

:class:`ShowBase`
    The base class for the Show class of each interactive backend;
    the 'show' callable is then set to Show.__call__, inherited from
    ShowBase.

:class:`ToolContainerBase`
     The base class for the Toolbar class of each interactive backend.

:class:`StatusbarBase`
    The base class for the messaging area.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   xrange(   t   contextmanager(   t   partial(   t   WeakKeyDictionary(
   t   backend_toolst   cbookt   colorst   textpatht
   tight_bboxt
   transformst   widgetst   get_backendt   is_interactivet   rcParams(   t   Gcf(   t   Bboxt   TransformedBboxt   Affine2D(   t   Path(   t   Imageu
   Postscriptu   psu   Encapsulated Postscriptu   epsu   Portable Document Formatu   pdfu   PGF code for LaTeXu   pgfu   Portable Network Graphicsu   pngu   Raw RGBA bitmapu   rawu   rgbau   Scalable Vector Graphicsu   svgu   svgzu   matplotlib.backends.backend_psu   matplotlib.backends.backend_pdfu   matplotlib.backends.backend_pgfu   matplotlib.backends.backend_aggu   matplotlib.backends.backend_svgc         C` s-   | d k r d } n  | t |  <| t |  <d S(   u@  
    Register a backend for saving to a given file format.

    Parameters
    ----------
    format : str
        File extension

    backend : module string or canvas class
        Backend for handling file output

    description : str, optional
        Description of the file type.  Defaults to an empty string
    u    N(   t   Nonet   _default_backendst   _default_filetypes(   t   formatt   backendt   description(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   register_backend^   s    	
c         C` sO   |  t  k r d St  |  } t | t j  rK t j |  j } | t  |  <n  | S(   uv   
    Return the registered default canvas for given file format.
    Handles deferred import of required backend.
    N(   R   R   t
   isinstancet   sixt   string_typest	   importlibt   import_modulet   FigureCanvas(   R   t   backend_class(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_registered_canvas_classs   s    
t   _Backendc           B` sn   e  Z d Z d Z d Z d Z e d     Z e d    Z	 e d    Z
 e d d   Z e d    Z RS(   c         O` sA   d d l  m } | j d |  } | | |   } |  j | |  S(   u.   Create a new figure manager instance.
        i    (   t   Figureu   FigureClass(   t   matplotlib.figureR(   t   popt   new_figure_manager_given_figure(   t   clst   numt   argst   kwargsR(   t   fig_clst   fig(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   new_figure_manager   s    c         C` s%   |  j  |  } |  j | |  } | S(   uC   Create a new figure manager instance for the given figure.
        (   R$   t   FigureManager(   R,   R-   t   figuret   canvast   manager(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR+      s    c         C` sA   |  j  d  k	 r= t   r= t j   } | r= |  j  |  q= n  d  S(   N(   t   trigger_manager_drawR   R   R   t
   get_active(   R,   R6   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_if_interactive   s    c         C` s   |  j  d k r d St j   } | s) d Sx | D] } | j   q0 W| d k r d d l m } y | j j } Wn t k
 r t	 } n X| o t
   } t   d k r t } q n  | r |  j    n  d S(   u   Show all figures.

        `show` blocks by calling `mainloop` if *block* is ``True``, or if it
        is ``None`` and we are neither in IPython's ``%pylab`` mode, nor in
        `interactive` mode.
        Ni    (   t   pyplotu   WebAgg(   t   mainloopR   R   t   get_all_fig_managerst   showt
   matplotlibR:   t	   _needmaint   AttributeErrort   FalseR   R   t   True(   R,   t   blockt   managersR6   R:   t   ipython_pylab(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR=      s$    
c         ` s   xC d d d d d d g D]) } t  t j   j | t   |   q Wd t f   f d     Y} t  t j   j d	 |    S(
   Nu   FigureCanvasu   FigureManageru   new_figure_manageru   new_figure_manager_given_figureu   draw_if_interactiveu   showt   Showc           ` s   e  Z   f d    Z RS(   c         ` s
     j    S(   N(   R;   (   t   self(   R,   (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR;      s    (   t   __name__t
   __module__R;   (    (   R,   (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRF      s   u   Show(   t   setattrt   syst   modulesRI   t   getattrt   ShowBase(   R,   t   nameRF   (    (   R,   s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   export   s    'N(   RH   RI   R   R$   R3   R7   R;   t   classmethodR2   R+   R9   R=   t   staticmethodRP   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR'      s   

!RN   c           B` s   e  Z d  Z d d  Z RS(   uu   
    Simple base class to generate a show() callable in backends.

    Subclass must override mainloop() method.
    c         C` s   |  j  d |  S(   NRC   (   R=   (   RG   RC   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   __call__   s    N(   RH   RI   t   __doc__R   RS   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRN      s   t   RendererBasec           B` s=  e  Z d  Z d   Z d! d  Z d   Z d! d  Z d! d  Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d! d  Z d   Z d   Z d d! d  Z e 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# RS("   u#  An abstract base class to handle drawing/rendering operations.

    The following methods must be implemented in the backend for full
    functionality (though just implementing :meth:`draw_path` alone would
    give a highly capable backend):

    * :meth:`draw_path`
    * :meth:`draw_image`
    * :meth:`draw_gouraud_triangle`

    The following methods *should* be implemented in the backend for
    optimization reasons:

    * :meth:`draw_text`
    * :meth:`draw_markers`
    * :meth:`draw_path_collection`
    * :meth:`draw_quad_mesh`

    c         C` s   d  |  _ t j   |  _ d  S(   N(   R   t   _texmanagerR   t
   TextToPatht
   _text2path(   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   __init__  s    	c         C` s   d S(   u   
        Open a grouping element with label *s*. If *gid* is given, use
        *gid* as the id of the group. Is only currently used by
        :mod:`~matplotlib.backends.backend_svg`.
        N(    (   RG   t   st   gid(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   open_group  s    c         C` s   d S(   u   
        Close a grouping element with label *s*
        Is only currently used by :mod:`~matplotlib.backends.backend_svg`
        N(    (   RG   RZ   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   close_group  s    c         C` s
   t   d S(   uk   
        Draws a :class:`~matplotlib.path.Path` instance using the
        given affine transform.
        N(   t   NotImplementedError(   RG   t   gct   patht	   transformt   rgbFace(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   draw_path  s    c         C` su   xn | j  | d t D]W \ } } t |  r | d \ }	 }
 |  j | | | t j   j |	 |
  |  q q Wd S(   u3  
        Draws a marker at each of the vertices in path.  This includes
        all vertices, including control points on curves.  To avoid
        that behavior, those vertices should be removed before calling
        this function.

        This provides a fallback implementation of draw_markers that
        makes multiple calls to :meth:`draw_path`.  Some backends may
        want to override this method in order to draw the marker only
        once and reuse it multiple times.

        Parameters
        ----------
        gc : `GraphicsContextBase`
            The graphics context

        marker_trans : `matplotlib.transforms.Transform`
            An affine transform applied to the marker.

        trans : `matplotlib.transforms.Transform`
            An affine transform applied to the path.

        t   simplifyiN(   t   iter_segmentsRA   t   lenRc   R   R   t	   translate(   RG   R_   t   marker_patht   marker_transR`   t   transRb   t   verticest   codest   xt   y(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_markers  s    "c         C` s   g  } x? |  j  | | |  D]( \ } } | j | t j |  f  q Wx |  j | | | | | | | | |	 |
 | | |  D]X \ } } } } } | \ } } t j | j    j | |  } |  j | | | |  q| Wd S(   u  
        Draws a collection of paths selecting drawing properties from
        the lists *facecolors*, *edgecolors*, *linewidths*,
        *linestyles* and *antialiaseds*. *offsets* is a list of
        offsets to apply to each of the paths.  The offsets in
        *offsets* are first transformed by *offsetTrans* before being
        applied.  *offset_position* may be either "screen" or "data"
        depending on the space that the offsets are in.

        This provides a fallback implementation of
        :meth:`draw_path_collection` that makes multiple calls to
        :meth:`draw_path`.  Some backends may want to override this in
        order to render each set of path data only once, and then
        reference that path multiple times with the different offsets,
        colors, styles etc.  The generator methods
        :meth:`_iter_collection_raw_paths` and
        :meth:`_iter_collection` are provided to help with (and
        standardize) the implementation across backends.  It is highly
        recommended to use those generators, so that changes to the
        behavior of :meth:`draw_path_collection` can be made globally.
        N(   t   _iter_collection_raw_pathst   appendR   R   t   _iter_collectiont
   get_matrixRg   Rc   (   RG   R_   t   master_transformt   pathst   all_transformst   offsetst   offsetTranst
   facecolorst
   edgecolorst
   linewidthst
   linestylest   antialiasedst   urlst   offset_positiont   path_idsR`   Ra   t   xot   yot   path_idt   gc0Rb   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_path_collection@  s    	 	"c         C` s   d d l  m } | j | | |  } |
 d k r: | }
 n  t j | j   g t  } |  j | | | g  | | | |
 | g  |	 g d g d  S(   u   
        This provides a fallback implementation of
        :meth:`draw_quad_mesh` that generates paths and then calls
        :meth:`draw_path_collection`.
        i    (   t   QuadMeshu   screenN(	   t   matplotlib.collectionsR   t   convert_mesh_to_pathsR   t   npt   arrayt   get_linewidtht   floatR   (   RG   R_   Rt   t	   meshWidtht
   meshHeightt   coordinatesRw   Rx   Ry   t   antialiasedRz   R   Ru   R{   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_quad_meshg  s    		c         C` s
   t   d S(   u  
        Draw a Gouraud-shaded triangle.

        Parameters
        ----------
        points : array_like, shape=(3, 2)
            Array of (x, y) points for the triangle.

        colors : array_like, shape=(3, 4)
            RGBA colors for each point of the triangle.

        transform : `matplotlib.transforms.Transform`
            An affine transform to apply to the points.

        N(   R^   (   RG   R_   t   pointsR
   Ra   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_gouraud_triangle|  s    c         C` sF   | j    } x3 t | |  D]" \ } } |  j | | | |  q Wd S(   u  
        Draws a series of Gouraud triangles.

        Parameters
        ----------
        points : array_like, shape=(N, 3, 2)
            Array of *N* (x, y) points for the triangles.

        colors : array_like, shape=(N, 3, 4)
            Array of *N* RGBA colors for each point of the triangles.

        transform : `matplotlib.transforms.Transform`
            An affine transform to apply to the points.
        N(   t   frozent   zipR   (   RG   R_   t   triangles_arrayt   colors_arrayRa   t   trit   col(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_gouraud_triangles  s    c   
      c` s   t  |  } t  |  } t | |  } | d k r7 d St j   } xN t |  D]@ } | | | }	 | r t | | |  } n  |	 | | f VqP Wd S(   uJ  
        This is a helper method (along with :meth:`_iter_collection`) to make
        it easier to write a space-efficient :meth:`draw_path_collection`
        implementation in a backend.

        This method yields all of the base path/transform
        combinations, given a master transform, a list of paths and
        list of transforms.

        The arguments should be exactly what is passed in to
        :meth:`draw_path_collection`.

        The backend should take each yielded path and transform and
        create an object that can be referenced (reused) later.
        i    N(   Rf   t   maxR   t   IdentityTransformR   R   (
   RG   Rt   Ru   Rv   t   Npathst   Ntransformst   NRa   t   iR`   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRp     s    c   	      C` sz   t  |  } | d k s< t  |  d k r@ t  |  d k r@ d St | t  |   } t | t  |   } | | d | S(   u|  
        Compute how many times each raw path object returned by
        _iter_collection_raw_paths would be used when calling
        _iter_collection. This is intended for the backend to decide
        on the tradeoff between using the paths in-line and storing
        them once and reusing. Rounds up in case the number of uses
        is not the same for every path.
        i    i   (   Rf   R   (	   RG   Ru   Rv   Rw   Ry   Rz   R   t	   Npath_idsR   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _iter_collection_uses_per_path  s    
0c   #      c` s;  t  |  } t  |  } t  |  } t | |  } t  |  } t  |  } t  |	  } t  |
  } t  |  } t  |  } | d k r | d k s | d k r d S| r | j |  } n  |  j   } | j |  | d k r d } n  | d k r| j d  n  d \ } } xt |  D]} | | | } | r| | | \ } } | d k r| ryt | | |  | } n | } | j	 | | f  \ } } | j	 d  \ }  }! |  | } |! | } qn  t
 j |  ot
 j |  sqn  | r| | | } n  | r| r*| j |	 | |  n  | rH| j |
 | |   n  | | | }" t  |"  d k r|" d d k r| j d  q| j |"  q| j |"  n  | d k	 rt  |  d k r| d d k rd } qn  | j | | |  | r| j | | |  n  | | | | | f VqW| j   d S(	   u  
        This is a helper method (along with
        :meth:`_iter_collection_raw_paths`) to make it easier to write
        a space-efficient :meth:`draw_path_collection` implementation in a
        backend.

        This method yields all of the path, offset and graphics
        context combinations to draw the path collection.  The caller
        should already have looped over the results of
        :meth:`_iter_collection_raw_paths` to draw this collection.

        The arguments should be the same as that passed into
        :meth:`draw_path_collection`, with the exception of
        *path_ids*, which is a list of arbitrary objects that the
        backend will use to reference one of the paths created in the
        :meth:`_iter_collection_raw_paths` stage.

        Each yielded result is of the form::

           xo, yo, path_id, gc, rgbFace

        where *xo*, *yo* is an offset; *path_id* is one of the elements of
        *path_ids*; *gc* is a graphics context and *rgbFace* is a color to
        use for filling the path.
        i    Ng        u   datai   i   (   i    i    (   i    i    (   Rf   R   Ra   t   new_gct   copy_propertiesR   t   set_linewidthR   R   t   transform_pointR   t   isfinitet
   set_dashest   set_foregroundt   set_antialiasedt   set_urlt   restore(#   RG   R_   Rt   Rv   R   Rw   Rx   Ry   Rz   R{   R|   R}   R~   R   R   R   t   NoffsetsR   t   Nfacecolorst   Nedgecolorst   Nlinewidthst   Nlinestylest   Naat   Nurlst   toffsetsR   Rb   R   R   R   R   Ra   t   xpt   ypt   fg(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRr     sr    $	
c         C` s   d S(   u   
        Get the factor by which to magnify images passed to :meth:`draw_image`.
        Allows a backend to have images at a different resolution to other
        artists.
        g      ?(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_image_magnification3  s    c         C` s
   t   d S(   u  
        Draw an RGBA image.

        Parameters
        ----------
        gc : `GraphicsContextBase`
            a graphics context with clipping information.

        x : scalar
            the distance in physical units (i.e., dots or pixels) from the left
            hand side of the canvas.

        y : scalar
            the distance in physical units (i.e., dots or pixels) from the
            bottom side of the canvas.

        im : array_like, shape=(N, M, 4), dtype=np.uint8
            An array of RGBA pixels.

        transform : `matplotlib.transforms.Affine2DBase`
            If and only if the concrete backend is written such that
            :meth:`option_scale_image` returns ``True``, an affine
            transformation *may* be passed to :meth:`draw_image`. It takes the
            form of a :class:`~matplotlib.transforms.Affine2DBase` instance.
            The translation vector of the transformation is given in physical
            units (i.e., dots or pixels). Note that the transformation does not
            override `x` and `y`, and has to be applied *before* translating
            the result by `x` and `y` (this can be accomplished by adding `x`
            and `y` to the translation vector defined by `transform`).
        N(   R^   (   RG   R_   Rm   Rn   t   imRa   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   draw_image;  s    c         C` s   t  S(   u   
        override this method for renderers that do not necessarily always
        want to rescale and composite raster images. (like SVG, PDF, or PS)
        (   RA   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   option_image_nocomposite\  s    c         C` s   t  S(   u   
        override this method for renderers that support arbitrary affine
        transformations in :meth:`draw_image` (most vector backends).
        (   RA   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   option_scale_imagec  s    u   TeX!c	   	   	   C` s&   |  j  | | | | | | d d d S(   u	   
        t   ismathu   TeXN(   t   _draw_text_as_path(	   RG   R_   Rm   Rn   RZ   t   propt   angleR   t   mtext(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_texj  s    c	   	      C` s#   |  j  | | | | | | |  d S(   u  
        Draw the text instance

        Parameters
        ----------
        gc : `GraphicsContextBase`
            the graphics context

        x : scalar
            the x location of the text in display coords

        y : scalar
            the y location of the text baseline in display coords

        s : str
            the text string

        prop : `matplotlib.font_manager.FontProperties`
            font properties

        angle : scalar
            the rotation angle in degrees

        mtext : `matplotlib.text.Text`
            the original text object to be rendered

        Notes
        -----
        **backend implementers note**

        When you are trying to determine if you have gotten your bounding box
        right (which is what enables the text layout/alignment to work
        properly), it helps to change the line in text.py::

            if 0: bbox_artist(self, renderer)

        to if 1, and then the actual bounding box will be plotted along with
        your text.
        N(   R   (	   RG   R_   Rm   Rn   RZ   R   R   R   R   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   draw_texto  s    )c         C` s/  |  j  } |  j | j    } | d k rQ | j | | d t d t \ }	 }
 n$ | j | | d | d t \ }	 }
 t |	 |
  } t j |  } |  j	   r t
   j | | j | | j  } | j |  j | |  j |  } n> t
   j | | j | | j  } | j |  j | |  } | | f S(   u}  
        return the text path and transform

        Parameters
        ----------
        prop : `matplotlib.font_manager.FontProperties`
          font property

        s : str
          text to be converted

        usetex : bool
          If True, use matplotlib usetex mode.

        ismath : bool
          If True, use mathtext parser. If "TeX", use *usetex* mode.
        u   TeXR   t   usetex(   RX   t   points_to_pixelst   get_size_in_pointst   get_text_pathRA   RB   R   R   t   deg2radt   flipyR   t   scalet
   FONT_SCALEt   rotateRg   t   height(   RG   Rm   Rn   RZ   R   R   R   t	   text2patht   fontsizet   vertsRl   R`   Ra   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _get_text_path_transform  s"    	%c         C` sZ   |  j  | | | | | |  \ } }	 | j   }
 | j d  |  j | | |	 d |
 d S(   u  
        draw the text by converting them to paths using textpath module.

        Parameters
        ----------
        prop : `matplotlib.font_manager.FontProperties`
          font property

        s : str
          text to be converted

        usetex : bool
          If True, use matplotlib usetex mode.

        ismath : bool
          If True, use mathtext parser. If "TeX", use *usetex* mode.
        g        Rb   N(   R   t   get_rgbR   Rc   (   RG   R_   Rm   Rn   RZ   R   R   R   R`   Ra   t   color(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s
    c         C` s8  | d k ra | j    } |  j j   } | j    } | j | | d |  \ } } }	 | | |	 f S|  j d  }
 | r |  j j j | |
 |  } | d d !S|  j j   } |  j j |  } | j    } | j	 | |
  | j
 | d d | | j   \ } } | j   }	 | d } | d } |	 d }	 | | |	 f S(	   u   
        Get the width, height, and descent (offset from the bottom
        to the baseline), in display coords, of the string *s* with
        :class:`~matplotlib.font_manager.FontProperties` *prop*
        u   TeXt   rendereriH   i    i   g        t   flagsg      P@(   R   RX   t   get_texmanagert   get_text_width_height_descentR   t   mathtext_parsert   parset   _get_hinting_flagt	   _get_fontt   set_sizet   set_textt   get_width_heightt   get_descent(   RG   RZ   R   R   t   sizet
   texmanagerR   t   wt   ht   dt   dpit   dimsR   t   font(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s,    


c         C` s   t  S(   u   
        Return true if y small numbers are top for renderer Is used
        for drawing text (:mod:`matplotlib.text`) and images
        (:mod:`matplotlib.image`) only
        (   RB   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s    c         C` s   d S(   u4   return the canvas width and height in display coordsi   (   i   i   (    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_canvas_width_height  s    c         C` s5   |  j  d k r. d d l m } |   |  _  n  |  j  S(   uO   
        return the :class:`matplotlib.texmanager.TexManager` instance
        i    (   t
   TexManagerN(   RV   R   t   matplotlib.texmanagerR   (   RG   R   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   
  s    c         C` s   t    S(   uF   
        Return an instance of a :class:`GraphicsContextBase`
        (   t   GraphicsContextBase(   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s    c         C` s   | S(   u  
        Convert points to display units

        You need to override this function (unless your backend
        doesn't have a dpi, e.g., postscript or svg).  Some imaging
        systems assume some value for pixels per inch::

            points to pixels = points * pixels_per_inch/72.0 * dpi/72.0

        Parameters
        ----------
        points : scalar or array_like
            a float or a numpy array of float

        Returns
        -------
        Points converted to pixels
        (    (   RG   R   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s    c         C` s   t  j |  S(   N(   R	   t
   strip_math(   RG   RZ   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   .  s    c         C` s   d S(   uK   
        Used in MixedModeRenderer. Switch to the raster renderer.
        N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   start_rasterizing1  s    c         C` s   d S(   u   
        Used in MixedModeRenderer. Switch back to the vector renderer
        and draw the contents of the raster renderer as an image on
        the vector renderer.
        N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   stop_rasterizing6  s    c         C` s   d S(   uj   
        Used in AggRenderer. Switch to a temporary renderer for image
        filtering effects.
        N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   start_filter=  s    c         C` s   d S(   u   
        Used in AggRenderer. Switch back to the original renderer.
        The contents of the temporary renderer is processed with the
        *filter_func* and is drawn on the original renderer as an
        image.
        N(    (   RG   t   filter_func(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   stop_filterC  s    N($   RH   RI   RT   RY   R   R\   R]   Rc   Ro   R   R   R   R   Rp   R   Rr   R   R   R   R   R   RA   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRU      s@   		 	'						a	!		+	*		!										R   c           B` s  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z e j 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 e d  Z d   Z d   Z e j d  d    Z  d   Z! d   Z" d   Z# d    Z$ d!   Z% d" d#  Z& d$   Z' d%   Z( d&   Z) d'   Z* d) d) d) d(  Z, RS(*   uI   
    An abstract base class that provides color, line styles, etc...
    c         C` s   d |  _  t |  _ d |  _ d |  _ d  |  _ d  |  _ d	 |  _ d |  _	 d |  _
 d |  _ d
 |  _ d  |  _ t j t d  |  _ t d |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  S(   Ng      ?i   u   buttu   roundu   solidg        u   hatch.coloru   hatch.linewidth(   NN(   g        g        g        g      ?(   t   _alphaRA   t   _forced_alphat   _antialiasedt	   _capstyleR   t	   _cliprectt	   _clippatht   _dashest
   _joinstylet
   _linestylet
   _linewidtht   _rgbt   _hatchR
   t   to_rgbaR   t   _hatch_colort   _hatch_linewidtht   _urlt   _gidt   _snapt   _sketch(   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY   Q  s$    															c         C` s   | j  |  _  | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j	 |  _	 | j
 |  _
 | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ d S(   u   Copy properties from gc to selfN(   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  (   RG   R_   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   e  s$    c         C` s   d S(   u   
        Restore the graphics context from the stack - needed only
        for backends that save graphics contexts on a stack
        N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   z  s    c         C` s   |  j  S(   ub   
        Return the alpha value used for blending - not supported on
        all backends
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   get_alpha  s    c         C` s   |  j  S(   u@   Return true if the object should try to do antialiased rendering(   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_antialiased  s    c         C` s   |  j  S(   uT   
        Return the capstyle as a string in ('butt', 'round', 'projecting')
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_capstyle  s    c         C` s   |  j  S(   uf   
        Return the clip rectangle as a :class:`~matplotlib.transforms.Bbox`
        instance
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_clip_rectangle  s    c         C` s    |  j  d k	 r |  j  j   Sd S(   u   
        Return the clip path in the form (path, transform), where path
        is a :class:`~matplotlib.path.Path` instance, and transform is
        an affine transform to apply to the path before clipping.
        N(   NN(   R   R   t   get_transformed_path_and_affine(   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_clip_path  s    c         C` s   |  j  S(   uO  
        Return the dash information as an offset dashlist tuple.

        The dash list is a even size list that gives the ink on, ink
        off in pixels.

        See p107 of to PostScript `BLUEBOOK
        <https://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF>`_
        for more info.

        Default value is None
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   get_dashes  s    c         C` s   |  j  S(   u   
        Return whether the value given by get_alpha() should be used to
        override any other alpha-channel values.
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_forced_alpha  s    c         C` s   |  j  S(   uR   
        Return the line join style as one of ('miter', 'round', 'bevel')
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_joinstyle  s    u   2.1c         C` s   |  j  S(   u`   
        Return the linestyle: one of ('solid', 'dashed', 'dashdot',
        'dotted').
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_linestyle  s    c         C` s   |  j  S(   u=   
        Return the line width in points as a scalar
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s    c         C` s   |  j  S(   uC   
        returns a tuple of three or four floats from 0-1.
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s    c         C` s   |  j  S(   u=   
        returns a url if one is set, None otherwise
        (   R  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_url  s    c         C` s   |  j  S(   uM   
        Return the object identifier if one is set, None otherwise.
        (   R  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_gid  s    c         C` s   |  j  S(   u  
        returns the snap setting which may be:

          * True: snap vertices to the nearest pixel center

          * False: leave vertices as-is

          * None: (auto) If the path contains only rectilinear line
            segments, round to the nearest pixel center
        (   R  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_snap  s    c         C` sM   | d k	 r! | |  _ t |  _ n d |  _ t |  _ |  j |  j d t d S(   uA  
        Set the alpha value used for blending - not supported on all backends.
        If ``alpha=None`` (the default), the alpha components of the
        foreground and fill colors will be used to set their respective
        transparencies (where applicable); otherwise, ``alpha`` will override
        them.
        g      ?t   isRGBAN(   R   R   RB   R   RA   R   R   (   RG   t   alpha(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   set_alpha  s    			c         C` s   | r d |  _  n	 d |  _  d S(   uK   
        True if object should be drawn with antialiased rendering
        i   i    N(   R   (   RG   t   b(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s    c         C` s,   | d k r | |  _  n t d |   d S(   uQ   
        Set the capstyle as a string in ('butt', 'round', 'projecting')
        u   buttu   roundu
   projectingu!   Unrecognized cap style.  Found %sN(   u   buttu   roundu
   projecting(   R   t
   ValueError(   RG   t   cs(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_capstyle  s    c         C` s   | |  _  d S(   uT   
        Set the clip rectangle with sequence (left, bottom, width, height)
        N(   R   (   RG   t	   rectangle(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_clip_rectangle  s    c         C` s;   | d k	 r. t | t j  r. t d   n  | |  _ d S(   u   
        Set the clip path and transformation.  Path should be a
        :class:`~matplotlib.transforms.TransformedPath` instance.
        u?   Path should be a matplotlib.transforms.TransformedPath instanceN(   R   R   R   t   TransformedPathR  R   (   RG   R`   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_clip_path  s    c         C` sU   | d k	 rB t j |  } t j | d k   rB t d   qB n  | | f |  _ d S(   u$  
        Set the dash style for the gc.

        Parameters
        ----------
        dash_offset : float
            is the offset (usually 0).

        dash_list : array_like
            specifies the on-off sequence as points.
            ``(None, None)`` specifies a solid line

        g        u,   All values in the dash list must be positiveN(   R   R   t   asarrayt   anyR  R   (   RG   t   dash_offsett	   dash_listt   dl(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR      s    c         C` su   |  j  r) | r) | d  |  j f |  _ nH |  j  rM t j | |  j  |  _ n$ | r_ | |  _ n t j |  |  _ d S(   u  
        Set the foreground color.  fg can be a MATLAB format string, a
        html hex color string, an rgb or rgba unit tuple, or a float between 0
        and 1.  In the latter case, grayscale is used.

        If you know fg is rgba, set ``isRGBA=True`` for efficiency.
        i   N(   R   R   R   R
   R   (   RG   R   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   5  s    	c         C` s,   | d k r | |  _  n t d |   d S(   uM   
        Set the join style to be one of ('miter', 'round', 'bevel')
        u   miteru   roundu   bevelu"   Unrecognized join style.  Found %sN(   u   miteru   roundu   bevel(   R   R  (   RG   t   js(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_joinstyleF  s    c         C` s   t  |  |  _ d S(   u-   
        Set the linewidth in points
        N(   R   R   (   RG   R   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   O  s    c         C` s   | |  _  d S(   uC  
        Set the linestyle to be one of ('solid', 'dashed', 'dashdot',
        'dotted'). These are defined in the rcParams
        `lines.dashed_pattern`, `lines.dashdot_pattern` and
        `lines.dotted_pattern`.  One may also specify customized dash
        styles by providing a tuple of (offset, dash pairs).
        N(   R   (   RG   t   style(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_linestyleU  s    	c         C` s   | |  _  d S(   u?   
        Sets the url for links in compatible backends
        N(   R  (   RG   t   url(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   `  s    c         C` s   | |  _  d S(   u   
        Sets the id.
        N(   R  (   RG   t   id(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_gidf  s    c         C` s   | |  _  d S(   u  
        Sets the snap setting which may be:

          * True: snap vertices to the nearest pixel center

          * False: leave vertices as-is

          * None: (auto) If the path contains only rectilinear line
            segments, round to the nearest pixel center
        N(   R  (   RG   t   snap(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_snapl  s    c         C` s   | |  _  d S(   u2   
        Sets the hatch style for filling
        N(   R   (   RG   t   hatch(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   set_hatchy  s    c         C` s   |  j  S(   u.   
        Gets the current hatch style
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   get_hatch  s    g      @c         C` s,   |  j    } | d k r d St j | |  S(   u7   
        Returns a Path for the current hatch.
        N(   R-  R   R   R+  (   RG   t   densityR+  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_hatch_path  s    c         C` s   |  j  S(   u5   
        Gets the color to use for hatching.
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_hatch_color  s    c         C` s   | |  _  d S(   u5   
        sets the color to use for hatching.
        N(   R   (   RG   t   hatch_color(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_hatch_color  s    c         C` s   |  j  S(   u9   
        Gets the linewidth to use for hatching.
        (   R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_hatch_linewidth  s    c         C` s   |  j  S(   u  
        Returns the sketch parameters for the artist.

        Returns
        -------
        sketch_params : tuple or `None`

        A 3-tuple with the following elements:

          * `scale`: The amplitude of the wiggle perpendicular to the
            source line.

          * `length`: The length of the wiggle along the line.

          * `randomness`: The scale factor by which the length is
            shrunken or expanded.

        May return `None` if no sketch parameters were set.
        (   R  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_sketch_params  s    c         C` s4   | d k r d n | | p d | p' d f |  _ d S(   u0  
        Sets the sketch parameters.

        Parameters
        ----------

        scale : float, optional
            The amplitude of the wiggle perpendicular to the source
            line, in pixels.  If scale is `None`, or not provided, no
            sketch filter will be provided.

        length : float, optional
             The length of the wiggle along the line, in pixels
             (default 128)

        randomness : float, optional
            The scale factor by which the length is shrunken or
            expanded (default 16)
        g      `@g      0@N(   R   R  (   RG   R   t   lengtht
   randomness(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_sketch_params  s    N(-   RH   RI   RT   RY   R   R   R  R  R  R  R
  R  R  R  R	   t
   deprecatedR  R   R   R  R  R  R  R   R  R  R  R   RA   R   R#  R   R%  R   R(  R*  R,  R-  R/  R0  R2  R3  R4  R   R7  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   L  sN   								
																												t	   TimerBasec           B` s   e  Z d  Z d d d  Z d   Z d d  Z d   Z d   Z d   Z	 d   Z
 d   Z e e
 e  Z d	   Z e d
  Z e e e  Z d   Z d   Z d   Z d   Z d   Z RS(   u  
    A base class for providing timer events, useful for things animations.
    Backends need to implement a few specific methods in order to use their
    own timing mechanisms so that the timer events are integrated into their
    event loops.

    Mandatory functions that must be implemented:

        * `_timer_start`: Contains backend-specific code for starting
          the timer

        * `_timer_stop`: Contains backend-specific code for stopping
          the timer

    Optional overrides:

        * `_timer_set_single_shot`: Code for setting the timer to
          single shot operating mode, if supported by the timer
          object. If not, the `Timer` class itself will store the flag
          and the `_on_timer` method should be overridden to support
          such behavior.

        * `_timer_set_interval`: Code for setting the interval on the
          timer, if there is a method for doing so on the timer
          object.

        * `_on_timer`: This is the internal function that any timer
          object should call, which will handle the task of running
          all callbacks that have been set.

    Attributes
    ----------
    interval : scalar
        The time between timer events in milliseconds. Default is 1000 ms.

    single_shot : bool
        Boolean flag indicating whether this timer should operate as single
        shot (run once and then stop). Defaults to `False`.

    callbacks : List[Tuple[callable, Tuple, Dict]]
        Stores list of (func, args, kwargs) tuples that will be called upon
        timer events. This list can be manipulated directly, or the
        functions `add_callback` and `remove_callback` can be used.

    c         C` sY   | d  k r g  |  _ n
 | |  _ | d  k r: d |  _ n	 | |  _ t |  _ d  |  _ d  S(   Ni  (   R   t	   callbackst	   _intervalRA   t   _singlet   _timer(   RG   t   intervalR:  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s    
		c         C` s   |  j    d S(   u1   Need to stop timer and possibly disconnect timer.N(   t   _timer_stop(   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   __del__  s    c         C` s*   | d k	 r |  j |  n  |  j   d S(   u   
        Start the timer object. `interval` is optional and will be used
        to reset the timer interval first if provided.
        N(   R   t   _set_intervalt   _timer_start(   RG   R>  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   start  s    c         C` s   |  j    d S(   u!   
        Stop the timer.
        N(   R?  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   stop  s    c         C` s   d  S(   N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRB  !  s    c         C` s   d  S(   N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR?  $  s    c         C` s   |  j  S(   N(   R;  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _get_interval'  s    c         C` s#   t  |  } | |  _ |  j   d  S(   N(   t   intR;  t   _timer_set_interval(   RG   R>  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRA  *  s    	c         C` s   |  j  S(   N(   R<  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _get_single_shot3  s    c         C` s   | |  _  |  j   d  S(   N(   R<  t   _timer_set_single_shot(   RG   t   ss(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _set_single_shot6  s    	c         O` s   |  j  j | | | f  d S(   u   
        Register `func` to be called by timer when the event fires. Any
        additional arguments provided will be passed to `func`.
        N(   R:  Rq   (   RG   t   funcR.   R/   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   add_callback<  s    c         O` st   | s | r( |  j  j | | | f  nH g  |  j  D] } | d ^ q2 } | | k rp |  j  j | j |   n  d S(   u   
        Remove `func` from list of callbacks. `args` and `kwargs` are optional
        and used to distinguish between copies of the same function registered
        to be called with different arguments.
        i    N(   R:  t   removeR*   t   index(   RG   RL  R.   R/   t   ct   funcs(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   remove_callbackC  s
     c         C` s   d S(   u0   Used to set interval on underlying timer object.N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRG  P  s    c         C` s   d S(   u3   Used to set single shot on underlying timer object.N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRI  S  s    c         C` sz   xQ |  j  D]F \ } } } | | |   } | d k r
 |  j  j | | | f  q
 q
 Wt |  j   d k rv |  j   n  d S(   u   
        Runs all function that have been registered as callbacks. Functions
        can return False (or 0) if they should not be called any more. If there
        are no callbacks, the timer is automatically stopped.
        i    N(   R:  RN  Rf   RD  (   RG   RL  R.   R/   t   ret(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   _on_timerV  s     N(   RH   RI   RT   R   RY   R@  RC  RD  RB  R?  RE  RA  t   propertyR>  RH  RB   RK  t   single_shotRM  RR  RG  RI  RT  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR9    s$   -												t   Eventc           B` s   e  Z d  Z d d  Z RS(   u  
    A matplotlib event.  Attach additional attributes as defined in
    :meth:`FigureCanvasBase.mpl_connect`.  The following attributes
    are defined and shown with their default values

    Attributes
    ----------
    name : str
        the event name

    canvas : `FigureCanvasBase`
        the backend-specific canvas instance generating the event

    guiEvent
        the GUI event that triggered the matplotlib event

    c         C` s   | |  _  | |  _ | |  _ d  S(   N(   RO   R5   t   guiEvent(   RG   RO   R5   RX  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY   |  s    		N(   RH   RI   RT   R   RY   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRW  j  s   u   2.1t	   IdleEventc           B` s   e  Z d  Z RS(   uc   
    An event triggered by the GUI backend when it is idle -- useful
    for passive animation
    (   RH   RI   RT   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY    s   t	   DrawEventc           B` s   e  Z d  Z d   Z RS(   u  
    An event triggered by a draw operation on the canvas

    In most backends callbacks subscribed to this callback will be
    fired after the rendering is complete but before the screen is
    updated.  Any extra artists drawn to the canvas's renderer will
    be reflected without an explicit call to ``blit``.

    .. warning ::

       Calling ``canvas.draw`` and ``canvas.blit`` in these callbacks may
       not be safe with all backends and may cause infinite recursion.

    In addition to the :class:`Event` attributes, the following event
    attributes are defined:

    Attributes
    ----------
    renderer : `RendererBase`
        the renderer for the draw event

    c         C` s    t  j |  | |  | |  _ d  S(   N(   RW  RY   R   (   RG   RO   R5   R   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s    (   RH   RI   RT   RY   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRZ    s   t   ResizeEventc           B` s   e  Z d  Z d   Z RS(   u'  
    An event triggered by a canvas resize

    In addition to the :class:`Event` attributes, the following event
    attributes are defined:

    Attributes
    ----------
    width : scalar
        width of the canvas in pixels

    height : scalar
        height of the canvas in pixels

    c         C` s/   t  j |  | |  | j   \ |  _ |  _ d  S(   N(   RW  RY   R   t   widthR   (   RG   RO   R5   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s    (   RH   RI   RT   RY   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR[    s   t
   CloseEventc           B` s   e  Z d  Z d d  Z RS(   u6   
    An event triggered by a figure being closed

    c         C` s   t  j |  | | |  d  S(   N(   RW  RY   (   RG   RO   R5   RX  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s    N(   RH   RI   RT   R   RY   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR]    s   t   LocationEventc           B` sG   e  Z d  Z d Z d Z d Z d Z d Z d Z	 d d  Z
 d   Z RS(   ud  
    An event that has a screen location

    The following additional attributes are defined and shown with
    their default values.

    In addition to the :class:`Event` attributes, the following
    event attributes are defined:

    Attributes
    ----------
    x : scalar
        x position - pixels from left of canvas

    y : scalar
        y position - pixels from bottom of canvas

    inaxes : bool
        the :class:`~matplotlib.axes.Axes` instance if mouse is over axes

    xdata : scalar
        x coord of mouse in data coords

    ydata : scalar
        y coord of mouse in data coords

    c         C` sM  t  j |  | | d | | |  _ | |  _ | d k sC | d k rZ d |  _ |  j   d S|  j j d k r g  |  j j	 j
   D] } | j |   r | ^ q } n |  j j g } | r6t j |  |  _ y1 |  j j j   } | j | | f  \ }	 }
 Wn# t k
 r d |  _ d |  _ q?X|	 |  _ |
 |  _ n	 d |  _ |  j   d S(   u?   
        *x*, *y* in figure coords, 0,0 = bottom, left
        RX  N(   RW  RY   Rm   Rn   R   t   inaxest   _update_enter_leaveR5   t   mouse_grabberR4   t   get_axest   in_axesR	   t   _topmost_artistt	   transDatat   invertedR   R  t   xdatat   ydata(   RG   RO   R5   Rm   Rn   RX  t   at	   axes_listRj   Rg  Rh  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s.    			
			c         C` s   t  j d k	 r t  j } | j |  j k r y, | j d k	 rU | j j j d |  n  Wn n X|  j d k	 r |  j j j d |   q q n( |  j d k	 r |  j j j d |   n  |  t  _ d S(   u*   process the figure/axes enter leave eventsu   axes_leave_eventu   axes_enter_eventN(   R^  t	   lasteventR   R_  R5   R:  t   process(   RG   t   last(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR`    s    	N(   RH   RI   RT   R   Rm   Rn   R_  Rg  Rh  Rk  RY   R`  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR^    s   %t
   MouseEventc           B` s_   e  Z d  Z d Z d Z d Z d Z d Z d Z	 d Z
 d Z d d d e d d  Z d   Z RS(   u  
    A mouse event ('button_press_event',
                   'button_release_event',
                   'scroll_event',
                   'motion_notify_event').

    In addition to the :class:`Event` and :class:`LocationEvent`
    attributes, the following attributes are defined:

    Attributes
    ----------
    button : None, scalar, or str
        button pressed None, 1, 2, 3, 'up', 'down' (up and down are used
        for scroll events).  Note that in the nbagg backend, both the
        middle and right clicks return 3 since right clicking will bring
        up the context menu in some browsers.

    key : None, or str
        the key depressed when the mouse event triggered (see
        :class:`KeyEvent`)

    step : scalar
        number of scroll steps (positive for 'up', negative for 'down')

    Examples
    --------
    Usage::

        def on_press(event):
            print('you pressed', event.button, event.xdata, event.ydata)

        cid = fig.canvas.mpl_connect('button_press_event', on_press)

    i    c
   
      C` sG   t  j |  | | | | d |	 | |  _ | |  _ | |  _ | |  _ d S(   un   
        x, y in figure coords, 0,0 = bottom, left
        button pressed None, 1, 2, 3, 'up', 'down'
        RX  N(   R^  RY   t   buttont   keyt   stept   dblclick(
   RG   RO   R5   Rm   Rn   Ro  Rp  Rq  Rr  RX  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY   U  s
    			c         C` s6   d d |  j  |  j |  j |  j |  j |  j |  j f S(   Nu4   MPL MouseEvent: xy=(%d,%d) xydata=(%s,%s) button=%s u   dblclick=%s inaxes=%s(   Rm   Rn   Rg  Rh  Ro  Rr  R_  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   __str__a  s    N(   RH   RI   RT   R   Rm   Rn   Ro  Rr  R_  Rg  Rh  Rq  RA   RY   Rs  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRn  )  s   "t	   PickEventc           B` s   e  Z d  Z d d  Z RS(   u  
    a pick event, fired when the user picks a location on the canvas
    sufficiently close to an artist.

    Attrs: all the :class:`Event` attributes plus

    Attributes
    ----------
    mouseevent : `MouseEvent`
        the mouse event that generated the pick

    artist : `matplotlib.artist.Artist`
        the picked artist

    other
        extra class dependent attrs -- e.g., a
        :class:`~matplotlib.lines.Line2D` pick may define different
        extra attributes than a
        :class:`~matplotlib.collections.PatchCollection` pick event

    Examples
    --------
    Usage::

        ax.plot(np.rand(100), 'o', picker=5)  # 5 points tolerance

        def on_pick(event):
            line = event.artist
            xdata, ydata = line.get_data()
            ind = event.ind
            print('on pick line:', np.array([xdata[ind], ydata[ind]]).T)

        cid = fig.canvas.mpl_connect('pick_event', on_pick)

    c         K` s<   t  j |  | | |  | |  _ | |  _ |  j j |  d  S(   N(   RW  RY   t
   mouseeventt   artistt   __dict__t   update(   RG   RO   R5   Ru  Rv  RX  R/   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s    		N(   RH   RI   RT   R   RY   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRt  h  s   #t   KeyEventc           B` s    e  Z d  Z d d d d  Z RS(   u  
    A key event (key press, key release).

    Attach additional attributes as defined in
    :meth:`FigureCanvasBase.mpl_connect`.

    In addition to the :class:`Event` and :class:`LocationEvent`
    attributes, the following attributes are defined:

    Attributes
    ----------
    key : None or str
        the key(s) pressed. Could be **None**, a single case sensitive ascii
        character ("g", "G", "#", etc.), a special key
        ("control", "shift", "f1", "up", etc.) or a
        combination of the above (e.g., "ctrl+alt+g", "ctrl+alt+G").

    Notes
    -----
    Modifier keys will be prefixed to the pressed key and will be in the order
    "ctrl", "alt", "super". The exception to this rule is when the pressed key
    is itself a modifier key, therefore "ctrl+alt" and "alt+control" can both
    be valid key values.

    Examples
    --------
    Usage::

        def on_key(event):
            print('you pressed', event.key, event.xdata, event.ydata)

        cid = fig.canvas.mpl_connect('key_press_event', on_key)

    i    c         C` s,   t  j |  | | | | d | | |  _ d  S(   NRX  (   R^  RY   Rp  (   RG   RO   R5   Rp  Rm   Rn   RX  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s    N(   RH   RI   RT   R   RY   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRy    s   "t   FigureCanvasBasec           B` s  e  Z d  Z d d d d d d d d d	 d
 d d d d d g Z e Z dG Z e Z	 e
 r e d d d  e d d d  e d d d  e d d d  n  d   Z e d    Z d   Z e j d  d    Z d   Z dG d  Z d   Z d   Z d    Z dG d!  Z dG d"  Z dG d#  Z d$   Z dG d%  Z e dG d&  Z dG d'  Z dG d(  Z  dG d)  Z! dG dG d*  Z" e j d+  dG d,   Z# d-   Z$ d.   Z% d/   Z& d0   Z' d1   Z( d2   Z) e* d3    Z+ e* d4    Z, d5   Z- dG dG dG d6 dG d7  Z. e* d8    Z/ d9   Z0 d:   Z1 d;   Z2 d<   Z3 d=   Z4 d>   Z5 d?   Z6 d@   Z7 dA dB  Z8 dC   Z9 e j d+ dD dE e8  Z: e j d+ dD dF e9  Z; RS(H   u   
    The canvas the figure renders into.

    Public attributes

    Attributes
    ----------
    figure : `matplotlib.figure.Figure`
        A high-level figure instance

    u   resize_eventu
   draw_eventu   key_press_eventu   key_release_eventu   button_press_eventu   button_release_eventu   scroll_eventu   motion_notify_eventu
   pick_eventu
   idle_eventu   figure_enter_eventu   figure_leave_eventu   axes_enter_eventu   axes_leave_eventu   close_eventu   jpgu   matplotlib.backends.backend_aggu    Joint Photographic Experts Groupu   jpegu   tifu   Tagged Image File Formatu   tiffc         C` s   t  |  _ t |  _ | j |   | |  _ t j   |  _ t	 j
   |  _ d  |  _ d  |  _ d \ |  _ |  _ |  j d |  j  |  _ |  j d |  j  |  _ d  |  _ d  |  _ t |  _ d  S(   Nu   button_press_eventu   scroll_event(   NN(   RB   t   _is_idle_drawingRA   t
   _is_savingt
   set_canvasR4   R	   t   CallbackRegistryR:  R   t   LockDrawt
   widgetlockR   t   _buttont   _keyt   _lastxt   _lastyt   mpl_connectt   pickt   button_pick_idt   scroll_pick_idRa  t   toolbar(   RG   R4   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s    							c         c` s   t  |  _ d  Vt |  _ d  S(   N(   RB   R{  RA   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _idle_draw_cntx  s    	c         C` s   |  j  S(   u   
        Returns whether the renderer is in the process of saving
        to a file, rather than rendering for an on-screen buffer.
        (   R|  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   is_saving  s    u   2.2c         C` s   t  j |  j j |   } d } | r4 | d } n  x] | r | j   rW |  j   Pn  d } x* | D]" } | | j   k rd | } Pqd qd W| } q7 Wd S(   u   
        Mouse event processor which removes the top artist
        under the cursor.  Connect this to the 'mouse_press_event'
        using::

            canvas.mpl_connect('mouse_press_event',canvas.onRemove)
        iN(   R	   Rd  R4   t   hitlistR   RN  t	   draw_idlet   get_children(   RG   t   evt   underR   t   parentt   p(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   onRemove  s    
	
c         C` s&   |  j  j   s" |  j j |  n  d  S(   N(   R  t   lockedR4   R  (   RG   Ru  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  $  s    c         C` s   d S(   u0   Blit the canvas in bbox (default entire canvas).N(    (   RG   t   bbox(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   blit(  s    c         C` s   d S(   u   Set the canvas size in pixels.N(    (   RG   R   R   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   resize+  s    c         C` s/   d } t  | |  |  } |  j j | |  d S(   u@   Pass a `DrawEvent` to all functions connected to ``draw_event``.u
   draw_eventN(   RZ  R:  Rl  (   RG   R   RZ   t   event(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   draw_event.  s    c         C` s6   d } t  | |   } |  j j | |  |  j   d S(   uM   Pass a `ResizeEvent` to all functions connected to ``resize_event``.
        u   resize_eventN(   R[  R:  Rl  R  (   RG   RZ   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   resize_event4  s    c         C` sP   d } y, t  | |  d | } |  j j | |  Wn t t f k
 rK n Xd S(   uK   Pass a `CloseEvent` to all functions connected to ``close_event``.
        u   close_eventRX  N(   R]  R:  Rl  t	   TypeErrorR@   (   RG   RX  RZ   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   close_event<  s    c         C` sJ   | |  _  d } t | |  | |  j |  j d | } |  j j | |  d S(   uM   Pass a `KeyEvent` to all functions connected to ``key_press_event``.
        u   key_press_eventRX  N(   R  Ry  R  R  R:  Rl  (   RG   Rp  RX  RZ   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   key_press_eventK  s
    	!c         C` sJ   d } t  | |  | |  j |  j d | } |  j j | |  d |  _ d S(   uX   
        Pass a `KeyEvent` to all functions connected to ``key_release_event``.
        u   key_release_eventRX  N(   Ry  R  R  R:  Rl  R   R  (   RG   Rp  RX  RZ   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   key_release_eventT  s
    !c         K` s>   d } t  | |  | | d | j | } |  j j | |  d S(   u   
        This method will be called by artists who are picked and will
        fire off :class:`PickEvent` callbacks registered listeners
        u
   pick_eventRX  N(   Rt  RX  R:  Rl  (   RG   Ru  Rv  R/   RZ   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   pick_event^  s
    	c         C` sk   | d k r d |  _  n	 d |  _  d } t | |  | | |  j  |  j d | d | } |  j j | |  d S(   uI  
        Backend derived classes should call this function on any
        scroll wheel event.  x,y are the canvas coords: 0,0 is lower,
        left.  button and key are as defined in MouseEvent.

        This method will be call all functions connected to the
        'scroll_event' with a :class:`MouseEvent` instance.
        i    u   upu   downu   scroll_eventRq  RX  N(   R  Rn  R  R:  Rl  (   RG   Rm   Rn   Rq  RX  RZ   Ru  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   scroll_eventi  s    		c         C` sP   | |  _  d } t | |  | | | |  j d | d | } |  j j | |  d S(   uW  
        Backend derived classes should call this function on any mouse
        button press.  x,y are the canvas coords: 0,0 is lower, left.
        button and key are as defined in :class:`MouseEvent`.

        This method will be call all functions connected to the
        'button_press_event' with a :class:`MouseEvent` instance.
        u   button_press_eventRr  RX  N(   R  Rn  R  R:  Rl  (   RG   Rm   Rn   Ro  Rr  RX  RZ   Ru  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   button_press_event{  s
    		c      	   C` sJ   d } t  | |  | | | |  j d | } |  j j | |  d |  _ d S(   u  
        Backend derived classes should call this function on any mouse
        button release.

        This method will call all functions connected to the
        'button_release_event' with a :class:`MouseEvent` instance.

        Parameters
        ----------
        x : scalar
            the canvas coordinates where 0=left

        y : scalar
            the canvas coordinates where 0=bottom

        guiEvent
            the native UI event that generated the mpl event

        u   button_release_eventRX  N(   Rn  R  R:  Rl  R   R  (   RG   Rm   Rn   Ro  RX  RZ   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   button_release_event  s    $c      	   C` sW   | | |  _  |  _ d } t | |  | | |  j |  j d | } |  j j | |  d S(   u  
        Backend derived classes should call this function on any
        motion-notify-event.

        This method will call all functions connected to the
        'motion_notify_event' with a :class:`MouseEvent` instance.

        Parameters
        ----------
        x : scalar
            the canvas coordinates where 0=left

        y : scalar
            the canvas coordinates where 0=bottom

        guiEvent
            the native UI event that generated the mpl event

        u   motion_notify_eventRX  N(   R  R  Rn  R  R  R:  Rl  (   RG   Rm   Rn   RX  RZ   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   motion_notify_event  s
    	c         C` s5   |  j  j d t j  d t _ d \ |  _ |  _ d S(   u   
        Backend derived classes should call this function when leaving
        canvas

        Parameters
        ----------
        guiEvent
            the native UI event that generated the mpl event

        u   figure_leave_eventN(   NN(   R:  Rl  R^  Rk  R   R  R  (   RG   RX  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   leave_notify_event  s    	c         C` sW   | d k	 r. | \ } } | | |  _ |  _ n  t d |  |  } |  j j d |  d S(   uP  
        Backend derived classes should call this function when entering
        canvas

        Parameters
        ----------
        guiEvent
            the native UI event that generated the mpl event
        xy : tuple of 2 scalars
            the coordinate location of the pointer when the canvas is
            entered

        u   figure_enter_eventN(   R   R  R  RW  R:  Rl  (   RG   RX  t   xyRm   Rn   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   enter_notify_event  s
    u   2.1c         C` s2   d } t  | |  d | } |  j j | |  d S(   u   Called when GUI is idle.u
   idle_eventRX  N(   RY  R:  Rl  (   RG   RX  RZ   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   idle_event  s    c         C` s1   |  j  d | f k r$ t d   n  | |  _  d S(   u   
        Set the child axes which are currently grabbing the mouse events.
        Usually called by the widgets themselves.
        It is an error to call this if the mouse is already grabbed by
        another axes.
        u&   Another Axes already grabs mouse inputN(   Ra  R   t   RuntimeError(   RG   t   ax(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   grab_mouse  s    c         C` s   |  j  | k r d |  _  n  d S(   u   
        Release the mouse grab held by the axes, ax.
        Usually called by the widgets.
        It is ok to call this even if you ax doesn't have the mouse
        grab currently.
        N(   Ra  R   (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   release_mouse  s    c         O` s   d S(   u.   Render the :class:`~matplotlib.figure.Figure`.N(    (   RG   R.   R/   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw  s    c         O` s3   |  j  s/ |  j    |  j | |   Wd QXn  d S(   uW   
        :meth:`draw` only if idle; defaults to draw but backends can override
        N(   R{  R  R  (   RG   R.   R/   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    	c         C` s   d S(   u   
        Draw a cursor in the event.axes if inaxes is not None.  Use
        native GUI drawing for efficiency if possible
        N(    (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_cursor	  s    c         C` s(   t  |  j j j  t  |  j j j  f S(   u   
        Return the figure width and height in points or pixels
        (depending on the backend), truncated to integers
        (   RF  R4   R  R\  R   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR     s    c         C` s   |  j  S(   u=   Return dict of savefig file formats supported by this backend(   t	   filetypes(   R,   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_supported_filetypes  s    c         C` sT   i  } xG t  j |  j  D]3 \ } } | j | g   j |  | | j   q W| S(   u  Return a dict of savefig file formats supported by this backend,
        where the keys are a file type name, such as 'Joint Photographic
        Experts Group', and the values are a list of filename extensions used
        for that filetype, such as ['jpg', 'jpeg'].(   R    t	   iteritemsR  t
   setdefaultRq   t   sort(   R,   t	   groupingst   extRO   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_supported_filetypes_grouped  s
    c         C` sm   d | } t  |  |  r |  St |  } | r< |  j |  St d j | d j t |  j        d S(   u   
        Return a canvas suitable for saving figures to a specified file format.

        If necessary, this function will switch to a registered backend that
        supports the format.
        u   print_%su4   Format {!r} is not supported (supported formats: {})u   , N(   t   hasattrR&   t   switch_backendsR  R   t   joint   sortedR  (   RG   t   fmtt   method_namet   canvas_class(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _get_output_canvas'  s    
u   portraitc         K` s  t  |  _ t   } t |  d  r3 |  j }	 |  ` n | }	 | d k r t | t t d d   rr t j	 |  } n  t | t
 j  r t j j |  d d } n  | d k s | d k r |  j   } t | t
 j  r | j d  d | } q q n  | j   } |  j |  }
 t |
 d |  } | d k r>t d } n  | d k rht |  j d	 |  j j  } n  | d k rt d
 } n  | d k rt d } n  |  j j } |  j j   } |  j j   } | |  j _ |  j j |  |  j j |  | j d d  } | d k rt d } n  | rT| d k r*| t j   d | d | d | d | d t  | } |  j j } |  j j |  } | j d d  } | d k r|  j j   } n  g  } x | D] } | j |  } | j    rW| j!   } | d k	 r	t" j# | |  } n  | j$   } | d k	 rW| d k	 rW| j%   } t" j# | | j&    } qWn  | d k	 r| j' d k s| j( d k r| j) |  qqW| rt" j* |  } t+   j, d |  j j  } t- | |  } t" j* | | g  } n  | j d d  } | d k rt d } n  | j. |  } n  t/ j0 |  j | |
 j1  } | | f } n d } z1 | | d | d | d | d | d | | } Wd | r| r|   n  | |  j _ |  j j |  |  j j |  |  j j2 |   |	 | k	 r|	 |  _ n  t3 |  _ X| S(   u	  
        Render the figure to hardcopy. Set the figure patch face and edge
        colors.  This is useful because some of the GUIs have a gray figure
        face color background and you'll probably want to override this on
        hardcopy.

        Parameters
        ----------
        filename
            can also be a file object on image backends

        orientation : {'landscape', 'portrait'}, optional
            only currently applies to PostScript printing.

        dpi : scalar, optional
            the dots per inch to save the figure in; if None, use savefig.dpi

        facecolor : color spec or None, optional
            the facecolor of the figure; if None, defaults to savefig.facecolor

        edgecolor : color spec or None, optional
            the edgecolor of the figure; if None, defaults to savefig.edgecolor

        format : str, optional
            when set, forcibly set the file format to save to

        bbox_inches : str or `~matplotlib.transforms.Bbox`, optional
            Bbox in inches. Only the given portion of the figure is
            saved. If 'tight', try to figure out the tight bbox of
            the figure. If None, use savefig.bbox

        pad_inches : scalar, optional
            Amount of padding around the figure when bbox_inches is
            'tight'. If None, use savefig.pad_inches

        bbox_extra_artists : list of `~matplotlib.artist.Artist`, optional
            A list of extra artists that will be considered when the
            tight bbox is calculated.

        u   manageru   PathLikei   u    u   .u   print_%su   savefig.dpiu   figureu   _original_dpiu   savefig.facecoloru   savefig.edgecoloru   bbox_inchesu   savefig.bboxu   tightR   t	   facecolort	   edgecolort   orientationt   dryrunu   bbox_extra_artistsi    g      ?u
   pad_inchesu   savefig.pad_inchest   bbox_inches_restoreN(    (4   RB   R|  t   objectR  R6   R   R   RM   t   ost   fspathR    R!   R`   t   splitextt   get_default_filetypet   rstript   lowerR  R   R4   R   t   get_facecolort   get_edgecolort   set_facecolort   set_edgecolorR*   t   iot   BytesIOt   _cachedRenderert   get_tightbboxt   get_default_bbox_extra_artistst   get_window_extentt   get_clip_ont   get_clip_boxR   t   intersectionR
  t   get_fully_transformed_patht   get_extentsR\  R   Rq   t   unionR   R   R   t   paddedR   t   adjust_bboxt	   fixed_dpiR}  RA   (   RG   t   filenameR   R  R  R  R   R/   t   _no_managerR6   R5   t   print_methodt   origDPIt   origfacecolort   origedgecolort   bbox_inchest   resultR   t   bbox_artistst   bbox_filteredRi  R  t   clip_boxt	   clip_patht   _bboxRj   t
   bbox_extrat   padt   restore_bboxt   _bbox_inches_restore(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   print_figure;  s    *				 		

c         C` s   t  d S(   u   
        Get the default savefig file format as specified in rcParam
        ``savefig.format``. Returned string excludes period. Overridden
        in backends that only support a single file type.
        u   savefig.format(   R   (   R,   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    c         C` s    t  |  d  r |  j j   Sd S(   u   
        Get the title text of the window containing the figure.
        Return None if there is no window (e.g., a PS backend).
        u   managerN(   R  R6   t   get_window_title(   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    c         C` s&   t  |  d  r" |  j j |  n  d S(   u   
        Set the title text of the window containing the figure.  Note that
        this has no effect if there is no window (e.g., a PS backend).
        u   managerN(   R  R6   t   set_window_title(   RG   t   title(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    c         C` s   |  j    p d } | j d d  } |  j   } | d | } t j j t d  } d } xD t j j t j j | |   r d j	 | | |  } | d 7} q] W| S(   ul   
        Return a string, which includes extension, suitable for use as
        a default filename.
        u   imageu    u   _u   .u   savefig.directoryi   u   {}-{}.{}(
   R  t   replaceR  R  R`   t
   expanduserR   t   isfileR  R   (   RG   t   default_basenamet   default_filetypet   default_filenamet   save_dirR   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   get_default_filename  s    $c         C` s   | |  j   } |  j | _ | S(   uS  
        Instantiate an instance of FigureCanvasClass

        This is used for backend switching, e.g., to instantiate a
        FigureCanvasPS from a FigureCanvasGTK.  Note, deep copying is
        not done, so any changes to one of the instances (e.g., setting
        figure size or line props), will be reflected in the other
        (   R4   R|  (   RG   t   FigureCanvasClasst	   newCanvas(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  	  s    	c         C` s2   | d k r t  j d d  n  |  j j | |  S(   u  
        Connect event with string *s* to *func*.  The signature of *func* is::

          def func(event)

        where event is a :class:`matplotlib.backend_bases.Event`.  The
        following events are recognized

        - 'button_press_event'
        - 'button_release_event'
        - 'draw_event'
        - 'key_press_event'
        - 'key_release_event'
        - 'motion_notify_event'
        - 'pick_event'
        - 'resize_event'
        - 'scroll_event'
        - 'figure_enter_event',
        - 'figure_leave_event',
        - 'axes_enter_event',
        - 'axes_leave_event'
        - 'close_event'

        For the location events (button and key press/release), if the
        mouse is over the axes, the variable ``event.inaxes`` will be
        set to the :class:`~matplotlib.axes.Axes` the event occurs is
        over, and additionally, the variables ``event.xdata`` and
        ``event.ydata`` will be defined.  This is the mouse location
        in data coords.  See
        :class:`~matplotlib.backend_bases.KeyEvent` and
        :class:`~matplotlib.backend_bases.MouseEvent` for more info.

        Return value is a connection id that can be used with
        :meth:`~matplotlib.backend_bases.Event.mpl_disconnect`.

        Examples
        --------
        Usage::

            def on_press(event):
                print('you pressed', event.button, event.xdata, event.ydata)

            cid = canvas.mpl_connect('button_press_event', on_press)

        u
   idle_eventg      ?u|   idle_event is only implemented for the wx backend, and will be removed in matplotlib 2.1. Use the animations module instead.(   R	   t   warn_deprecatedR:  t   connect(   RG   RZ   RL  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  !	  s    .	
c         C` s   |  j  j |  S(   u   
        Disconnect callback id cid

        Examples
        --------
        Usage::

            cid = canvas.mpl_connect('button_press_event', on_press)
            #...later
            canvas.mpl_disconnect(cid)
        (   R:  t
   disconnect(   RG   t   cid(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   mpl_disconnectW	  s    c         O` s   t  | |   S(   u  
        Creates a new backend-specific subclass of
        :class:`backend_bases.Timer`. This is useful for getting periodic
        events through the backend's native event loop. Implemented only for
        backends with GUIs.

        Other Parameters
        ----------------
        interval : scalar
            Timer interval in milliseconds

        callbacks : List[Tuple[callable, Tuple, Dict]]
            Sequence of (func, args, kwargs) where ``func(*args, **kwargs)``
            will be executed by the timer every *interval*.

            callbacks which return ``False`` or ``0`` will be removed from the
            timer.

        Examples
        --------

        >>> timer = fig.canvas.new_timer(callbacks=[(f1, (1, ), {'a': 3}),])

        (   R9  (   RG   R.   R/   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt	   new_timere	  s    c         C` s   d S(   ul   Flush the GUI events for the figure.

        Interactive backends need to reimplement this method.
        N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   flush_events	  s    i    c         C` sr   | d k r t  j } n  d } d } t |  _ x> |  j rm | | | k  rm |  j   t j |  | d 7} q0 Wd S(   u#  Start a blocking event loop.

        Such an event loop is used by interactive functions, such as `ginput`
        and `waitforbuttonpress`, to wait for events.

        The event loop blocks until a callback function triggers
        `stop_event_loop`, or *timeout* is reached.

        If *timeout* is negative, never timeout.

        Only interactive backends need to reimplement this method and it relies
        on `flush_events` being properly implemented.

        Interactive backends should implement this in a more native way.
        i    g{Gz?i   N(   R   t   infRB   t   _loopingR  t   timet   sleep(   RG   t   timeoutt   timestept   counter(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   start_event_loop	  s    	
c         C` s   t  |  _ d S(   u   Stop the current blocking event loop.

        Interactive backends need to reimplement this to match
        `start_event_loop`
        N(   RA   R  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   stop_event_loop	  s    RO   u   start_event_loop_defaultu   stop_event_loop_defaultN(<   RH   RI   RT   t   eventsRB   t   supports_blitR   R  R   R  t   _has_pilR   RY   R   R  R  R	   R8  R  R  R  R  R  R  R  R  R  R  R  RA   R  R  R  R  R  R  R  R  R  R  R  R   RQ   R  R  R  R  R  R  R  R  R  R  R   R  R  R
  R  t   start_event_loop_defaultt   stop_event_loop_default(    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRz    s   					
							
			
												6				c         C` sS  |  j  d k r d St d } t d } t d } t d } t d } t d } t d }	 t d	 }
 t d
 } t d } t d } t d } t d } |  j  | k r y | j j   Wq t k
 r q Xn  |  j  |
 k r t j | j  n  | d k	 r|  j  | k r| j	   q|  j  | k r2| j
   q|  j  | k rN| j   q|  j  | k rw| j   | j |   q|  j  | k r| j   | j |   q|  j  |	 k r| j   qn  |  j d k rd Sd   } |  j } |  j  | k rd | | j j  | | j j  g k r| | j j  } | | j j  } t t f t t f t t f t t f g } y1 | | j | | f  d t |  \ } } Wn t k
 rqX| j | d | rd n d d d | j | d | rd n d d d | j   n  |  j  | k rd | | j j  | | j j  g k r| | j j  } | | j j  } t t f t t f t t f t t f g } y1 | | j | | f  d t |  \ } } Wn t k
 rqOX| j | d d d d | j | d d d d | j   n=|  j  | k r| j   } | d k rY| j d  | j j j   qO| d k rOy | j d  Wn3 t k
 r} t j  t! |   | j d  n X| j j j   qOn|  j  | k rr| j"   } | d k r	| j# d  | j j j   qO| d k rOy | j# d  Wn3 t k
 r[} t j  t! |   | j# d  n X| j j j   qOn |  j  j$   r|  j  d k s|  j  | k rO|  j  | k rt% |  j   d } n  x t& | j j'    D]n \ } } |  j( d k	 r|  j) d k	 r| j* |   r|  j  | k r2| j+ t  qH| j+ | | k  qqWn  d S(   uz  
    Implement the default mpl key bindings for the canvas and toolbar
    described at :ref:`key-event-handling`

    Parameters
    ----------
    event : :class:`KeyEvent`
        a key press/release event
    canvas : :class:`FigureCanvasBase`
        the backend-specific canvas instance
    toolbar : :class:`NavigationToolbar2`
        the navigation cursor toolbar

    Nu   keymap.fullscreenu   keymap.homeu   keymap.backu   keymap.forwardu
   keymap.panu   keymap.zoomu   keymap.saveu   keymap.quitu   keymap.gridu   keymap.grid_minoru   keymap.yscaleu   keymap.xscaleu   keymap.all_axesc         S` s<   t  d   |  D  r t St d   |  D  s4 t Sd  Sd  S(   Nc         s` s   |  ] } | j  Vq d  S(   N(   t   gridOn(   t   .0t   tick(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pys	   <genexpr>	  s    c         s` s   |  ] } | j  Vq d  S(   N(   R  (   R  R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pys	   <genexpr>	  s    (   t   allRB   R  RA   R   (   t   ticks(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _get_uniform_gridstate	  s
    i   t   whichu   majoru   botht   axisu   xu   yu   logu   linearu   0(,   Rp  R   R   R6   t   full_screen_toggleR@   R   t   destroy_figR4   t   homet   backt   forwardt   pant   _set_cursort   zoomt   save_figureR_  t   xaxist
   minorTickst   yaxist
   majorTicksRA   RB   RO  Rf   R  t   gridR  t
   get_yscalet
   set_yscaleR5   t   warningst   warnt   strt
   get_xscalet
   set_xscalet   isdigitRF  t	   enumerateRb  Rm   Rn   Rc  t   set_navigate(   R  R5   R  t   fullscreen_keyst	   home_keyst	   back_keyst   forward_keyst   pan_keyst	   zoom_keyst	   save_keyst	   quit_keyst	   grid_keyst   grid_minor_keyst   toggle_yscale_keyst   toggle_xscale_keyst   all_keysR  R  t   x_statet   y_statet   cycleR   t   exct   scalext   nR   Ri  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   key_press_handler	  s    














	
	*1%%*1-"t   NonGuiExceptionc           B` s   e  Z RS(    (   RH   RI   (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRE  V
  s   t   FigureManagerBasec           B` sn   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z e	 j
 d  d    Z d	   Z d
   Z RS(   u  
    Helper class for pyplot mode, wraps everything up into a neat bundle

    Attributes
    ----------
    canvas : :class:`FigureCanvasBase`
        The backend-specific canvas instance

    num : int or str
        The figure number

    key_press_handler_id : int
        The default key handler cid, when using the toolmanager.  Can be used
        to disable default key press handling ::

            figure.canvas.mpl_disconnect(
                figure.canvas.manager.key_press_handler_id)
    c         C` sV   | |  _  |  | _ | |  _ d  |  _ t d d k rR |  j  j d |  j  |  _ n  d  S(   Nu   toolbaru   toolmanageru   key_press_event(   R5   R6   R-   R   t   key_press_handler_idR   R  t	   key_press(   RG   R5   R-   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY   m
  s    					c         C` s   t     d S(   u   
        For GUI backends, show the figure window and redraw.
        For non-GUI backends, raise an exception to be caught
        by :meth:`~matplotlib.figure.Figure.show`, for an
        optional warning.
        N(   RE  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR=   x
  s    c         C` s   d  S(   N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   destroy
  s    c         C` s   d  S(   N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  
  s    c         C` s   d S(   u1   "For GUI backends, resize the window (in pixels).N(    (   RG   R   R   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  
  s    c         C` s0   t  d d k r, t | |  j |  j j  n  d S(   ue   
        Implement the default mpl key bindings defined at
        :ref:`key-event-handling`
        u   toolbaru   toolmanagerN(   R   RD  R5   R  (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRH  
  s    u   2.2c         C` s   d S(   u'   Display message in a popup -- GUI only.N(    (   RG   t   msg(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   show_popup
  s    c         C` s   d S(   uv   Get the title text of the window containing the figure.

        Return None for non-GUI (e.g., PS) backends.
        u   image(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  
  s    c         C` s   d S(   u}   Set the title text of the window containing the figure.

        This has no effect for non-GUI (e.g., PS) backends.
        N(    (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  
  s    (   RH   RI   RT   RY   R=   RI  R  R  RH  R	   R8  RK  R  R  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRF  Z
  s   								t   NavigationToolbar2c           B` sR  e  Z d  Z d; d< d= d? d@ dA dB dC dD f	 Z d   Z d   Z d   Z e j	 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 d0   Z d1   Z d2   Z d3   Z d4   Z d5   Z d6   Z  d7   Z! d8   Z" d9   Z# d:   Z$ RS(E   u%  
    Base class for the navigation cursor, version 2

    backends must implement a canvas that handles connections for
    'button_press_event' and 'button_release_event'.  See
    :meth:`FigureCanvasBase.mpl_connect` for more information


    They must also define

      :meth:`save_figure`
         save the current figure

      :meth:`set_cursor`
         if you want the pointer icon to change

      :meth:`_init_toolbar`
         create your toolbar widget

      :meth:`draw_rubberband` (optional)
         draw the zoom to rect "rubberband" rectangle

      :meth:`press`  (optional)
         whenever a mouse button is pressed, you'll be notified with
         the event

      :meth:`release` (optional)
         whenever a mouse button is released, you'll be notified with
         the event

      :meth:`set_message` (optional)
         display message

      :meth:`set_history_buttons` (optional)
         you can change the history back / forward buttons to
         indicate disabled / enabled state.

    That's it, we'll do the rest!
    u   Homeu   Reset original viewu   homeu   Backu   Back to  previous viewu   backu   Forwardu   Forward to next viewu   forwardu   Panu)   Pan axes with left mouse, zoom with rightu   moveu   panu   Zoomu   Zoom to rectangleu   zoom_to_rectu   zoomu   Subplotsu   Configure subplotsu   subplotsu   configure_subplotsu   Saveu   Save the figureu   filesaveu   save_figurec         C` s   | |  _  |  | _ t j   |  _ d  |  _ d  |  _ d  |  _ d  |  _	 t
 j |  _ |  j   |  j  j d |  j  |  _ g  |  _ d  |  _ d  |  _ d |  _ |  j   d  S(   Nu   motion_notify_eventu    (   R5   R  R	   t   Stackt
   _nav_stackR   t   _xypresst   _idPresst
   _idReleaset   _activet   cursorst   POINTERt   _lastCursort   _init_toolbarR  t
   mouse_movet   _idDragt	   _ids_zoomt
   _zoom_modet   _button_pressedt   modet   set_history_buttons(   RG   R5   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY   
  s     						
					c         C` s   d S(   u.   Display a message on toolbar or in status bar.N(    (   RG   RZ   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   set_message
  s    c         G` s%   |  j  j   |  j   |  j   d S(   u   move back up the view lim stackN(   RN  R  R]  t   _update_view(   RG   R.   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  
  s    
u   2.1t   alternativeu   canvas.draw_idlec         C` s   |  j  j   d  S(   N(   R5   R  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   dynamic_update  s    c         C` s   d S(   u   Draw a rectangle rubberband to indicate zoom limits.

        Note that it is not guaranteed that ``x0 <= x1`` and ``y0 <= y1``.
        N(    (   RG   R  t   x0t   y0t   x1t   y1(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   draw_rubberband  s    c         C` s   d S(   u   Remove the rubberband.N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   remove_rubberband  s    c         G` s%   |  j  j   |  j   |  j   d S(   u#   Move forward in the view lim stack.N(   RN  R  R]  R_  (   RG   R.   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    
c         G` s%   |  j  j   |  j   |  j   d S(   u   Restore the original view.N(   RN  R  R]  R_  (   RG   R.   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    
c         C` s
   t   d S(   u  
        This is where you actually build the GUI widgets (called by
        __init__).  The icons ``home.xpm``, ``back.xpm``, ``forward.xpm``,
        ``hand.xpm``, ``zoom_to_rect.xpm`` and ``filesave.xpm`` are standard
        across backends (there are ppm versions in CVS also).

        You just need to set the callbacks

        home         : self.home
        back         : self.back
        forward      : self.forward
        hand         : self.pan
        zoom_to_rect : self.zoom
        filesave     : self.save_figure

        You only need to define the last one - the others are in the base
        class implementation.

        N(   R^   (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRV    s    c         C` s   | j  s |  j rH |  j t j k r |  j t j  t j |  _ q n |  j d k r |  j t j k r |  j t j  t j |  _ n@ |  j d k r |  j t j k r |  j t j  t j |  _ n  d  S(   Nu   ZOOMu   PAN(   R_  RR  RU  RS  RT  t
   set_cursort   SELECT_REGIONt   MOVE(   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  3  s    c         C` sJ  |  j  |  | j r6| j j   r6y | j j | j | j  } Wn t t f k
 r] qFXg  | j j D]' } | j	 |  rk | j
   rk | ^ qk } | r t j |  } | | j j k	 r | j |  } | d  k	 r | d | j |  7} q q n  t |  j  r&|  j d |  j | f  qF|  j |  n |  j |  j  d  S(   Nu    [%s]u   %s, %s(   R  R_  t   get_navigatet   format_coordRg  Rh  R  t   OverflowErrort   mouseover_sett   containst   get_visibleR	   Rd  t   patcht   get_cursor_dataR   t   format_cursor_dataRf   R\  R^  (   RG   R  RZ   Ri  t   artistst   data(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRW  B  s$    ' c         G` s9  |  j  d k r d |  _  n	 d |  _  |  j d k	 rW |  j j |  j  |  _ d |  _ n  |  j d k	 r |  j j |  j  |  _ d |  _ n  |  j  r |  j j d |  j  |  _ |  j j d |  j	  |  _ d |  _ |  j j
 |   n |  j j
 j |   x* |  j j j   D] } | j |  j   qW|  j |  j  d S(   uA   Activate the pan/zoom tool. pan with left button, zoom with rightu   PANu    u   button_press_eventu   button_release_eventu   pan/zoomN(   RR  R   RP  R5   R   R\  RQ  R  t	   press_pant   release_panR  t   releaseR4   Rb  t   set_navigate_modeR^  (   RG   R.   Ri  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  ]  s(    					c         C` s   d S(   u*   Called whenever a mouse button is pressed.N(    (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   press}  s    c         C` sT  | j  d k r d |  _ n( | j  d k r6 d |  _ n d |  _ d S|  j   d k rb |  j   n  | j | j } } g  |  _ x t |  j	 j
 j    D] \ } } | d k	 r | d k	 r | j |  r | j   r | j   r | j | | | j   |  j j | | f  |  j	 j |  j  |  j	 j d |  j  |  _ q q W|  j |  d S(   u1   Callback for mouse button press in pan/zoom mode.i   i   Nu   motion_notify_event(   Ro  R[  R   RN  t   push_currentRm   Rn   RO  R/  R5   R4   Rb  Rc  Rk  t   can_pant	   start_panRq   R   RX  R  t   drag_panRz  (   RG   R  Rm   Rn   R   Ri  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRv    s&    		%'c   
      C` s  |  j  g  k ri x! |  j  D] } |  j j |  q W|  j |  |  j   d |  _ d |  _ g  |  _  d S| j d k r d |  _ n( | j d k r d |  _ n d |  _ d S|  j	   d k r |  j
   n  | j | j } } g  |  _ x t |  j j j    D]s \ } } | d k	 r | d k	 r | j |  r | j   r | j   r |  j j | | | | | j   f  q q W|  j j d |  j  } |  j j d |  j  } |  j j d |  j  }	 | | |	 f |  _  | j |  _ |  j |  d S(   u5   Callback for mouse button press in zoom to rect mode.Ni   i   u   motion_notify_eventu   key_press_eventu   key_release_event(   RY  R5   R   Rx  R  R   RO  R[  Ro  RN  R{  Rm   Rn   R/  R4   Rb  Rc  Rk  t   can_zoomRq   t	   _get_viewR  t	   drag_zoomt   _switch_on_zoom_modet   _switch_off_zoom_modeRp  RZ  Rz  (
   RG   R  t   zoom_idRm   Rn   R   Ri  t   id1t   id2t   id3(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt
   press_zoom  s>    
					%',c         C` s   | j  |  _ |  j |  d  S(   N(   Rp  RZ  RW  (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    c         C` s   d  |  _ |  j |  d  S(   N(   R   RZ  RW  (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    	c         C` s7   |  j  j t d   |  j j j D   |  j   d S(   u9   Push the current view limits and position onto the stack.c         S` sF   i  |  ]< } | j    | j t  j   | j   j   f f |  q S(    (   R  t   get_positionRB   R   (   R  R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pys
   <dictcomp>  s   	N(   RN  t   pushR   R5   R4   t   axesR]  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR{    s
    	c         C` s   d S(   u"   Callback for mouse button release.N(    (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRx    s    c         C` s   |  j  d k r d S|  j j |  j  |  j j d |  j  |  _ x! |  j D] \ } } | j   qK W|  j sr d Sg  |  _ d |  _  |  j	   |  j
 |  |  j   d S(   u3   Callback for mouse button release in pan/zoom mode.Nu   motion_notify_event(   R[  R   R5   R   RX  R  RW  RO  t   end_panR{  Rx  R  (   RG   R  Ri  t   ind(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRw    s    				
c         C` sM   x9 |  j  D]. \ } } | j |  j | j | j | j  q
 W|  j j   d S(   u'   Callback for dragging in pan/zoom mode.N(   RO  R~  R[  Rp  Rm   Rn   R5   R  (   RG   R  Ri  R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR~    s    &c         C` s   |  j  r | j | j } } |  j  d \ } } } } } t j | | g | | g g | j j | j j  \ \ }	 }
 \ } } |  j d k r | j j	 \ }
 } n$ |  j d k r | j j
 \ }	 } n  |  j | |	 |
 | |  n  d S(   u#   Callback for dragging in zoom mode.i    u   xu   yN(   RO  Rm   Rn   R   t   clipR  t   minR   RZ  t	   intervalyt	   intervalxRf  (   RG   R  Rm   Rn   t   lastxt   lastyRi  R  t   viewRd  Re  t   x2t   y2(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    	?c         C` s  x! |  j  D] } |  j j |  q
 Wg  |  _  |  j   |  j sD d Sg  } xx|  j D]m} | j | j } } | \ } } }	 }
 } t | |  d k  r |  j d k s t | |  d k  r |  j d k r d |  _ |  j
 |  |  j   d St t } } | rYxS | D]H } |	 j   j |	 |  r1t } n  |	 j   j |	 |  r
t } q
q
Wn  | j |	  |  j d k r~d } n |  j d k rT d } n qT |	 j | | | | f | |  j | |  qT W|  j   d |  _ d |  _ d |  _ |  j   |  j
 |  d S(	   u7   Callback for mouse button release in zoom to rect mode.Ni   u   yu   xi   u   ini   u   out(   RY  R5   R   Rg  RO  Rm   Rn   t   absRZ  R   Rx  R  RA   t   get_shared_x_axest   joinedRB   t   get_shared_y_axesRq   R[  t   _set_view_from_bboxR{  (   RG   R  R  t   last_at   cur_xypressRm   Rn   R  R  Ri  R  R  t   twinxt   twinyt   lat	   direction(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   release_zoom  sJ    	
	%%	
			
			
c         C` s   x |  j  j j   D] } t | d d  } t | d d  } g  } | d k	 rx | j | j    | j | j    n  | d k	 r | j | j    | j | j    n  x | D] } | j   q Wq W|  j  j	   d S(   u)   Redraw the canvases, update the locators.u   xaxisu   yaxisN(
   R5   R4   Rb  RM   R   Rq   t   get_major_locatort   get_minor_locatort   refreshR  (   RG   Ri  R"  R$  t   locatorst   loc(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  <  s    c         C` s   |  j    } | d k r d St | j    } xM | D]E \ } \ } \ } } | j |  | j | d  | j | d  q5 W|  j j   d S(   u`   Update the viewlim and position from the view and
        position stack for each axes.
        Nu   originalu   active(   RN  R   t   listt   itemst	   _set_viewt   _set_positionR5   R  (   RG   t   nav_infoR  R  R  t   pos_origt
   pos_active(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR_  M  s    c         G` s
   t   d S(   u   Save the current figure.N(   R^   (   RG   R.   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR!  ^  s    c         C` s   d S(   uC  Set the current cursor to one of the :class:`Cursors` enums values.

        If required by the backend, this method should trigger an update in
        the backend event loop after the cursor is set, as this method may be
        called e.g. before a long-running task during which the GUI is not
        updated.
        N(    (   RG   t   cursor(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRh  b  s    c         C` s   |  j  j   |  j   d S(   u   Reset the axes stack.N(   RN  t   clearR]  (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRx  k  s    c         G` s9  |  j  d k r d |  _  n	 d |  _  |  j d k	 rW |  j j |  j  |  _ d |  _ n  |  j d k	 r |  j j |  j  |  _ d |  _ n  |  j  r |  j j d |  j  |  _ |  j j d |  j	  |  _ d |  _ |  j j
 |   n |  j j
 j |   x* |  j j j   D] } | j |  j   qW|  j |  j  d S(   u   Activate zoom to rect mode.u   ZOOMu    u   button_press_eventu   button_release_eventu	   zoom rectN(   RR  R   RP  R5   R   R\  RQ  R  R  R  R  Rx  R4   Rb  Ry  R^  (   RG   R.   Ri  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR   p  s(    			c         C` s   d S(   u*   Enable or disable the back/forward button.N(    (   RG   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR]    s    (   u   Homeu   Reset original viewu   homeu   home(   u   Backu   Back to  previous viewu   backu   back(   u   Forwardu   Forward to next viewu   forwardu   forwardN(   NNNN(   u   Panu)   Pan axes with left mouse, zoom with rightu   moveu   pan(   u   Zoomu   Zoom to rectangleu   zoom_to_rectu   zoom(   u   Subplotsu   Configure subplotsu   subplotsu   configure_subplots(   NNNN(   u   Saveu   Save the figureu   filesaveu   save_figure(%   RH   RI   RT   R   t	   toolitemsRY   R^  R  R	   R8  Ra  Rf  Rg  R  R  RV  R  RW  R  Rz  Rv  R  R  R  R{  Rx  Rw  R~  R  R  R  R_  R!  Rh  Rx  R   R]  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRL  
  sP   '
												 			,								7							t   ToolContainerBasec           B` sh   e  Z d  Z d Z d   Z d   Z d d  Z d   Z d   Z d   Z	 d	   Z
 d
   Z d   Z RS(   u   
    Base class for all tool containers, e.g. toolbars.

    Attributes
    ----------
    toolmanager : `ToolManager`
        The tools with which this `ToolContainer` wants to communicate.
    u   .pngc         C` s#   | |  _  |  j  j d |  j  d  S(   Nu   tool_removed_event(   t   toolmanagert   toolmanager_connectt   _remove_tool_cbk(   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY     s    	c         C` s    |  j  | j j | j j  d S(   uc   
        Captures the 'tool_trigger_[name]'

        This only gets used for toggled tools
        N(   t   toggle_toolitemt   toolRO   t   toggled(   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   _tool_toggled_cbk  s    ic         C` s   |  j  j |  } |  j | j  } t | d d  d k	 } |  j | j | | | | j |  | r |  j  j	 d | j |  j
  | j r |  j | j t  q n  d S(   ue  
        Adds a tool to this container

        Parameters
        ----------
        tool : tool_like
            The tool to add, see `ToolManager.get_tool`.
        group : str
            The name of the group to add this tool to.
        position : int (optional)
            The position within the group to place this tool.  Defaults to end.
        u   toggledu   tool_trigger_%sN(   R  t   get_toolt   _get_image_filenamet   imageRM   R   t   add_toolitemRO   R   R  R  R  R  RB   (   RG   R  t   groupt   positionR  t   toggle(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   add_tool  s    
	c         C` s   |  j  | j j  d S(   u>   Captures the 'tool_removed_event' signal and removes the tool.N(   t   remove_toolitemR  RO   (   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    c         C` s   | s
 d St j j t d d  } | | |  j t j j | |  t j j | |  |  j f } x$ | D] } t j j |  rh | Sqh Wd S(   u!   Find the image based on its name.u   datapathu   imagesN(   R   R  R`   R  R   t   _icon_extensionR  (   RG   R  t   basedirt   possible_imagest   fname(    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    
c         C` s   |  j  j | d |  d S(   u   
        Trigger the tool

        Parameters
        ----------
        name : String
            Name (id) of the tool triggered from within the container
        t   senderN(   R  t   trigger_tool(   RG   RO   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    	c         C` s
   t   d S(   u  
        Add a toolitem to the container

        This method must get implemented per backend

        The callback associated with the button click event,
        must be **EXACTLY** `self.trigger_tool(name)`

        Parameters
        ----------
        name : string
            Name of the tool to add, this gets used as the tool's ID and as the
            default label of the buttons
        group : String
            Name of the group that this tool belongs to
        position : Int
            Position of the tool within its group, if -1 it goes at the End
        image_file : String
            Filename of the image for the button or `None`
        description : String
            Description of the tool, used for the tooltips
        toggle : Bool
            * `True` : The button is a toggle (change the pressed/unpressed
              state between consecutive clicks)
            * `False` : The button is a normal button (returns to unpressed
              state after release)
        N(   R^   (   RG   RO   R  R  R  R   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    c         C` s
   t   d S(   u   
        Toggle the toolitem without firing event

        Parameters
        ----------
        name : String
            Id of the tool to toggle
        toggled : bool
            Whether to set this tool as toggled or not.
        N(   R^   (   RG   RO   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    c         C` s
   t   d S(   u  
        Remove a toolitem from the `ToolContainer`

        This method must get implemented per backend

        Called when `ToolManager` emits a `tool_removed_event`

        Parameters
        ----------
        name : string
            Name of the tool to remove
        N(   R^   (   RG   RO   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s    (   RH   RI   RT   R  RY   R  R  R  R  R  R  R  R  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR    s   							t   StatusbarBasec           B` s)   e  Z d  Z d   Z d   Z d   Z RS(   u   Base class for the statusbarc         C` s#   | |  _  |  j  j d |  j  d  S(   Nu   tool_message_event(   R  R  t   _message_cbk(   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyRY   %  s    	c         C` s   |  j  | j  d S(   u5   Captures the 'tool_message_event' and set the messageN(   R^  t   message(   RG   R  (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  *  s    c         C` s   d S(   u   
        Display a message on toolbar or in status bar

        Parameters
        ----------
        s : str
            Message text
        N(    (   RG   RZ   (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR^  .  s    	(   RH   RI   RT   RY   R  R^  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyR  #  s   		(O   RT   t
   __future__R    R   R   R   R    t	   six.movesR   t
   contextlibR   t	   functoolsR   R"   R  R  RK   R  R)  t   weakrefR   t   numpyR   R>   R   t   toolsR	   R
   R   R   R   R   R   R   R   t   matplotlib._pylab_helpersR   t   matplotlib.transformsR   R   R   t   matplotlib.pathR   t   PILR   RB   R  t   ImportErrorRA   R   R   R   R   R&   R  R'   RN   RU   R   R9  RW  R8  RY  RZ  R[  R]  R^  Rn  Rt  Ry  Rz  RD  t	   ExceptionRE  RF  RS  RL  R  R  (    (    (    s7   lib/python2.7/site-packages/matplotlib/backend_bases.pyt   <module>!   s   "F


	g  [ 	e?,(  J	 