ó
±éRc           @  sÇ  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l j	 Z
 d d l j Z d d l j Z d d l j Z d d l j Z d d l j Z d d l j Z d d l j Z d d l j Z d d l j Z d d l j  Z  d d l! j" Z# d d l m$ Z$ d Z% d Z& d e% e& f Z' e$ j( j) d e' ƒ d	 „  Z* d
 e j+ f d „  ƒ  YZ, d e, f d „  ƒ  YZ- e$ j. e% ƒ e/ e/ d d d d „ ƒ Z0 e$ j. e% ƒ d „  ƒ Z1 d e- f d „  ƒ  YZ2 d „  Z3 d S(   sµ  
Colorbar toolkit with two classes and a function:

    :class:`ColorbarBase`
        the base class with full colorbar drawing functionality.
        It can be used as-is to make a colorbar for a given colormap;
        a mappable object (e.g., image) is not needed.

    :class:`Colorbar`
        the derived class for use with images or contour plots.

    :func:`make_axes`
        a function for resizing an axes and adding a second axes
        suitable for a colorbar

The :meth:`~matplotlib.figure.Figure.colorbar` method uses :func:`make_axes`
and :class:`Colorbar`; the :func:`~matplotlib.pyplot.colorbar` function
is a thin wrapper over :meth:`~matplotlib.figure.Figure.colorbar`.

iÿÿÿÿ(   t   print_functionN(   t	   docstrings«  

    ============= ====================================================
    Property      Description
    ============= ====================================================
    *orientation* vertical or horizontal
    *fraction*    0.15; fraction of original axes to use for colorbar
    *pad*         0.05 if vertical, 0.15 if horizontal; fraction
                  of original axes between colorbar and new image axes
    *shrink*      1.0; fraction by which to shrink the colorbar
    *aspect*      20; ratio of long to short dimensions
    *anchor*      (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal;
                  the anchor point of the colorbar axes
    *panchor*     (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal;
                  the anchor point of the colorbar parent axes. If
                  False, the parent axes' anchor will be unchanged
    ============= ====================================================

sS  

    ============  ====================================================
    Property      Description
    ============  ====================================================
    *extend*      [ 'neither' | 'both' | 'min' | 'max' ]
                  If not 'neither', make pointed end(s) for out-of-
                  range values.  These are set for a given colormap
                  using the colormap set_under and set_over methods.
    *extendfrac*  [ *None* | 'auto' | length | lengths ]
                  If set to *None*, both the minimum and maximum
                  triangular colorbar extensions with have a length of
                  5% of the interior colorbar length (this is the
                  default setting). If set to 'auto', makes the
                  triangular colorbar extensions the same lengths as
                  the interior boxes (when *spacing* is set to
                  'uniform') or the same lengths as the respective
                  adjacent interior boxes (when *spacing* is set to
                  'proportional'). If a scalar, indicates the length
                  of both the minimum and maximum triangular colorbar
                  extensions as a fraction of the interior colorbar
                  length. A two-element sequence of fractions may also
                  be given, indicating the lengths of the minimum and
                  maximum colorbar extensions respectively as a
                  fraction of the interior colorbar length.
    *extendrect*  [ *False* | *True* ]
                  If *False* the minimum and maximum colorbar extensions
                  will be triangular (the default). If *True* the
                  extensions will be rectangular.
    *spacing*     [ 'uniform' | 'proportional' ]
                  Uniform spacing gives each discrete color the same
                  space; proportional makes the space proportional to
                  the data interval.
    *ticks*       [ None | list of ticks | Locator object ]
                  If None, ticks are determined automatically from the
                  input.
    *format*      [ None | format string | Formatter object ]
                  If None, the
                  :class:`~matplotlib.ticker.ScalarFormatter` is used.
                  If a format string is given, e.g., '%.3f', that is
                  used. An alternative
                  :class:`~matplotlib.ticker.Formatter` object may be
                  given instead.
    *drawedges*   [ False | True ] If true, draw lines at color
                  boundaries.
    ============  ====================================================

    The following will probably be useful only in the context of
    indexed colors (that is, when the mappable has norm=NoNorm()),
    or other unusual circumstances.

    ============   ===================================================
    Property       Description
    ============   ===================================================
    *boundaries*   None or a sequence
    *values*       None or a sequence which must be of length 1 less
                   than the sequence of *boundaries*. For each region
                   delimited by adjacent entries in *boundaries*, the
                   color mapped to the corresponding value in values
                   will be used.
    ============   ===================================================

s�
  

Add a colorbar to a plot.

Function signatures for the :mod:`~matplotlib.pyplot` interface; all
but the first are also method signatures for the
:meth:`~matplotlib.figure.Figure.colorbar` method::

  colorbar(**kwargs)
  colorbar(mappable, **kwargs)
  colorbar(mappable, cax=cax, **kwargs)
  colorbar(mappable, ax=ax, **kwargs)

arguments:

  *mappable*
    the :class:`~matplotlib.image.Image`,
    :class:`~matplotlib.contour.ContourSet`, etc. to
    which the colorbar applies; this argument is mandatory for the
    :meth:`~matplotlib.figure.Figure.colorbar` method but optional for the
    :func:`~matplotlib.pyplot.colorbar` function, which sets the
    default to the current image.

keyword arguments:

  *cax*
    None | axes object into which the colorbar will be drawn
  *ax*
    None | parent axes object(s) from which space for a new
    colorbar axes will be stolen. If a list of axes is given
    they will all be resized to make room for the colorbar axes.
  *use_gridspec*
    False | If *cax* is None, a new *cax* is created as an instance of
    Axes. If *ax* is an instance of Subplot and *use_gridspec* is True,
    *cax* is created as an instance of Subplot using the
    grid_spec module.


Additional keyword arguments are of two kinds:

  axes properties:
%s
  colorbar properties:
%s

If *mappable* is a :class:`~matplotlib.contours.ContourSet`, its *extend*
kwarg is included automatically.

Note that the *shrink* kwarg provides a simple way to keep a vertical
colorbar, for example, from being taller than the axes of the mappable
to which the colorbar is attached; but it is a manual method requiring
some trial and error. If the colorbar is too tall (or a horizontal
colorbar is too wide) use a smaller value of *shrink*.

For more precise control, you can manually specify the positions of
the axes objects in which the mappable and the colorbar are drawn.  In
this case, do not use any of the axes properties kwargs.

It is known that some vector graphics viewer (svg and pdf) renders white gaps
between segments of the colorbar. This is due to bugs in the viewers not
matplotlib. As a workaround the colorbar can be rendered with overlapping
segments::

    cbar = colorbar()
    cbar.solids.set_edgecolor("face")
    draw()

However this has negative consequences in other circumstances. Particularly
with semi transparent images (alpha < 1) and colorbar extensions and is not
enabled by default see (issue #1188).

returns:
    :class:`~matplotlib.colorbar.Colorbar` instance; see also its base class,
    :class:`~matplotlib.colorbar.ColorbarBase`.  Call the
    :meth:`~matplotlib.colorbar.ColorbarBase.set_label` method
    to label the colorbar.

t   colorbar_docc          O  s   t  j d ƒ d  S(   Ns,   Use the colorbar set_ticks() method instead.(   t   warningst   warn(   t   argst   kw(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   _set_ticks_on_axis_warnÐ   s    t   ColorbarBasec           B  s†  e  Z d  Z i e d d( ƒ d 6e d d ƒ d 6e d d( ƒ d 6e d d ƒ d 6Z d( d( d( d( d( d d	 d d
 d( d( e e d( e d d „ Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z e d „ Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z d „  Z d( d „ Z d „  Z d „  Z d  „  Z d! d" „ Z d# „  Z d$ „  Z d% „  Z  d& „  Z! d' „  Z" RS()   sF  
    Draw a colorbar in an existing axes.

    This is a base class for the :class:`Colorbar` class, which is the
    basis for the :func:`~matplotlib.pyplot.colorbar` function and the
    :meth:`~matplotlib.figure.Figure.colorbar` method, which are the
    usual ways of creating a colorbar.

    It is also useful by itself for showing a colormap.  If the *cmap*
    kwarg is given but *boundaries* and *values* are left as None,
    then the colormap will be displayed on a 0-1 scale. To show the
    under- and over-value colors, specify the *norm* as::

        colors.Normalize(clip=False)

    To show the colors versus index instead of on the 0-1 scale,
    use::

        norm=colors.NoNorm.

    Useful attributes:

        :attr:`ax`
            the Axes instance in which the colorbar is drawn

        :attr:`lines`
            a list of LineCollection if lines were drawn, otherwise
            an empty list

        :attr:`dividers`
            a LineCollection if *drawedges* is True, otherwise None

    Useful public methods are :meth:`set_label` and :meth:`add_lines`.

    i    t   neitheri   iÿÿÿÿt   botht   mint   maxt   verticalt   autot   uniformt    c         C  sÿ  | |  _  |  j ƒ  | d  k r. t j ƒ  } n  | d  k rI t j ƒ  } n  | |  _ t j j	 |  d | d | ƒ| |  _
 | |  _ |	 |  _ |  j |	 |  _ |
 |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  |  _ t ƒ  |  _ d  |  _ d  |  _ d  |  _ | d k r&| d k rd n d } n  | |  _ |  j | ƒ t j | ƒ rlt j  | d t! | ƒ ƒ|  _" n	 | |  _" | d  k rºt# |  j$ t j% ƒ r¨t j& ƒ  |  _' qçt j( ƒ  |  _' n- t j) | ƒ rÞt j* | ƒ |  _' n	 | |  _' |  j+ ƒ  |  j, ƒ  d  S(   Nt   cmapt   normR   t
   horizontalt   bottomt   rightt   nbins(-   t   axt	   _patch_axt   Nonet   cmt   get_cmapt   colorst	   Normalizet   alphat   ScalarMappablet   __init__t   valuest
   boundariest   extendt   _slice_dictt   _insidet   spacingt   orientationt	   drawedgest   filledt
   extendfract
   extendrectt   solidst   listt   linest   outlinet   patcht   dividerst   ticklocationt	   set_labelt   cbookt   iterablet   tickert   FixedLocatort   lent   locatort
   isinstanceR   t   LogNormt   LogFormatterMathtextt	   formattert   ScalarFormattert   is_string_liket   FormatStrFormattert   config_axist   draw_all(   t   selfR   R   R   R   R!   R"   R'   R2   R#   R&   t   tickst   formatR(   R)   R*   R+   t   label(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR    ÿ   sN    	
															!		
c         C  s   |  j  d k S(   s.   Returns whether the lower limit is open ended.R
   R   (   R
   s   min(   R#   (   RC   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   _extend_lower?  s    c         C  s   |  j  d k S(   s-   Returns whether the uper limit is open ended.R
   R   (   s   boths   max(   R#   (   RC   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   _extend_upperC  s    c         C  s   t  |  j _ t  |  j _ d  S(   N(   R   R   t
   set_xtickst
   set_yticks(   RC   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR   G  s    c         C  su   |  j  ƒ  |  j ƒ  |  j ƒ  \ } } |  j d d … t j f } |  j | | ƒ |  j rq |  j | | | ƒ n  d S(   ss   
        Calculate any free parameters based on the current cmap and norm,
        and do all the drawing.
        N(	   t   _process_valuest   _find_ranget   _mesht   _valuest   npt   newaxist   _config_axesR)   t   _add_solids(   RC   t   Xt   Yt   C(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRB   M  s    

	c         C  s•   |  j  } |  j d k rQ | j j g  ƒ | j j |  j ƒ | j j |  j ƒ n6 | j j g  ƒ | j j |  j ƒ | j j |  j ƒ |  j ƒ  d  S(   NR   (	   R   R'   t   xaxist	   set_tickst   yaxist   set_label_positionR2   t   set_ticks_positiont
   _set_label(   RC   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRA   Z  s    	c         C  sš   |  j  } |  j ƒ  \ } } } |  j d k rc | j j | ƒ | j | ƒ | j j ƒ  j | ƒ n3 | j j | ƒ | j	 | ƒ | j j ƒ  j | ƒ d S(   s”   
        Force the update of the ticks and ticklabels. This must be
        called whenever the tick locator and/or tick formatter changes.
        R   N(
   R   t   _tickerR'   RX   RW   t   set_yticklabelst   get_major_formattert   set_offset_stringRV   t   set_xticklabels(   RC   R   RD   t
   ticklabelst   offset_string(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   update_ticksi  s    	c         C  sP   t  j | ƒ r0 t j | d t | ƒ ƒ|  _ n	 | |  _ | rL |  j ƒ  n  d S(   sÁ   
        set tick locations. Tick locations are updated immediately unless
        update_ticks is *False*. To manually update the ticks, call
        *update_ticks* method explicitly.
        R   N(   R4   R5   R6   R7   R8   R9   Rc   (   RC   RD   Rc   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRW   z  s
    !	c         C  sN   t  |  j t j ƒ r= t j | ƒ |  _ | rJ |  j ƒ  qJ n t j d ƒ d S(   s»   
        set tick labels. Tick labels are updated immediately unless
        update_ticks is *False*. To manually update the ticks, call
        *update_ticks* method explicitly.
        s"   set_ticks() must have been called.N(	   R:   R9   R6   R7   t   FixedFormatterR=   Rc   R   R   (   RC   Ra   Rc   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   set_ticklabelsˆ  s
    c      
   C  sz  |  j  } | j t ƒ | j t ƒ |  j | | ƒ } | j | ƒ | j | j j Œ  | j	 | j j
 Œ  |  j d k	 r‡ |  j j ƒ  n  t j | d d … d f | d d … d f d t j d d t j d ƒ|  _ | j |  j ƒ |  j j d ƒ |  j j d ƒ t j d } |  j d k	 r2|  j j ƒ  n  t j | d	 | d
 | d d d d ƒ|  _ | j |  j ƒ |  j ƒ  d S(   s1   
        Make an axes patch and outline.
        Ni    i   t   colors   axes.edgecolort	   linewidths   axes.linewidths   axes.facecolort	   edgecolort	   facecolorg{®Gáz„?t   zorderiÿÿÿÿ(   R   t   set_frame_ont   Falset   set_navigatet   _outlinet   update_datalimt   set_xlimt   dataLimt	   intervalxt   set_ylimt	   intervalyR/   R   t   removeR.   t   Line2Dt   mplt   rcParamst
   add_artistt   set_clip_boxt   set_clip_pathR0   t   mpatchest   PolygonRc   (   RC   RS   RT   R   t   xyt   c(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRQ   •  s0    	6c         C  sH   |  j  d k r+ |  j j |  j |  j � n |  j j |  j |  j � d  S(   NR   (   R'   R   t
   set_ylabelt   _labelt   _labelkwt
   set_xlabel(   RC   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR[   ³  s    c         K  s'   d | f |  _  | |  _ |  j ƒ  d S(   s5   
        Label the long axis of the colorbar
        s   %sN(   R�   R‚   R[   (   RC   RF   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR3   ¹  s    	c      	   C  sý   | j  d } d d | d | d d | d d | d | d | d g	 } t j t j t j | ƒ ƒ | ƒ } t j t j t j | ƒ ƒ | ƒ } | j t | ƒ d f ƒ } | j t | ƒ d f ƒ } |  j d k rê t j | | f ƒ St j | | f ƒ S(   so   
        Return *x*, *y* arrays of colorbar bounding polygon,
        taking orientation into account.
        i    i   i   R   (	   t   shapeRO   t   taket   ravelt	   transposet   reshapeR8   R'   t   hstack(   RC   RS   RT   t   Nt   iit   xt   y(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRn   Á  s    =$$c         C  sŠ   | j  d } |  j d k rQ g  t d | d ƒ D] } t | | | | ƒ ^ q0 Sg  t d | d ƒ D] } t | | | | ƒ ^ qe Sd S(   sM   
        Return the separator line segments; helper for _add_solids.
        i    R   i   N(   R„   R'   t   xranget   zip(   RC   RS   RT   RŠ   t   i(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   _edgesÐ  s    5c   	   	   C  st  |  j  d k r! | | | f } n* t j | ƒ t j | ƒ t j | ƒ f } t d |  j d |  j d |  j d d ƒ } |  j j ƒ  } |  j j	 t
 ƒ |  j j | | Ž  } |  j j	 | ƒ |  j d k	 rØ |  j j ƒ  n  | |  _ |  j d k	 r	|  j j ƒ  d |  _ n  |  j rpd t j d f } t j |  j | | ƒ d	 t j d
 f d | ƒ|  _ |  j j |  j ƒ n  d S(   st   
        Draw the colors using :meth:`~matplotlib.axes.Axes.pcolormesh`;
        optionally add separators.
        R   R   R   R   t
   edgecolorsR   g      à?s   axes.linewidthR   s   axes.edgecolort
   linewidthsN(   R'   RO   R‡   t   dictR   R   R   R   t   isholdt   holdt   Truet
   pcolormeshR,   R   Ru   R1   R(   Rw   Rx   t   collectionst   LineCollectionR‘   t   add_collection(	   RC   RS   RT   RU   R   R   t   _holdt   colR“   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRR   Ü  s.    *					c         C  s£  |  j  | ƒ } | d k  | d k @} | | } t j | ƒ rT t j | ƒ | } n  t j | ƒ ry t j | ƒ | } n  t | ƒ } t j d d g ƒ } t j | | ƒ \ }	 }
 |  j d k rô g  t	 | ƒ D] } t
 |	 | |
 | ƒ ^ qÎ } n0 g  t	 | ƒ D] } t
 |
 | |	 | ƒ ^ q} t j | d | ƒ} | rr|  j rrx |  j D] } | j ƒ  qRWg  |  _ n  |  j j | ƒ | j | ƒ |  j j | ƒ d S(   sø   
        Draw lines on the colorbar.

        *colors* and *linewidths* must be scalars or
        sequences the same length as *levels*.

        Set *erase* to False to add lines without first
        removing any previously added lines.
        gj¼t“ð?gü©ñÒMbP¿g        g      ð?R   R“   N(   t   _locateR4   R5   RO   t   asarrayR8   t   arrayt   meshgridR'   RŽ   R�   R™   Rš   R.   Ru   t   appendt	   set_colorR   R›   (   RC   t   levelsR   R“   t   eraseR�   t   igoodRŠ   RŒ   RS   RT   R�   R~   R�   t   lc(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt	   add_linesÿ  s*    

30c         C  sS  |  j  } |  j } | d k r|  j d k rì t |  j t j ƒ r€ t |  j	 ƒ } d t
 | d ƒ } t j d | d d ƒ } qt |  j t j ƒ r¹ |  j j } t j | d d ƒ} qt |  j t j ƒ rÝ t j ƒ  } qt j ƒ  } q|  j |  j } t j | d d ƒ} n  t |  j t j ƒ rF|  j	 d |  j	 d f } n |  j |  j f } | j d | d ƒ | j d | d ƒ | j | Œ  | j | Œ  | j | Œ  | j | Œ  t j | ƒ  ƒ } |  j | ƒ } | d	 k | d
 k  @} | | } | | } | j | ƒ g  t | ƒ D] \ }	 }
 | |
 |	 ƒ ^ q} | j ƒ  } | | | f S(   si   
        Return two sequences: ticks (colorbar data locations)
        and ticklabels (strings).
        i   i
   t   baset   offseti    R   iÿÿÿÿt   minposgü©ñÒMbP¿gj¼t“ð?N(   R9   R=   R   R"   R:   R   R   t   NoNormR8   RN   t   intR6   t   IndexLocatort   BoundaryNormR7   R;   t
   LogLocatort   MaxNLocatort   _boundariesR%   t   vmint   vmaxt   create_dummy_axist   set_view_intervalt   set_data_intervalRO   R    Rž   t   set_locst	   enumeratet
   get_offset(   RC   R9   R=   t   nvR©   t   bt   intvRD   t   inrangeR�   t   tRa   Rb   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR\   !  sD    		

.c         C  s!  | d k r |  j } n  | d k	 r» t j | d t ƒ|  _ |  j d k r¢ d |  j d  |  j d |  _ t |  j	 t
 j ƒ rž |  j d j t j ƒ |  _ n  d St j |  j ƒ |  _ d S|  j d k	 rŠt j |  j ƒ |  _ |  j d k rqt j t |  j ƒ d d ƒ } d |  j d  |  j d | d d +d | d | d	 | d
 <d | d | d | d <| |  _ d St j |  j ƒ |  _ d St |  j	 t
 j ƒ r^|  j |  j j d ƒ |  j j d } t j t | ƒ d f d t j ƒ} t j |  j j d t j ƒ| |  j <|  j ƒ  r)d | d
 <n  |  j ƒ  rH|  j j | d <n  | |  _ | |  _ d St |  j	 t
 j ƒ rt |  j	 j ƒ } |  j ƒ  r©| d
 d g | } n  |  j ƒ  rÍ| | d d g } n  t j | ƒ } t j t | ƒ d f d t ƒ} |  j	 j } d | d  | d | |  j <|  j ƒ  rH| d
 d | d
 <n  |  j ƒ  ri| d d | d <n  | |  _ | |  _ d S|  j	 j ƒ  s©d
 |  j	 _ d |  j	 _ n  |  j	 j |  j |  j j d ƒ ƒ } |  j ƒ  rï| d
 d | d
 <n  |  j ƒ  r| d d | d <n  |  j | ƒ d S(   sÆ   
        Set the :attr:`_boundaries` and :attr:`_values` attributes
        based on the input boundaries and values.  Input boundaries
        can be *self.boundaries* or the argument *b*.
        t   dtypeg      à?iÿÿÿÿi   gñhãˆµøä>Nt   dg       @i   i    iþÿÿÿiýÿÿÿ(   R   R"   RO   RŸ   t   floatR²   R!   RN   R:   R   R   R¬   t   astypet   int16R    t   zerosR8   t
   _uniform_yR   RŠ   t   arangeR%   RG   RH   R¯   R-   t   scaledR³   R´   t   inverseRK   (   RC   R¼   t   vt   bi(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRK   M  sx    #	'%%		"		%c         C  s.   |  j  |  j } | d |  _ | d |  _ d S(   sˆ   
        Set :attr:`vmin` and :attr:`vmax` attributes to the first and
        last boundary excluding extended end boundaries.
        i    iÿÿÿÿN(   R²   R%   R³   R´   (   RC   R¼   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRL   “  s    c         C  sK   t  |  j ƒ } |  j d k r+ | d 8} n |  j d k rG | d 8} n  | S(   s1   number of boundaries **before** extension of endsR
   i   R   R   i   (   s   mins   max(   R8   R²   R#   (   RC   t   nb(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt
   _central_Nœ  s    c         C  sL   |  j  j d } |  j d k r, | d 7} n |  j d k rH | d 7} n  | S(   se   
        Based on the colormap and extend variable, return the
        number of boundaries.
        i   R
   i   R   R   (   s   mins   max(   R   RŠ   R#   (   RC   RŠ   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   _extended_N¥  s    gš™™™™™©?c         C  sÁ   t  j | | g ƒ } t | t ƒ r\ | j ƒ  d k rM | | d <| | d <q½ t d ƒ ‚ na | d k	 r½ y, | | (t  j | ƒ j ƒ  r“ t ƒ  ‚ n  Wq½ t	 t f k
 r¹ t d ƒ ‚ q½ Xn  | S(   sv   
        Get the lengths of colorbar extensions.

        A helper method for _uniform_y and _proportional_y.
        R   i    i   s   invalid value for extendfracN(
   RO   R    R:   t   strt   lowert
   ValueErrorR   t   isnant   anyt	   TypeError(   RC   t   fract   automint   automaxt   defaultt   extendlength(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   _get_extension_lengths±  s    
c         C  s%  |  j  d k r' t j d d | ƒ } nú d | d } } |  j |  j | | d d ƒ} |  j  d k r£ t j | d d	 ƒ } d
 | d | d <d | d | d <nb |  j  d k rÝ t j | d d	 ƒ } d
 | d | d <n( t j | d d	 ƒ } d | d | d <t j d d | ƒ | |  j <| S(   sv   
        Return colorbar data coordinates for *N* uniformly
        spaced boundaries, plus ends if required.
        R	   i    i   g      ð?RØ   gš™™™™™©?R
   i   RÁ   g        iÿÿÿÿR   (   R#   RO   t   linspaceRÚ   R*   RÅ   R%   (   RC   RŠ   R�   RÖ   R×   RÙ   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRÆ   Î  s"    		c         C  sâ  t  |  j t j ƒ rH |  j |  j d } | |  j d |  j d } n |  j |  j j ƒ  ƒ } |  j d k r° | d | d } | d | d | } | d | d | } nŽ |  j d k r | d | d } | d | d | } | d | d | } n> | d | d } | d | d | } | d | d | } |  j |  j | | d	 d
 ƒ} |  j d k r€d | d | d <n  |  j d k r¤d | d | d <n  | |  j	 } t j
 | d | d ƒ } | | ƒ | |  j	 <| S(   si   
        Return colorbar data coordinates for the boundaries of
        a proportional colorbar.
        i    iÿÿÿÿR   i   i   iþÿÿÿR   iýÿÿÿRØ   gš™™™™™©?R
   g        g      ð?(   s   boths   min(   s   boths   max(   R:   R   R   R¯   R²   t   copyR#   RÚ   R*   R%   R   (   RC   R�   t   clenRÖ   R×   RÙ   t   yiR   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   _proportional_yç  s4    		c         C  sÑ   t  j d d g ƒ } |  j d k r< |  j |  j ƒ  ƒ } n |  j ƒ  } | |  _ t  j | | ƒ \ } } |  j ƒ  r˜ |  j	 r˜ d | d d d … f <n  |  j
 ƒ  rÇ |  j	 rÇ d | d d d … f <n  | | f S(   sé   
        Return X,Y, the coordinate arrays for the colorbar pcolormesh.
        These are suitable for a vertical colorbar; swapping and
        transposition for a horizontal colorbar are done outside
        this function.
        g        g      ð?R   g      à?i    Niÿÿÿÿ(   RO   R    R&   RÆ   RÍ   Rß   t   _yR¡   RG   R+   RH   (   RC   RŒ   R�   RS   RT   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRM     s    	c         C  sh  t  |  j t j t j f ƒ r0 |  j } | } n9 |  j |  j d t ƒj ƒ  } |  j | d t ƒj ƒ  } |  j } t	 | ƒ } t
 j | | ƒ } | d } | | k } | d k }	 | | c d 8<| | c d 8<| |	 c d 7<| |	 c d 7<t
 j | | ƒ t
 j | | ƒ }
 t
 j | | ƒ t
 j | | ƒ } t
 j | | ƒ | t
 j | | ƒ | |
 } | S(   sq   
        Given a set of color data values, return their
        corresponding colorbar data coordinates.
        t   clipi   i    (   R:   R   R   R¬   R¯   R²   Rl   R)   Rà   R8   RO   t   searchsortedR…   (   RC   RŒ   R¼   t   xnR�   RŠ   R‹   t   i0t   itopt   ibott   dbt   dyt   z(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRž      s&    			
"".c         C  s   | |  _  d  S(   N(   R   (   RC   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt	   set_alphaA  s    N(#   t   __name__t
   __module__t   __doc__t   sliceR   R$   Rl   R—   R    RG   RH   R   RB   RA   Rc   RW   Re   RQ   R[   R3   Rn   R‘   RR   R¨   R\   RK   RL   RÍ   RÎ   RÚ   RÆ   Rß   RM   Rž   Rê   (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR   Ö   s^   #1												#"	,F							%		!t   Colorbarc           B  s>   e  Z d  Z d „  Z d „  Z e d „ Z d „  Z d „  Z RS(   s„  
    This class connects a :class:`ColorbarBase` to a
    :class:`~matplotlib.cm.ScalarMappable` such as a
    :class:`~matplotlib.image.AxesImage` generated via
    :meth:`~matplotlib.axes.Axes.imshow`.

    It is not intended to be instantiated directly; instead,
    use :meth:`~matplotlib.figure.Figure.colorbar` or
    :func:`~matplotlib.pyplot.colorbar` to make your colorbar.

    c         K  sL  | j  ƒ  | |  _ | j | d <} | j | d <} t | t j ƒ râ | } | j ƒ  | d <| j | d <| j	 | d <| j
 | d <| j d t j | j d d	 ƒƒ | j | d
 <t j |  | | � | j sH|  j | ƒ qHnf t | d t ƒ t k	 r| j d | j ƒ n  t | t j ƒ r5| j ƒ  | d <n  t j |  | | � d  S(   NR   R   R   R"   R!   R#   RD   R   i
   R)   t   colorbar_extend(   t   autoscale_Nonet   mappableR   R   R:   t   contourt
   ContourSett	   get_alphat   _levelst   cvaluesR#   t
   setdefaultR6   R7   R¤   R)   R   R    R¨   t   getattrRl   Rð   t   martistt   Artist(   RC   R   Rò   R   R   R   t   CS(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR    Q  s(    
	"	c         C  s7   |  j  | j ƒ  ƒ |  j | j ƒ  ƒ |  j | ƒ d S(   sÛ   
        Updates this colorbar to match the mappable's properties.

        Typically this is automatically registered as an event handler
        by :func:`colorbar_factory` and should not be called manually.

        N(   t   set_cmapR   t   set_climt   get_climt   update_normal(   RC   Rò   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   on_mappable_changedo  s    c         C  sŽ   t  | t j ƒ s | j r+ t d ƒ ‚ n  g  | j D] } | d ^ q5 } g  | j D] } | d ^ qU } t j |  | j	 | | d | ƒd S(   sÒ   
        Add the lines from a non-filled
        :class:`~matplotlib.contour.ContourSet` to the colorbar.

        Set *erase* to False if these lines should be added to
        any pre-existing lines.
        s+   add_lines is only for a ContourSet of linesi    R¥   N(
   R:   Ró   Rô   R)   RÑ   t   tcolorst   tlinewidthsR   R¨   R¤   (   RC   Rü   R¥   R   R  R¿   R  (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR¨   {  s      	c         C  sH   |  j  ƒ  t |  j t j ƒ rD |  j } | j sD |  j | ƒ qD n  d S(   s×   
        update solid, lines, etc. Unlike update_bruteforce, it does
        not clear the axes.  This is meant to be called when the image
        or contour plot to which this colorbar belongs is changed.
        N(   RB   R:   Rò   Ró   Rô   R)   R¨   (   RC   Rò   Rü   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR   ’  s
    
		c         C  sº   |  j  j ƒ  d |  _ d |  _ d |  _ t ƒ  |  _ d |  _ |  j	 | j
 ƒ  ƒ | j |  _ | j |  _ |  j ƒ  |  j ƒ  t |  j t j ƒ r¶ |  j } | j s¶ |  j | ƒ q¶ n  d S(   s  
        Destroy and rebuild the colorbar.  This is
        intended to become obsolete, and will probably be
        deprecated and then removed.  It is not called when
        the pyplot.colorbar function or the Figure.colorbar
        method are used to create the colorbar.

        N(   R   t   claR   R/   R0   R,   R-   R.   R1   Rê   Rõ   R   R   RA   RB   R:   Rò   Ró   Rô   R)   R¨   (   RC   Rò   Rü   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   update_bruteforcež  s    				

		(	   Rë   Rì   Rí   R    R  R—   R¨   R   R  (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRï   E  s   			g333333Ã?g      ð?i   c           sñ  d d d d g } | d k	 rQ | d k	 rQ d j d j | ƒ ƒ } t | ƒ ‚ n  | d k rr | d k rr d } n  | d k r™ | d k r� d n d } n  | | k rÁ t d d j | ƒ ƒ ‚ n  i i d d 6d d 6d d 6d d 6d 6i d d 6d  d 6d d 6d d 6d 6i d! d 6d" d 6d d 6d d 6d 6i d# d 6d$ d 6d d 6d d 6d 6}	 |	 | }
 |
 d | d <| | d <| j d |
 d ƒ } | j d |
 d ƒ } | j d |
 d ƒ } t |  t t f ƒ sØ|  g }  n  |  d j	 ƒ  ‰  t
 ‡  f d †  |  Dƒ ƒ st d ƒ ‚ n  t j j g  |  D] } | j d t ƒ j ƒ  ^ q#ƒ } | } | d% k rÒ| d k rŠ| j | | | ƒ \ } } } n' | j d | | d | ƒ \ } } } | j d	 | ƒ j | | ƒ } n} | d k r | j | | | ƒ \ } } } n' | j d | | d | ƒ \ } } } | j | d	 ƒ j | | ƒ } d	 | } t j | | ƒ } x[ |  D]S } | j | j ƒ  ƒ } t j | ƒ } | j | ƒ | t k	 rh| j | ƒ qhqhWˆ  j | ƒ } | j | d | d d ƒ| | f S(&   s9  
    Resize and reposition parent axes, and return a child
    axes suitable for a colorbar::

        cax, kw = make_axes(parent, **kw)

    Keyword arguments may include the following (with defaults):

        location : [`None`|'left'|'right'|'top'|'bottom']
            The position, relative to **parents**, where the colorbar axes
            should be created. If None, the value will either come from the
            given ``orientation``, else it will default to 'right'.

        orientation :  [`None`|'vertical'|'horizontal']
            The orientation of the colorbar. Typically, this keyword shouldn't
            be used, as it can be derived from the ``location`` keyword.

    %s

    Returns (cax, kw), the child axes and the reduced kw dictionary to be
    passed when creating the colorbar instance.
    t   leftR   t   topR   s\   position and orientation are mutually exclusive. Consider setting the position to any of {0}s   , R   s,   Invalid colorbar location. Must be one of %sg      ð?g      à?t   anchorg        t   panchorgš™™™™™¹?t   padR'   gš™™™™™©?R   g333333Ã?R2   i    c         3  s!   |  ] } ˆ  | j  ƒ  k Vq d  S(   N(   t
   get_figure(   t   .0R   (   t   fig(    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pys	   <genexpr>  s    sJ   Unable to create a colorbar axes as not all parents share the same figure.t   originali   t
   adjustablet   boxN(   g      ð?g      à?(   g        g      à?(   g        g      à?(   g      ð?g      à?(   g      à?g        (   g      à?g      ð?(   g      à?g      ð?(   g      à?g        (   s   lefts   right(   R   RE   t   joinRÔ   RÑ   t   popR:   R-   t   tupleR  t   allt   mtranst   Bboxt   uniont   get_positionR—   t   frozent   splitxt   shrunkt   anchoredt   splityt   BboxTransformt	   transformt   set_positionRl   t
   set_anchort   add_axest
   set_aspect(   t   parentst   locationR'   t   fractiont   shrinkt   aspectR   t	   locationst   msgt   default_location_settingst   loc_settingsR  t   parent_anchorR
  R   t   parents_bboxt   pbt   pbcbt   _t   pb1t   shrinking_transt   new_posnt   cax(    (   R  sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt	   make_axesÄ  s|    	




+"'!"'
c      
   K  s!  | j  d d ƒ } d | d <| j d d ƒ } | j d d ƒ } | j d	 d
 ƒ } d | } d | d } | | | g } t j }	 | d k r| j d d ƒ }
 d |
 d |
 } |	 d d d |  j ƒ  d | d | |
 | g ƒ} |	 d d d | d d d d | ƒ} d } d } n� | j d d ƒ }
 d |
 d |
 } |	 d d d |  j ƒ  d | d | |
 | g ƒ} |	 d d d | d d d d | ƒ} d | } d } d } |  j | d ƒ |  j ƒ  |  j |  j ƒ |  j	 | ƒ |  j
 ƒ  } | j | d ƒ } | j | d | d d ƒ| | f S(   sY  
    Resize and reposition a parent axes, and return a child axes
    suitable for a colorbar. This function is similar to
    make_axes. Prmary differences are

     * *make_axes_gridspec* only handles the *orientation* keyword
       and cannot handle the "location" keyword.

     * *make_axes_gridspec* should only be used with a subplot parent.

     * *make_axes* creates an instance of Axes. *make_axes_gridspec*
        creates an instance of Subplot.

     * *make_axes* updates the position of the
        parent. *make_axes_gridspec* replaces the grid_spec attribute
        of the parent with a new one.

    While this function is meant to be compatible with *make_axes*,
    there could be some minor differences.::

        cax, kw = make_axes_gridspec(parent, **kw)

    Keyword arguments may include the following (with defaults):

        *orientation*
            'vertical' or 'horizontal'

    %s

    All but the first of these are stripped from the input kw set.

    Returns (cax, kw), the child axes and the reduced kw dictionary to be
    passed when creating the colorbar instance.
    R'   R   R   R2   R&  g333333Ã?R'  g      ð?R(  i   g      à?R
  gš™™™™™©?i   i   t   subplot_spect   wspacet   width_ratiosi   t   hspaceg        t   height_ratiosi    R  R  R  (   g        g      à?(   g      ð?g      à?(   g      à?g      ð?(   g      à?g        (   Rø   R  t   gridspect   GridSpecFromSubplotSpect   get_subplotspect   set_subplotspect   update_paramsR   t   figboxR!  R  t   add_subplotR#  (   t   parentR   R'   R&  R'  R(  t   x1t   pad_st	   wh_ratiost   gs_from_subplotspecR
  t   wh_spacet   gst   gs2R  R	  R  R5  (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   make_axes_gridspec=  sV    %

	
		
	

t   ColorbarPatchc           B  s    e  Z d  Z d „  Z d „  Z RS(   s]  
    A Colorbar which is created using :class:`~matplotlib.patches.Patch`
    rather than the default :func:`~matplotlib.axes.pcolor`.

    It uses a list of Patch instances instead of a
    :class:`~matplotlib.collections.PatchCollection` because the
    latter does not allow the hatch pattern to vary among the
    members of the collection.
    c         K  s#   g  |  _  t j |  | | | � d  S(   N(   t   solids_patchesRï   R    (   RC   R   Rò   R   (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyR    «  s    	c         C  sj  |  j  j ƒ  } |  j  j t ƒ i |  j d 6} t | ƒ } |  j j | } g  } xFt t | ƒ d ƒ D].}	 | |	 d }
 | |	 } t	 j
 | |	 d | |	 d g | |	 d | |	 d g | |	 d d | |	 d d g | |	 d d | |	 d d g g ƒ } |  j d k r4| d d d d … f } n  t j t j | ƒ d |  j |  j |
 ƒ ƒ d	 | d
 d d t | �} |  j  j | ƒ | j | ƒ qh W|  j rÄx |  j D] } | j ƒ  q­Wn  | |  _ |  j d k	 rõ|  j j ƒ  d |  _ n  |  j rVt j |  j | | ƒ d t j d f d d t j d f ƒ|  _ |  j  j |  j ƒ n  |  j  j | ƒ d S(   sn   
        Draw the colors using :class:`~matplotlib.patches.Patch`;
        optionally add separators.
        R   i   i    R   .NiÿÿÿÿRi   t   hatchRg   t   antialiasedR   s   axes.edgecolorR“   g      à?s   axes.linewidth(    R   R•   R–   R—   R   R8   Rò   t   hatchesRŽ   RO   R    R'   R|   t	   PathPatcht   mpatht   PathR   R   Rl   t	   add_patchR¢   RM  Ru   R1   R   R(   R™   Rš   R‘   Rw   Rx   R›   (   RC   RS   RT   RU   Rœ   R   t
   n_segmentsRP  t   patchesR�   t   valRN  R~   R0   t   solid(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRR   ²  sD    
!*			(   Rë   Rì   Rí   R    RR   (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyRL  ¡  s   		c         K  s„   t  | t j ƒ rO t g  | j D] } | d k	 ^ q ƒ rO t |  | | � } n t |  | | � } | j j	 d | j
 ƒ | | _ | S(   sÂ   
    Creates a colorbar on the given axes for the given mappable.

    Typically, for automatic colorbar placement given only a mappable use
    :meth:`~matplotlib.figure.Figure.colorbar`.

    t   changedN(   R:   Ró   Rô   RÓ   RP  R   RL  Rï   t   callbacksSMt   connectR  t   colorbar(   R5  Rò   t   kwargsRN  t   cb(    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   colorbar_factoryì  s    
(	(4   Rí   t
   __future__R    R   t   numpyRO   t
   matplotlibRw   t   matplotlib.artistt   artistRú   t   matplotlib.cbookR4   t   matplotlib.collectionsR™   t   matplotlib.colorsR   t   matplotlib.contourRó   t   matplotlib.cmR   t   matplotlib.gridspecR<  t   matplotlib.linesR.   t   matplotlib.patchesRV  R|   t   matplotlib.patht   pathRR  t   matplotlib.tickerR6   t   matplotlib.transformst
   transformsR  R   t   make_axes_kw_doct   colormap_kw_docR   t   interpdt   updateR   R   R   Rï   t   SubstitutionR   R6  RK  RL  R_  (    (    (    sM   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/colorbar.pyt   <module>   s@   @O	ÿ ÿ q	wdK