U
    \	¸a.ì  ã                   @   sØ  d 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m	Z	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e e¡Z dZ!dZ"dZ#ej$j%de &e!d	¡e &e"d	¡e#f d
 ej$j'd Z(e#Z)e!e" Z*dd„ Z+G dd„ dej,ƒZ-G dd„ dej.ƒZ/G dd„ dej0ƒZ1G dd„ dej2ƒZ3G dd„ dƒZ4dd„ Z5G dd„ de4ƒZ6dd„ Z7e 8e!e"¡d,d!d"„ƒZ9e 8e!e"¡ddddd d#œd$d%„ƒZ:ej;d&dd'G d(d)„ d)e6ƒƒZ<ej;d&dd'd*d+„ ƒZ=dS )-aI  
Colorbars are a visualization of the mapping from scalar values to colors.
In Matplotlib they are drawn into a dedicated `~.axes.Axes`.

.. note::
   Colorbars are typically created through `.Figure.colorbar` or its pyplot
   wrapper `.pyplot.colorbar`, which use `.make_axes` and `.Colorbar`
   internally.

   As an end-user, you most likely won't have to call the methods or
   instantiate the classes in this module explicitly.

: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`
    On top of `.ColorbarBase` this connects the colorbar with a
    `.ScalarMappable` such as an image or contour plot.

:func:`make_axes`
    Create an `~.axes.Axes` suitable for a colorbar. This functions can be
    used with figures containing a single axes or with freely placed axes.

:func:`make_axes_gridspec`
    Create a `~.SubplotBase` suitable for a colorbar. This function should
    be used for adding a colorbar to a `.GridSpec`.
é    N)Ú_apiÚcollectionsÚcmÚcolorsÚcontourÚticker)Ú	docstringaï  
location : None or {'left', 'right', 'top', 'bottom'}
    The location, relative to the parent axes, where the colorbar axes
    is created.  It also determines the *orientation* of the colorbar
    (colorbars on the left and right are vertical, colorbars at the top
    and bottom are horizontal).  If None, the location will come from the
    *orientation* if it is set (vertical colorbars on the right, horizontal
    ones at the bottom), or default to 'right' if *orientation* is unset.
orientation : None or {'vertical', 'horizontal'}
    The orientation of the colorbar.  It is preferable to set the *location*
    of the colorbar, as that also determines the *orientation*; passing
    incompatible values for *location* and *orientation* raises an exception.
fraction : float, default: 0.15
    Fraction of original axes to use for colorbar.
shrink : float, default: 1.0
    Fraction by which to multiply the size of the colorbar.
aspect : float, default: 20
    Ratio of long to short dimensions.
aì  
pad : float, default: 0.05 if vertical, 0.15 if horizontal
    Fraction of original axes between colorbar and new image axes.
anchor : (float, float), optional
    The anchor point of the colorbar axes.
    Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.
panchor : (float, float), or *False*, optional
    The anchor point of the colorbar parent axes. If *False*, the parent
    axes' anchor will be unchanged.
    Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.
aý  

    ============  ====================================================
    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*  bool
                  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* or list of ticks or Locator
                  If None, ticks are determined automatically from the
                  input.
    *format*      None or str or Formatter
                  If None, `~.ticker.ScalarFormatter` is used.
                  If a format string is given, e.g., '%.3f', that is used.
                  An alternative `~.ticker.Formatter` may be given instead.
    *drawedges*   bool
                  Whether to draw lines at color boundaries.
    *label*       str
                  The label on the colorbar's long axis.
    ============  ====================================================

    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
                   colormapped to the corresponding value in values
                   will be used.
    ============   ===================================================

aN	  
Add a colorbar to a plot.

Parameters
----------
mappable
    The `matplotlib.cm.ScalarMappable` (i.e., `~matplotlib.image.AxesImage`,
    `~matplotlib.contour.ContourSet`, etc.) described by this colorbar.
    This argument is mandatory for the `.Figure.colorbar` method but optional
    for the `.pyplot.colorbar` function, which sets the default to the current
    image.

    Note that one can create a `.ScalarMappable` "on-the-fly" to generate
    colorbars not attached to a previously drawn artist, e.g. ::

        fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax)

cax : `~matplotlib.axes.Axes`, optional
    Axes into which the colorbar will be drawn.

ax : `~matplotlib.axes.Axes`, list of Axes, optional
    One or more parent axes from which space for a new colorbar axes will be
    stolen, if *cax* is None.  This has no effect if *cax* is set.

use_gridspec : bool, optional
    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 :mod:`~.gridspec` module.

Returns
-------
colorbar : `~matplotlib.colorbar.Colorbar`
    See also its base class, `~matplotlib.colorbar.ColorbarBase`.

Notes
-----
Additional keyword arguments are of two kinds:

  axes properties:
%s
%s
  colorbar properties:
%s

If *mappable* is a `~.contour.ContourSet`, its *extend* kwarg is included
automatically.

The *shrink* kwarg provides a simple way to scale the colorbar with respect
to the axes. Note that if *cax* is specified, it determines the size of the
colorbar and *shrink* and *aspect* kwargs are ignored.

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 viewers (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, e.g. with
semi-transparent images (alpha < 1) and colorbar extensions; therefore, this
workaround is not used by default (see issue #1188).
z    )Úcolorbar_docr	   c                  O   s   t  d¡ d S )Nz,Use the colorbar set_ticks() method instead.)r   Úwarn_external)ÚargsÚkw© r   ú7/tmp/pip-unpacked-wheel-wjyw_3jo/matplotlib/colorbar.pyÚ_set_ticks_on_axis_warnÛ   s    r   c                       s,   e Zd ZdZ‡ fdd„Z‡ fdd„Z‡  ZS )Ú_ColorbarAutoLocatora  
    AutoLocator for Colorbar

    This locator is just a `.MaxNLocator` except the min and max are
    clipped by the norm's min and max (i.e. vmin/vmax from the
    image/pcolor/contour object).  This is necessary so ticks don't
    extrude into the "extend regions".
    c                    s,   || _ d}dddddg}tƒ j||d dS )	z¬
        This ticker needs to know the *colorbar* so that it can access
        its *vmin* and *vmax*.  Otherwise it is the same as
        `~.ticker.AutoLocator`.
        Úautoé   é   g      @é   é
   )ÚnbinsÚstepsN©Ú	_colorbarÚsuperÚ__init__)ÚselfÚcolorbarr   r   ©Ú	__class__r   r   r   ë   s    z_ColorbarAutoLocator.__init__c                    sh   ||kr|| }}t || jjjƒ}t|| jjjƒ}tƒ  ||¡}|| d }|||| k||| k@  S ©Nç»½×Ùß|Û=)Úmaxr   ÚnormÚvminÚminÚvmaxr   Útick_values©r   r$   r&   ÚticksÚrtolr   r   r   r'   ÷   s    
z _ColorbarAutoLocator.tick_values©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   Ú__classcell__r   r   r   r   r   á   s   	r   c                       s.   e Zd ZdZd‡ fdd„	Z‡ fdd„Z‡  ZS )Ú_ColorbarAutoMinorLocatora*  
    AutoMinorLocator for Colorbar

    This locator is just a `.AutoMinorLocator` except the min and max are
    clipped by the norm's min and max (i.e. vmin/vmax from the
    image/pcolor/contour object).  This is necessary so that the minorticks
    don't extrude into the "extend regions".
    Nc                    s   || _ || _tƒ jdd dS )zo
        This ticker needs to know the *colorbar* so that it can access
        its *vmin* and *vmax*.
        N)Ún)r   Zndivsr   r   )r   r   r2   r   r   r   r     s    z"_ColorbarAutoMinorLocator.__init__c                    sF   | j jj}| j jj}tƒ  ¡ }|| d }|||| k||| k@  S r    )r   r#   r$   r&   r   Ú__call__r(   r   r   r   r3     s
    


z"_ColorbarAutoMinorLocator.__call__)N)r,   r-   r.   r/   r   r3   r0   r   r   r   r   r1     s   		r1   c                       s,   e Zd ZdZ‡ fdd„Z‡ fdd„Z‡  ZS )Ú_ColorbarLogLocatora  
    LogLocator for Colorbarbar

    This locator is just a `.LogLocator` except the min and max are
    clipped by the norm's min and max (i.e. vmin/vmax from the
    image/pcolor/contour object).  This is necessary so ticks don't
    extrude into the "extend regions".

    c                    s   || _ tƒ j||Ž dS )zú
        This ticker needs to know the *colorbar* so that it can access
        its *vmin* and *vmax*.  Otherwise it is the same as
        `~.ticker.LogLocator`.  The ``*args`` and ``**kwargs`` are the
        same as `~.ticker.LogLocator`.
        Nr   )r   r   r   Úkwargsr   r   r   r   '  s    z_ColorbarLogLocator.__init__c                    s   ||kr|| }}t || jjjƒ}t|| jjjƒ}tƒ  ||¡}t 	|¡t 	|¡ d }|t 	|¡t 	|¡| kt 	|¡t 	|¡| k@  }|S r    )
r"   r   r#   r$   r%   r&   r   r'   ÚnpÚlog10r(   r   r   r   r'   1  s    
ÿz_ColorbarLogLocator.tick_valuesr+   r   r   r   r   r4     s   	
r4   c                       s6   e Zd Z‡ fdd„Zd
dd„Zdd„ Zdd	„ Z‡  ZS )Ú_ColorbarSpinec                    s$   t ƒ  |dtjt d¡dd¡ d S )Nr   ©r   r   T©Úclosed)r   r   ÚmpathÚPathr6   Úempty)r   Úaxesr   r   r   r   >  s    
ÿz_ColorbarSpine.__init__Nc                 C   s   t jj| |dS )N)Úrenderer)ÚmpatchesÚPatchÚget_window_extent)r   r@   r   r   r   rC   B  s    z _ColorbarSpine.get_window_extentc                 C   s   t j|dd| _d| _d S )NTr:   )r<   r=   Ú_pathÚstale)r   Úxyr   r   r   Úset_xyH  s    z_ColorbarSpine.set_xyc                 C   s   t j | |¡}d| _|S )NF)rA   rB   ÚdrawrE   )r   r@   Úretr   r   r   rH   L  s    z_ColorbarSpine.draw)N)r,   r-   r.   r   rC   rG   rH   r0   r   r   r   r   r8   =  s   
r8   c                   @   s&  e Zd ZdZdZe dd¡dHdd„ƒZdd„ Zdd„ Z	dd„ Z
e d¡dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdId d!„ZdJd"d#„ZdKd$d%„Zd&d'„ Zd(d)„ Zdd*œd+d,„Zd-d.„ Zd/d0„ Zd1d2„ ZdLd3d4„Zd5d6„ ZdMd7d8„ZdNd:d;„Zd<d=„ Zd>d?„ Z d@dA„ Z!dBdC„ Z"dDdE„ Z#dFdG„ Z$dS )OÚColorbarBaseaJ  
    Draw a colorbar in an existing axes.

    There are only some rare cases in which you would work directly with a
    `.ColorbarBase` as an end-user. Typically, colorbars are used
    with `.ScalarMappable`\s such as an `.AxesImage` generated via
    `~.axes.Axes.imshow`. For these cases you will use `.Colorbar` and
    likely create it via `.pyplot.colorbar` or `.Figure.colorbar`.

    The main application of using a `.ColorbarBase` explicitly is drawing
    colorbars that are not associated with other elements in the figure, e.g.
    when showing a colormap by itself.

    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::

        norm=colors.Normalize(clip=False)

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

        norm=colors.NoNorm()

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

    Attributes
    ----------
    ax : `~matplotlib.axes.Axes`
        The `~.axes.Axes` instance in which the colorbar is drawn.
    lines : list
        A list of `.LineCollection` (empty if no lines were drawn).
    dividers : `.LineCollection`
        A LineCollection (empty if *drawedges* is ``False``).

    Parameters
    ----------
    ax : `~matplotlib.axes.Axes`
        The `~.axes.Axes` instance in which the colorbar is drawn.
    cmap : `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
        The colormap to use.
    norm : `~matplotlib.colors.Normalize`

    alpha : float
        The colorbar transparency between 0 (transparent) and 1 (opaque).

    values

    boundaries

    orientation : {'vertical', 'horizontal'}

    ticklocation : {'auto', 'left', 'right', 'top', 'bottom'}

    extend : {'neither', 'both', 'min', 'max'}

    spacing : {'uniform', 'proportional'}

    ticks : `~matplotlib.ticker.Locator` or array-like of float

    format : str or `~matplotlib.ticker.Formatter`

    drawedges : bool

    filled : bool

    extendfrac

    extendrec

    label : str
    é2   ú3.3ÚcmapNÚverticalr   ÚuniformFTÚ c                 C   sh  t jtjd g|d t jddg|d t jddddd	g|d
 t jddg|
d || _t |_|_|j	dd |d kr~t
 ¡ }|d krŽt ¡ }|	d kr¬t|dƒr¨|j}	nd}	|| _|| _|| _|| _|| _|	| _t jtdd ƒtddƒtdd ƒtddƒdœ|	d| _|
| _|| _|| _|| _|| _|| _d | _g | _g | _|j  ¡ D ]}| !d¡ qBt"|ƒ | _#|j d< t$j%t& 'd¡t(j)d ddd| _*| +| j*¡ t,j-g t(j)d gdt(j)d  gd| _.| j /| j.¡ d | _0d | _1d | _2d | _3|dkrü|dkrød	nd}|| _4|  5|¡ |  6¡  t& 7|¡r6t8j9|t:|ƒd | _0n|| _0t;|t<ƒrVt8 =|¡| _1n|| _1|  >¡  d S )!N)rM   rN   Ú
horizontal©Úorientationr   ÚleftÚrightÚtopÚbottom)ÚticklocationrO   Zproportional)ÚspacingF)ZnavigateÚextendÚneitherr   r   éÿÿÿÿ)r[   Úbothr%   r"   ©rZ   Úoutliner9   úaxes.facecolorç{®Gáz„?©ÚcolorÚ	linewidthZzorderzaxes.edgecolorç      à?zaxes.linewidth)r   Ú
linewidths©r   )?r   Zcheck_isinstancer   ZColormapÚcheck_in_listÚaxr   Z
set_xticksZ
set_yticksÚsetr   Zget_cmapÚ	NormalizeÚhasattrrZ   ÚalpharM   r#   ÚvaluesÚ
boundariesÚcheck_getitemÚsliceÚ_insiderY   rS   Ú	drawedgesÚfilledÚ
extendfracÚ
extendrectÚsolidsÚsolids_patchesÚlinesÚspinesÚset_visibler8   r_   rA   ÚPolygonr6   r>   ÚmplÚrcParamsÚpatchÚ
add_artistr   ÚLineCollectionÚdividersÚadd_collectionÚlocatorÚ	formatterÚ_manual_tick_data_valuesÚ_ColorbarBase__scalerX   Ú	set_labelÚ_reset_locator_formatter_scaleÚiterabler   ÚFixedLocatorÚlenÚ
isinstanceÚstrZFormatStrFormatterÚdraw_all)r   ri   rM   r#   rm   rn   ro   rS   rX   rZ   rY   r)   Úformatrs   rt   ru   rv   ÚlabelÚspiner   r   r   r   ž  sœ     ÿþ ÿ
 ÿý  þ
ý

zColorbarBase.__init__c                 C   s
   | j dkS )z-Return whether the lower limit is open ended.©r]   r%   r^   ©r   r   r   r   Ú_extend_lower  s    zColorbarBase._extend_lowerc                 C   s
   | j dkS )z-Return whether the upper limit is open ended.©r]   r"   r^   r”   r   r   r   Ú_extend_upper  s    zColorbarBase._extend_upperc           
   	   C   s(  |   ¡  |  ¡  | j| j ddg \| _| _|  ¡ \}}t |ddddgdf |dddddgdf g¡}t |ddddgdf |dddddgdf g¡}t 	||g¡}|j
dd\}}|jdd\}}	| jj||f||	fd | j |¡ | j |¡ |  ¡  | jr$|  ||| jdd…tjf ¡ dS )zs
        Calculate any free parameters based on the current cmap and norm,
        and do all the drawing.
        r   r\   r   éþÿÿÿ©Zaxis)ZxlimZylimN)Ú_config_axisÚ_process_valuesÚ_boundariesrr   r$   r&   Ú_meshr6   ZconcatenateZcolumn_stackr%   r"   ri   rj   r_   rG   r   Úupdate_ticksrt   Ú_add_solidsÚ_valuesZnewaxis)
r   ÚXÚYÚxÚyrF   ZxminZyminZxmaxZymaxr   r   r   r   	  s    00zColorbarBase.draw_allc                 C   s   |   ¡  d S ©N)rš   r”   r   r   r   Úconfig_axis%  s    zColorbarBase.config_axisc                 C   s†   | j }| jdkr2|j|j }}tjd rR|  ¡  n |j|j }}tjd rR|  ¡  |j| j| jd | 	g ¡ |j	g dd d| _
dS )zSet up long and short axis.rN   zytick.minor.visiblezxtick.minor.visible)Zlabel_positionZticks_positionT)ÚminorN)ri   rS   ÚyaxisÚxaxisr}   r~   Úminorticks_onrj   rX   Ú	set_ticksrE   )r   ri   Ú	long_axisZ
short_axisr   r   r   rš   )  s    



ÿ
zColorbarBase._config_axisc                 C   sn  | j }| j}|dkrø| jdkrÞt| jtjƒrVt| jƒ}dt	|d ƒ }t
j|dd}qøt| jtjƒr|| jj}t
j|dd}qøt| jtjƒr”t| ƒ}qøt| jtjƒrÀt
jt dd¡| jjdd}qøtjd rÔt
 ¡ }qøt| ƒ}n| j| j }t
j|dd}|dkrHt| jtjƒrt
 ¡ }n*t| jtjƒr>t
j| jjd	}nt
 ¡ }n| j}|| _ || _t d
|¡ ||fS )a  
        Return the ``locator`` and ``formatter`` of the colorbar.

        If they have not been defined (i.e. are *None*), suitable formatter
        and locator instances will be created, attached to the respective
        attributes and returned.
        Nr   r   r   )ÚbaseÚoffsetrg   )ÚsubsÚ	linthreshr­   z_internal.classic_mode)r°   zlocator: %r)r„   r…   ro   r   r#   r   ÚNoNormrŒ   r    Úintr   ZIndexLocatorÚBoundaryNormr‹   ÚLogNormr4   Z
SymLogNormZSymmetricalLogLocatorr6   Úaranger°   r}   r~   ÚMaxNLocatorr   rœ   rr   ÚLogFormatterSciNotationZScalarFormatterÚ_logÚdebug)r   r„   r…   Únvr­   Úbr   r   r   Ú_get_ticker_locator_formatter:  sJ    



ý




ÿ
z*ColorbarBase._get_ticker_locator_formatterc                 C   s0   | j dk	o| jdk}t| jƒtjtjfko.| S )z‹
        Return if we should use an adjustable tick locator or a fixed
        one.  (check is used twice so factored out here...)
        NrO   )ro   rY   Útyper#   r   rk   r´   )r   Z
contouringr   r   r   Ú_use_auto_colorbar_locatoro  s    ÿz'ColorbarBase._use_auto_colorbar_locatorc                 C   s|   d| _ d| _t| jtjƒrB| j d¡ | j d¡ |  	¡  d| _
n6| j d¡ | j d¡ t| jƒtjkrrd| _
nd| _
dS )zß
        Reset the locator et al to defaults.  Any user-hardcoded changes
        need to be re-entered if this gets called (either at init, or when
        the mappable normal gets changed: Colorbar.update_normal)
        NÚlogZlinearÚmanual)r„   r…   r   r#   r   r´   ri   Z
set_xscaleZ
set_yscalerª   r‡   r½   rk   r”   r   r   r   r‰   x  s    z+ColorbarBase._reset_locator_formatter_scalec                 C   s”   | j }|  ¡ \}}| jdkr"|jn|j}|  ¡ rRt d|¡ | |¡ | 	|¡ n>t d¡ |  
||¡\}}}| |¡ | |¡ | ¡  |¡ dS )z”
        Force the update of the ticks and ticklabels. This must be
        called whenever the tick locator and/or tick formatter changes.
        rN   z*Using auto colorbar locator %r on colorbarzUsing fixed locator on colorbarN)ri   r¼   rS   r¨   r©   r¾   r¸   r¹   Zset_major_locatorZset_major_formatterÚ_tickerr«   Úset_ticklabelsZget_major_formatterZset_offset_string)r   ri   r„   r…   r¬   r)   Ú
ticklabelsÚoffset_stringr   r   r   rž     s    



zColorbarBase.update_ticksc                 C   s<   t  |¡r tj|t|ƒd| _n|| _|r2|  ¡  d| _dS )a  
        Set tick locations.

        Parameters
        ----------
        ticks : array-like or `~matplotlib.ticker.Locator` or None
            The tick positions can be hard-coded by an array of values; or
            they can be defined by a `.Locator`. Setting to *None* reverts
            to using a default locator.

        update_ticks : bool, default: True
            If True, tick locations are updated immediately.  If False, the
            user has to call `update_ticks` later to update the ticks.

        rg   TN)r6   rŠ   r   r‹   rŒ   r„   rž   rE   )r   r)   rž   r   r   r   r«   £  s    
zColorbarBase.set_ticksc                 C   s8   | j dkr.| j}| jdkr |jn|j}| ¡ S | j S dS )z*Return the x ticks as a list of locations.NrN   )r†   ri   rS   r¨   r©   Zget_majorticklocs)r   r§   ri   r¬   r   r   r   Ú	get_ticks¼  s    
ÿzColorbarBase.get_ticksc                 C   s<   t | jtjƒr(t |¡| _|r2|  ¡  n
t d¡ d| _	dS )z³
        Set tick labels.

        Tick labels are updated immediately unless *update_ticks* is *False*,
        in which case one should call `.update_ticks` explicitly.
        z"set_ticks() must have been called.TN)
r   r„   r   r‹   ZFixedFormatterr…   rž   r   r
   rE   )r   rÃ   rž   r   r   r   rÂ   È  s    

zColorbarBase.set_ticklabelsc                 C   s^   | j }| jdkr|jn|j}| ¡ dkrL| t| ddd¡ | t 	¡ ¡ n| t
| ƒ¡ dS )zn
        Turn the minor ticks of the colorbar on without extruding
        into the "extend regions".
        rN   r¿   g      $@r   )r­   r¯   N)ri   rS   r¨   r©   Z	get_scaleÚset_minor_locatorr4   Zset_minor_formatterr   r·   r1   ©r   ri   r¬   r   r   r   rª   ×  s    
ÿzColorbarBase.minorticks_onc                 C   s.   | j }| jdkr|jn|j}| t ¡ ¡ dS )z)Turn the minor ticks of the colorbar off.rN   N)ri   rS   r¨   r©   rÆ   r   ZNullLocatorrÇ   r   r   r   Úminorticks_offæ  s    zColorbarBase.minorticks_off)Úlocc                K   sF   | j dkr$| jj|fd|i|—Ž n| jj|fd|i|—Ž d| _dS )a¤  
        Add a label to the long axis of the colorbar.

        Parameters
        ----------
        label : str
            The label text.
        loc : str, optional
            The location of the label.

            - For horizontal orientation one of {'left', 'center', 'right'}
            - For vertical orientation one of {'bottom', 'center', 'top'}

            Defaults to :rc:`xaxis.labellocation` or :rc:`yaxis.labellocation`
            depending on the orientation.
        **kwargs
            Keyword arguments are passed to `~.Axes.set_xlabel` /
            `~.Axes.set_ylabel`.
            Supported keywords are *labelpad* and `.Text` properties.
        rN   rÉ   TN)rS   ri   Z
set_ylabelZ
set_xlabelrE   )r   r‘   rÉ   r5   r   r   r   rˆ   ì  s    
zColorbarBase.set_labelc                 C   s    | j dk	r| j  ¡  | jD ]}| ¡  qt| ddƒ}t|tjƒrftdd„ |jD ƒƒrf|  	||||¡ n|  
|||¡ | j | jr–t ||g¡dd… ng ¡ dS )z+Draw the colors; optionally add separators.NÚmappablec                 s   s   | ]}|d k	V  qd S r¥   r   )Ú.0Úhatchr   r   r   Ú	<genexpr>  s     z+ColorbarBase._add_solids.<locals>.<genexpr>r   r\   )rw   Úremoverx   Úgetattrr   r   Ú
ContourSetÚanyÚhatchesÚ_add_solids_patchesÚ_add_solids_pcolormeshr‚   Zset_segmentsrs   r6   Zdstack)r   r¡   r¢   ÚCZsolidrÊ   r   r   r   rŸ     s    



ÿÿzColorbarBase._add_solidsc              
   C   st   t  d¡ |jd |jd kr*|d d… }| jj|||| j| j| jddd| _| j	spt
| jƒ| jkrp| j d¡ d S )NzSetting pcolormeshr   r\   ÚnoneZflat)rM   r#   rm   Z
edgecolorsZshadingT)r¸   r¹   Úshaperi   Z
pcolormeshrM   r#   rm   rw   rs   rŒ   Ú_yÚn_rasterizeZset_rasterized)r   r¡   r¢   rÕ   r   r   r   rÔ     s     
      þz#ColorbarBase._add_solids_pcolormeshc           
   
   C   sð   |j t|ƒ }g }tt|ƒd ƒD ]Â}t ||df ||df g||df ||df g||d df ||d df g||d df ||d df gg¡}tjt |¡|  	|  
|| d ¡¡|| dd| jd}	| j |	¡ | |	¡ q"|| _d S )Nr   r   F)Z	facecolorrÌ   rd   Zantialiasedrm   )rÒ   rŒ   Úranger6   ÚarrayrA   Z	PathPatchr<   r=   rM   r#   rm   ri   Z	add_patchÚappendrx   )
r   r¡   r¢   rÕ   rÊ   rÒ   ÚpatchesÚirF   r   r   r   r   rÓ   %  s$    ý  ýz ColorbarBase._add_solids_patchesc                 C   s0  |   |¡}| jd | jd  d }|| jd | k || jd | k@ }|| }t |¡rft |¡| }t |¡r~t |¡| }t | jd | jd g|¡\}}	| jdkr¼tj||	gdd}
ntj|	|gdd}
tj	|
|d}|r| j
r| j
D ]}| ¡  qðg | _
| j
 |¡ | |¡ | j |¡ d| _dS )	aQ  
        Draw lines on the colorbar.

        The lines are appended to the list :attr:`lines`.

        Parameters
        ----------
        levels : array-like
            The positions of the lines.
        colors : color or list of colors
            Either a single color applying to all lines or one color value for
            each line.
        linewidths : float or array-like
            Either a single linewidth applying to all lines or one linewidth
            for each line.
        erase : bool, default: True
            Whether to remove any previously added lines.
        r\   r   r!   rN   r™   )rf   TN)Ú_locaterØ   r6   rŠ   ÚasarrayÚmeshgridrS   Ústackr   r   ry   rÎ   rÜ   Z	set_colorri   rƒ   rE   )r   Úlevelsr   rf   Úeraser¤   r*   Zigoodr¡   r¢   rF   ÚcolÚlcr   r   r   Ú	add_lines5  s*    
$

 



zColorbarBase.add_linesc           	      C   s0  t | jtjƒr.| jdkr.| jd | jd f}n| j| jf}|j|d d |j|d d |j	|Ž  |j
|Ž  |j	|Ž  |j
|Ž  t |ƒ ¡}t |tjƒrÌd}|||d d|  k||d d|  k@  }n8|d |d  d }|||d | k||d | k@  }|| _|  |¡}| |¡}| ¡ }|||fS )zŒ
        Return the sequence of ticks (colorbar data locations),
        ticklabels (strings), and the corresponding offset string.
        Nr   r\   )Zminposr!   r   )r   r#   r   r±   ro   r    r$   r&   Zcreate_dummy_axisZset_view_intervalZset_data_intervalr6   rÛ   r   Ú
LogLocatorr†   rß   Zformat_ticksZ
get_offset)	r   r„   r…   Zintvr»   Zepsr)   rÃ   rÄ   r   r   r   rÁ   `  s(    



.$

zColorbarBase._tickerc                 C   s”  |dkr| j }|dk	rˆtj|td| _| jdkrvd| jdd… | jdd…   | _t| jt	j
ƒr„| jd  tj¡| _nt | j¡| _dS | jdk	r6t | j¡| _| j dkr$t t| jƒd ¡}d| jdd… | jdd…   |dd…< d|d  |d  |d	< d|d
  |d  |d< || _dS t | j ¡| _dS t| jt	j
ƒrÎ|  | jjd ¡| jj d }tjt|ƒd tjd}tj| jjtjd|| j< |  ¡ r¨d|d	< |  ¡ r¾| jj|d< || _|| _dS t| jt	jƒr¬t| jj ƒ}|  ¡ r|d	 d g| }|  ¡ r"||d d g }t |¡}t t|ƒd ¡}| jj }d|dd… |dd…   || j< |  ¡ r‚|d	 d |d	< |  ¡ rœ|d d |d< || _|| _dS | j ¡ sÈd	| j_d| j_tj| jj| jjdd\| j_| j_| j |  | jjd ¡¡}t| jt	jt	j fƒrR|  ¡ r6d|d	  |d	< |  ¡ r†d|d  |d< n4|  ¡ rl|d	 d |d	< |  ¡ r†|d d |d< |  !|¡ dS )zÆ
        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*.
        N)Zdtypere   r\   r   gñhãˆµøä>g       @r   r   r˜   éýÿÿÿçš™™™™™¹?)ZexpandergÍÌÌÌÌÌì?gš™™™™™ñ?)"ro   r6   rà   Úfloatrœ   rn   r    r   r#   r   r±   ZastypeZint16rÛ   ÚzerosrŒ   Ú
_uniform_yrM   ÚNrµ   rr   r•   r—   r³   ÚlistZscaledr$   r&   ÚmtransformsZnonsingularÚinverseZ	PowerNormr´   r›   )r   r»   ÚvZbir   r   r   r›   }  sŒ    
ÿ(




"

ý



zColorbarBase._process_valuesçš™™™™™©?c              
   C   s    t  ||g¡}t|tƒr>tjdg| ¡ d ||g|dd…< n^|dk	rœz$||dd…< t  |¡ ¡ rht	ƒ ‚W n0 t
t	fk
rš } zt	dƒ|‚W 5 d}~X Y nX |S )z
        Return the lengths of colorbar extensions.

        This is a helper method for _uniform_y and _proportional_y.
        r   )ru   Nzinvalid value for extendfrac)r6   rÛ   r   rŽ   r   rh   ÚlowerÚisnanrÑ   Ú
ValueErrorÚ	TypeError)r   ÚfracÚautominÚautomaxÚdefaultÚextendlengthÚerrr   r   r   Ú_get_extension_lengthsÒ  s    

z#ColorbarBase._get_extension_lengthsc                 C   sÞ   | j dkrt dd|¡}nÀd|d   }}| j| j||dd}| j dkrzt |d d	¡}d
|d  |d< d|d  |d< nL| j dkr¦t |d d	¡}d
|d  |d< n t |d d	¡}d|d  |d< t dd|¡|| j< |S )zv
        Return colorbar data coordinates for *N* uniformly
        spaced boundaries, plus ends if required.
        r[   r   r   ç      ð?ró   ©rû   r]   r   Údç        r\   r%   )rZ   r6   Zlinspacerþ   ru   rì   rr   )r   rî   r¤   rù   rú   rü   r   r   r   rí   ë  s&    
 þ

zColorbarBase._uniform_yc                 C   s¸  t | jtjƒr8| j| jd  }|| jd | jd   }n |  | j ¡ ¡}tj |tj	¡}| j
dkrœ|d |d  }|d |d  | }|d |d  | }nˆ| j
dkrà|d |d  }|d |d  | }|d |d  | }nD| j
d	kr$|d |d  }|d |d  | }|d |d  | }| j
d
krD| j| j||dd}| j
dkr`d|d  |d< | j
dkr|d|d  |d< || j }t |d |d ¡}tj ||ƒtj	¡|| j< |S )zi
        Return colorbar data coordinates for the boundaries of
        a proportional colorbar.
        r   r\   r%   r   r   r˜   r"   ré   r]   )r]   r%   r"   ró   r   r“   r  r–   rÿ   )r   r#   r   r³   rœ   Úcopyr6   Úmart   ÚnanrZ   rþ   ru   rr   rk   )r   r¤   Úclenrù   rú   rü   Úyir#   r   r   r   Ú_proportional_y  s>    

 þ
zColorbarBase._proportional_yc           	      C   s6  t   | j¡}| j|_| j|_t ddg¡}| jdkrPt| j| j	 ƒ}|  
|¡}n|  ¡ }t dg¡}| jdkrŽ| |¡}| |¡}| |¡}n6| j| j }|| | j }|| | j }|| | j }|| _t ||¡\}}|  ¡ rø| jsø||ddd…f< |  ¡ r| js||ddd…f< | jd	kr.||fS ||fS )
zµ
        Return the coordinate arrays for the colorbar pcolormesh/patches.

        These are scaled between vmin and vmax, and already handle colorbar
        orientation.
        r  rÿ   rO   re   rÀ   r   Nr\   rN   )r  r#   r$   r&   r6   rÛ   rY   rŒ   rœ   rr   rí   r  r‡   rñ   rØ   rá   r•   rv   r—   rS   )	r   r#   r£   Zn_boundaries_no_extensionsr¤   ZxmidZdvr¡   r¢   r   r   r   r   +  s0    



zColorbarBase._meshc                 C   s²   t | jtjtjfƒr | j}|}n&| j| jdd ¡ }| j|dd ¡ }|}| j}|d |d krx|dd… }|dd… }|d |d kr |dd… }|dd… }t 	|||¡}|S )zq
        Given a set of color data values, return their
        corresponding colorbar data coordinates.
        F)Zclipr   r   Nr\   r˜   )
r   r#   r   r±   r³   rœ   rt   rØ   r6   Zinterp)r   r£   r»   ZxnZbuniqueZyuniqueÚzr   r   r   rß   S  s    zColorbarBase._locatec                 C   s
   || _ dS )z<Set the transparency between 0 (transparent) and 1 (opaque).N©rm   )r   rm   r   r   r   Ú	set_alphap  s    zColorbarBase.set_alphac                 C   s   | j  ¡  dS )z%Remove this colorbar from the figure.N)ri   rÎ   r”   r   r   r   rÎ   t  s    zColorbarBase.remove)NNNNNrN   r   NrO   NNFTNFrP   )T)F)T)T)N)ró   )%r,   r-   r.   r/   rÙ   r   Zmake_keyword_onlyr   r•   r—   r   Ú
deprecatedr¦   rš   r¼   r¾   r‰   rž   r«   rÅ   rÂ   rª   rÈ   rˆ   rŸ   rÔ   rÓ   rç   rÁ   r›   rþ   rí   r  r   rß   r  rÎ   r   r   r   r   rJ   R  sb   I
                ñb
5	



+
U
'(rJ   c                 K   s<   |  ¡ D ].\}}|| kr.tjdd|›dd || |< qdS )zR
    Update dict *d* with entries in *kwargs*, which must be absent from *d*.
    rL   zThe z parameter to Colorbar has no effect because it is overridden by the mappable; it is deprecated since %(since)s and will be removed %(removal)s.)ÚmessageN)Úitemsr   Zwarn_deprecated)r  r5   Úkrò   r   r   r   Ú_add_disjoint_kwargsy  s     
ÿr  c                       sn   e Zd ZdZ‡ fdd„Zejddddd„ ƒZd‡ fd
d„	Zdd„ Z	ejddddd„ ƒZ
‡ fdd„Z‡  ZS )ÚColorbara3  
    This class connects a `ColorbarBase` to a `~.cm.ScalarMappable`
    such as an `~.image.AxesImage` generated via `~.axes.Axes.imshow`.

    .. note::
        This class is not intended to be instantiated directly; instead, use
        `.Figure.colorbar` or `.pyplot.colorbar` to create a colorbar.
    c                    s   |  ¡ d k	r| ¡  || _t||j|jd t|tjƒr–|}t|| 	¡ |j
|j|j|jd | dtj|jdd¡ tƒ j|f|Ž |jsä|  |¡ nNt|jddƒdk	r¸| d|jj¡ t|tjƒrÔt|| 	¡ d	 tƒ j|f|Ž | |_|j d
| j¡|_d S )N)rM   r#   )rm   ro   rn   rZ   rt   r)   r   rg   Úcolorbar_extendFrZ   r
  Úchanged)Z	get_arrayZautoscale_NonerÊ   r  rM   r#   r   r   rÐ   Ú	get_alphaZ_levelsZcvaluesrZ   rt   Ú
setdefaultr   r‹   rã   r   r   rç   rÏ   r  ÚmartistZArtistr   ÚcallbacksSMÚconnectÚupdate_normalÚcolorbar_cid)r   ri   rÊ   r5   Úcsr   r   r   r     s>    ú ÿ ÿzColorbar.__init__rL   r  ©Úalternativec                 C   s   t  d¡ |  |¡ dS )zÙ
        Update 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.
        zcolorbar mappable changedN)r¸   r¹   r  )r   rÊ   r   r   r   Úon_mappable_changed³  s    
zColorbar.on_mappable_changedTc                    sT   t |tjƒr|jrtdƒ‚dd„ |jD ƒ}dd„ |jD ƒ}tƒ j|j	|||d dS )av  
        Add the lines from a non-filled `~.contour.ContourSet` to the colorbar.

        Parameters
        ----------
        CS : `~.contour.ContourSet`
            The line positions are taken from the ContourSet levels. The
            ContourSet must not be filled.
        erase : bool, default: True
            Whether to remove any previously added lines.
        z+add_lines is only for a ContourSet of linesc                 S   s   g | ]}|d  ‘qS ©r   r   )rË   Úcr   r   r   Ú
<listcomp>Ì  s     z&Colorbar.add_lines.<locals>.<listcomp>c                 S   s   g | ]}|d  ‘qS r  r   )rË   Útr   r   r   r!  Í  s     )rä   N)
r   r   rÐ   rt   rö   ÚtcolorsÚtlinewidthsr   rç   rã   )r   ÚCSrä   r#  r$  r   r   r   rç   ¾  s
    zColorbar.add_linesc                 C   s€   t  d|j| j¡ || _|  | ¡ ¡ |j| _|j| jkrJ|j| _|  ¡  |  ¡  t	| jt
jƒrv| j}|jsv|  |¡ d| _dS )a
  
        Update solid patches, lines, etc.

        This is meant to be called when the norm of the image or contour plot
        to which this colorbar belongs changes.

        If the norm on the mappable is different than before, this resets the
        locator and formatter for the axis, so if these have been customized,
        they will need to be customized again.  However, if the norm only
        changes values of *vmin*, *vmax* or *cmap* then the old formatter
        and locator will be preserved.
        zcolorbar update normal %r %rTN)r¸   r¹   r#   rÊ   r  r  rM   r‰   r   r   r   rÐ   rt   rç   rE   )r   rÊ   r%  r   r   r   r  Ñ  s    
zColorbar.update_normalc                 C   s¾   | j  ¡  d| _d| _| j j ¡ D ]}| d¡ q"t| j ƒ | _| j jd< t	j
t d¡tjd ddd| _| j  | j¡ d| _g | _|  |¡ |  ¡  t| jtjƒrº| j}|jsº|  |¡ dS )	a  
        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.
        NFr_   r9   r`   ra   r\   rb   )ri   Zclar„   r…   rz   rn   r{   r8   r_   rA   r|   r6   r>   r}   r~   r   r€   rw   ry   r  r   r   rÊ   r   rÐ   rt   rç   )r   rÊ   r’   r%  r   r   r   Úupdate_bruteforceí  s*    
  þ
zColorbar.update_bruteforcec                    s¢   t ƒ  ¡  | jj | jj¡ d| j_d| j_z| jj}W n tk
rN   Y dS X z| 	¡  
¡ }| ¡ }W n* tk
r’   |jdd}| |¡ Y nX | |¡ dS )z¢
        Remove this colorbar from the figure.

        If the colorbar was created with ``use_gridspec=True`` the previous
        gridspec is restored.
        NT©Úoriginal)r   rÎ   rÊ   r  Z
disconnectr  r   r?   ÚAttributeErrorÚget_subplotspecZget_gridspecZget_topmost_subplotspecÚget_positionÚ_set_positionÚset_subplotspec)r   ri   ÚgsZsubplotspecÚposr   r   r   rÎ     s    
zColorbar.remove)T)r,   r-   r.   r/   r   r   r  r  rç   r  r&  rÎ   r0   r   r   r   r   r  †  s   	#


(r  c              
   C   s†   | d krt jddddœ|d} t jddddd	d
œdddddd
œdddddd
œdddddd
œdœ| d}|d k	r‚||d kr‚tdƒ‚|S )NrU   rW   )NrN   rQ   rR   rT   rN   )rÿ   re   )r  re   rê   )ÚlocationrS   ÚanchorÚpanchorÚpadró   rV   rQ   )re   r  )re   rÿ   ç333333Ã?)rT   rU   rV   rW   )r0  rS   z/location and orientation are mutually exclusive)r   rp   r÷   )r0  rS   Úloc_settingsr   r   r   Ú_normalize_location_orientation3  s@    
þ  ÿ  ÿ  ÿ  ÿù	÷
r6  r4  rÿ   é   c              
      s*  t ||ƒ}|d |d< |d  }|d< | d|d ¡}| d|d ¡}	t | ¡}
t | ¡ ¡ } | d  ¡ ‰ ˆ  ¡ rvdn|d }| d|¡}t‡ fd	d
„| D ƒƒs¨t	dƒ‚t
j dd„ | D ƒ¡}|}|dkr |dkrì| ||| ¡\}}}n| d| | d| ¡\}}}| d|¡ ||¡}n\|dkrB| ||| ¡\}}}n| d| | d| ¡\}}}| |d¡ ||¡}d| }t
 ||¡}| D ]@}| |jdd¡}t
 |¡}| |¡ |	dk	rŒ| |	¡ qŒˆ j|dd}| D ]}| j|g7  _qàt|| |||	|||d|_|j||dd ||fS )a&  
    Create an `~.axes.Axes` suitable for a colorbar.

    The axes is placed in the figure of the *parents* axes, by resizing and
    repositioning *parents*.

    Parameters
    ----------
    parents : `~.axes.Axes` or list of `~.axes.Axes`
        The Axes to use as parents for placing the colorbar.
    %s

    Returns
    -------
    cax : `~.axes.Axes`
        The child axes.
    kw : dict
        The reduced keyword dictionary to be passed when creating the colorbar
        instance.

    Other Parameters
    ----------------
    %s
    rS   r0  rX   r1  r2  r   ró   r3  c                 3   s   | ]}ˆ |  ¡ kV  qd S r¥   )Ú
get_figure©rË   ri   ©Úfigr   r   rÍ   v  s     zmake_axes.<locals>.<genexpr>zJUnable to create a colorbar axes as not all parents share the same figure.c                 S   s   g | ]}|j d d ¡ ‘qS )Tr'  )r+  Úfrozenr9  r   r   r   r!  |  s     zmake_axes.<locals>.<listcomp>©rT   rU   rT   r   rÿ   rW   Tr'  Fú
<colorbar>©r‘   )r0  ÚparentsÚshrinkr1  r2  ÚfractionÚaspectr3  Úbox©r1  Z
adjustable)r6  Úpopr6   rŠ   Z
atleast_1dZravelr8  Zget_constrained_layoutÚallrö   rð   ZBboxÚunionZsplitxZshrunkZanchoredZsplityZBboxTransformZ	transformr+  r,  Ú
set_anchorZadd_axesZ
_colorbarsÚdictZ_colorbar_infoÚ
set_aspect)r@  r0  rS   rB  rA  rC  r   r5  r1  Zparent_anchorZparents_iterableZpad0r3  Zparents_bboxZpbZpbcbÚ_Zpb1Zshrinking_transri   Znew_posnÚcaxÚar   r:  r   Ú	make_axesH  s`    

ÿ




ø
rO  )r0  rS   rB  rA  rC  c                K   s>  t ||ƒ}|d |d< |d  }|d< | d|d ¡}| d|d ¡}	| d|d ¡}
d|
 d|
  }|d	kr*d|d  d|  ||d d|  g}|d
krä|  ¡ jdd||d| |
 gd}|d }|d jddd|dd }nD|  ¡ jdd|d| |
 |gd}|d }|d jddd|dd }nÊ|d d|  |d|d  d|  g}|dkr¨|  ¡ jdd|d| |
 |gd}|d }|d jddd|dd }d| }nL|  ¡ jdd||d| |
 gd}|d }|d jddd|dd }d| }|  |¡ |  |d ¡ |  ¡ }|j|dd}|j||d dd ||fS )a  
    Create a `~.SubplotBase` suitable for a colorbar.

    The axes is placed in the figure of the *parent* axes, by resizing and
    repositioning *parent*.

    This function is similar to `.make_axes`. Primary differences are

    - `.make_axes_gridspec` should only be used with a `.SubplotBase` parent.

    - `.make_axes` creates an `~.axes.Axes`; `.make_axes_gridspec` creates a
      `.SubplotBase`.

    - `.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.

    Parameters
    ----------
    parent : `~.axes.Axes`
        The Axes to use as parent for placing the colorbar.
    %s

    Returns
    -------
    cax : `~.axes.SubplotBase`
        The child axes.
    kw : dict
        The reduced keyword dictionary to be passed when creating the colorbar
        instance.

    Other Parameters
    ----------------
    %s
    rS   r0  rX   r1  r2  r3  r   r   r=  rT   )ZwspaceÚwidth_ratiosr   é   )ZhspaceÚheight_ratiosrW   r>  r?  rD  rE  )	r6  rF  r*  Zsubgridspecr-  rI  r8  Zadd_subplotrK  )Úparentr0  rS   rB  rA  rC  r   r5  r1  r2  r3  Zwh_spacerR  r.  Zss_mainZss_cbrP  r;  rM  r   r   r   Úmake_axes_gridspec®  s¬    )

  ÿ  þ   ÿÿ  þ   ÿÿ  ÿ
  þ   ÿÿ
  þ   ÿÿ
rT  z3.4r  c                   @   s   e Zd ZdS )ÚColorbarPatchN)r,   r-   r.   r   r   r   r   rU    s   rU  c                 K   s   t | |f|ŽS )aÈ  
    Create a colorbar on the given axes for the given mappable.

    .. note::
        This is a low-level function to turn an existing axes into a colorbar
        axes.  Typically, you'll want to use `~.Figure.colorbar` instead, which
        automatically handles creation and placement of a suitable axes as
        well.

    Parameters
    ----------
    cax : `~matplotlib.axes.Axes`
        The `~.axes.Axes` to turn into a colorbar.
    mappable : `~matplotlib.cm.ScalarMappable`
        The mappable to be described by the colorbar.
    **kwargs
        Keyword arguments are passed to the respective colorbar class.

    Returns
    -------
    `.Colorbar`
        The created colorbar instance.
    )r  )rM  rÊ   r5   r   r   r   Úcolorbar_factory  s    rV  )NNr4  rÿ   r7  )>r/   r  ÚloggingÚtextwrapZnumpyr6   Z
matplotlibr}   r   r   r   r   r   r   Zmatplotlib.artistZartistr  Zmatplotlib.patchesrÝ   rA   Zmatplotlib.pathÚpathr<   Zmatplotlib.spinesrz   ZmspinesZmatplotlib.transformsZ
transformsrð   r   Ú	getLoggerr,   r¸   Z_make_axes_param_docZ_make_axes_other_param_docZ_colormap_kw_docZinterpdÚupdateÚindentÚparamsr	   Zcolormap_kw_docZmake_axes_kw_docr   r¶   r   ZAutoMinorLocatorr1   rè   r4   ZSpiner8   rJ   r  r  r6  ZSubstitutionrO  rT  r  rU  rV  r   r   r   r   Ú<module>   sp    
?C

þ½H!       - .
    ÿe
  ÿc