B
    ]t\Ԯ                @   s  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	Z
d dl	mZ d dl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 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* d dl+m,Z, d dl-m.Z/ d dl0m1Z2 d dl3m4Z5 d dl6m7Z8 d dl9m:Z; d dl<m=Z> d dl?m@ZA d dlBmCZD d dlEmFZG d dlHmIZJ d dlmKZKmLZLmMZMmNZNmOZO d dlPmQZQmRZRmSZS d dlTmUZUmVZV eWeXZYejZZZdd	 Z[d
d Z\dd Z]G dd deUZ^dS )    N)Number)ma)_preprocess_data)MatplotlibDeprecationWarningwarn_deprecatedSTEP_LOOKUP_MAPiterablesafe_first_element)BarContainerErrorbarContainerStemContainer)	_AxesBase_process_plot_formatc             C   s6   y| j jdk	o|| j jkS  tk
r0   || kS X dS )zReturn whether *data* can be item-accessed with *name*.

    This supports data with a dict-like interface (`in` checks item
    availability) and with numpy.arrays.
    N)dtypenamesAttributeError)dataname r   4lib/python3.7/site-packages/matplotlib/axes/_axes.py	_has_item0   s    r   c             C   s   t | dkrdgS t | dkrxt|| d s4ddgS yt| d  W n tk
rX   Y nX td| d t ddgS t | dkrdddgS tdd S )	N   y   czSecond argument {!r} is ambiguous: could be a color spec but is in data; using as data.  Either rename the entry in data or use three arguments to plot.x   zxUsing arbitrary long args with data is not supported due to ambiguity of arguments.
Use multiple plotting calls instead.)lenr   r   
ValueErrorcbookZ_warn_externalformatRuntimeWarning)argsr   r   r   r   _plot_args_replacer<   s"    
r#   c                s(   t jj|   || fdd}|S )a  
    Helper function to locate inset axes, used in
    `.Axes.inset_axes`.

    A locator gets used in `Axes.set_aspect` to override the default
    locations...  It is a function that takes an axes object and
    a renderer and tells `set_aspect` where it is to be placed.

    Here *rect* is a rectangle [l, b, w, h] that specifies the
    location for the axes in the transform given by *trans* on the
    *parent*.
    c                s,    }t |}jj }t ||}|S )N)mtransformsZTransformedBboxfiguretransFigureinverted)ZaxZrendererZbboxbbZtr)_bounds_parent_transr   r   inset_locatori   s
    z*_make_inset_locator.<locals>.inset_locator)r$   Bboxfrom_bounds)boundstransparentr,   r   )r)   r*   r+   r   _make_inset_locatorX   s
    r2   c               @   sV  e Zd ZdZd ZdddZdddZdd	 Zdd
dZdd Z	dddZ
dddZejdd Zdd ZdddddZddddddddd Zd!d" Zdd$d%Zejd&d' Zejjje_ejdd*d+Zejdd,d-Zejdd.d/Zdd0d1Zed2d3d4d5gd2d6d d:d;Zed<d=d>d5gd<d6dd?d@ZedAdBdCdDd5dEgdd6ejddGdHZed<d2ge ddIejdJdJdKdLdMZ!ed<d2gd2d6ejddOdPZ"ejdQdR Z#ejdSdT Z$ejdUdV Z%ed<gd<d6dWdX Z&ed<d2gd2d6dJe'j(dJdYfdZd[Z)ed<d2gd2d6d\d]d^d_Z*ed<d`dadbd2dcdddedfdgdhdidjgddJdkejdddmdndoZ+ejdddmdpdqZ,eddrejdsdt Z-edJddudddd(ddvdwdxZ.ed<dydzd5gdd6dd~dZ/ed<d2dhdigd2d6ejdddZ0eddrdddZ1d	ddZ2ed<d2ddDddddddg	d2d6d
ddZ3ed<d2gd2d6ejddddddddddddde4j5dd#fddZ6ejdd Z7dd Z8e9j:j;e8_dd Z<edJddudd Z=e9j>j?e=_edJddudd Z@eAj@je@_ed<d2dddgdd6dddZBeCjBjeB_edJdduejdd ZDed<d2gdd<d2dgddd ZEed<dddgdd6ejdddZFed2dddgdd6ejdddZGeddrdddZHeId#dddZJeddrejddddddddZKeddrejddddddd#dddZLeddrejddddddddZMe dd ZNeOjPjQeN_e ddĄ ZReOjPjQeR_ddƄ ZSeOjTjSjeS_ejddȄ ZUed<dgd<d6ddd΄ZVed<d2dgdd6dddЄZWed<gdd6ejddd҄ZXed<d2gd2d6ejdddԄZYed<gdd6ejdddքZZed<gdd6ejddd؄Z[ed<gdd6ejdddڄZ\ed<d2gdd6ejddd(e'j(e'j]d(dddf	dd߄Z^ed<gdd6ejdddZ_ejdddZ`dd Zaedgdd6dddZbdddZcdd Zdeejdjed_dd Zfeejdjef_dd Zgeejgjeg_dd Zheejhjeh_dS (  Axesa  
    The :class:`Axes` contains most of the figure elements:
    :class:`~matplotlib.axis.Axis`, :class:`~matplotlib.axis.Tick`,
    :class:`~matplotlib.lines.Line2D`, :class:`~matplotlib.text.Text`,
    :class:`~matplotlib.patches.Polygon`, etc., and sets the
    coordinate system.

    The :class:`Axes` instance supports callbacks through a callbacks
    attribute which is a :class:`~matplotlib.cbook.CallbackRegistry`
    instance.  The events you can connect to are 'xlim_changed' and
    'ylim_changed' and the callback will be called with func(*ax*)
    where *ax* is the :class:`Axes` instance.

    Attributes
    ----------
    dataLim : `.BBox`
        The bounding box enclosing all data displayed in the Axes.
    viewLim : `.BBox`
        The view limits in data coordinates.

    centerc             C   sH   y| j | j| jd|  }W n  tk
r>   td| Y nX | S )a  
        Get an axes title.

        Get one of the three available axes titles. The available titles
        are positioned above the axes in the center, flush with the left
        edge, and flush with the right edge.

        Parameters
        ----------
        loc : {'center', 'left', 'right'}, str, optional
            Which title to get, defaults to 'center'.

        Returns
        -------
        title : str
            The title text string.

        )leftr4   rightz'%s' is not a valid location)_left_titletitle_right_titlelowerKeyErrorr   get_text)selflocr8   r   r   r   	get_title   s    zAxes.get_titleNc             K   s   y| j | j| jd|  }W n  tk
r>   td| Y nX td td d| d}|dkrjtd }| t| |	| |
| |dk	r|
| |
| |S )	aG  
        Set a title for the axes.

        Set one of the three available axes titles. The available titles
        are positioned above the axes in the center, flush with the left
        edge, and flush with the right edge.

        Parameters
        ----------
        label : str
            Text to use for the title

        fontdict : dict
            A dictionary controlling the appearance of the title text,
            the default `fontdict` is::

               {'fontsize': rcParams['axes.titlesize'],
                'fontweight' : rcParams['axes.titleweight'],
                'verticalalignment': 'baseline',
                'horizontalalignment': loc}

        loc : {'center', 'left', 'right'}, str, optional
            Which title to set, defaults to 'center'

        pad : float
            The offset of the title from the top of the axes, in points.
            Default is ``None`` to use rcParams['axes.titlepad'].

        Returns
        -------
        text : :class:`~matplotlib.text.Text`
            The matplotlib text instance representing the title

        Other Parameters
        ----------------
        **kwargs : `~matplotlib.text.Text` properties
            Other keyword arguments are text properties, see
            :class:`~matplotlib.text.Text` for a list of valid text
            properties.
        )r5   r4   r6   z'%s' is not a valid locationzaxes.titlesizezaxes.titleweightbaseline)ZfontsizeZ
fontweightverticalalignmenthorizontalalignmentNzaxes.titlepad)r7   r8   r9   r:   r;   r   rcParamsZ_set_title_offset_transfloatZset_textupdate)r=   labelfontdictr>   Zpadkwargsr8   defaultr   r   r   	set_title   s&    *



zAxes.set_titlec             C   s   | j  }| S )z-
        Get the xlabel text string.
        )xaxis	get_labelr<   )r=   rF   r   r   r   
get_xlabel   s    
zAxes.get_xlabelc             K   s"   |dk	r|| j _| j j||f|S )a  
        Set the label for the x-axis.

        Parameters
        ----------
        xlabel : str
            The label text.

        labelpad : scalar, optional, default: None
            Spacing in points between the label and the x-axis.

        Other Parameters
        ----------------
        **kwargs : `.Text` properties
            `.Text` properties control the appearance of the label.

        See also
        --------
        text : for information on how override and the optional args work
        N)rK   labelpadset_label_text)r=   ZxlabelrG   rN   rH   r   r   r   
set_xlabel   s    zAxes.set_xlabelc             C   s   | j  }| S )z-
        Get the ylabel text string.
        )yaxisrL   r<   )r=   rF   r   r   r   
get_ylabel  s    
zAxes.get_ylabelc             K   s"   |dk	r|| j _| j j||f|S )a  
        Set the label for the y-axis.

        Parameters
        ----------
        ylabel : str
            The label text.

        labelpad : scalar, optional, default: None
            Spacing in points between the label and the y-axis.

        Other Parameters
        ----------------
        **kwargs : `.Text` properties
            `.Text` properties control the appearance of the label.

        See also
        --------
        text : for information on how override and the optional args work

        N)rQ   rN   rO   )r=   ZylabelrG   rN   rH   r   r   r   
set_ylabel  s    zAxes.set_ylabelc             C   s   t | g|\}}||fS )z
        Return handles and labels for legend

        ``ax.legend()`` is equivalent to ::

          h, l = ax.get_legend_handles_labels()
          ax.legend(h, l)

        )mlegendZ_get_legend_handles_labels)r=   Zlegend_handler_maphandleslabelsr   r   r   get_legend_handles_labels,  s    
zAxes.get_legend_handles_labelsc             O   sP   t j| gf||\}}}}t|r,tdt j| ||f|| _| j| j_| jS )a  
        Place a legend on the axes.

        Call signatures::

            legend()
            legend(labels)
            legend(handles, labels)

        The call signatures correspond to three different ways how to use
        this method.

        **1. Automatic detection of elements to be shown in the legend**

        The elements to be added to the legend are automatically determined,
        when you do not pass in any extra arguments.

        In this case, the labels are taken from the artist. You can specify
        them either at artist creation or by calling the
        :meth:`~.Artist.set_label` method on the artist::

            line, = ax.plot([1, 2, 3], label='Inline label')
            ax.legend()

        or::

            line.set_label('Label via method')
            line, = ax.plot([1, 2, 3])
            ax.legend()

        Specific lines can be excluded from the automatic legend element
        selection by defining a label starting with an underscore.
        This is default for all artists, so calling `Axes.legend` without
        any arguments and without setting the labels manually will result in
        no legend being drawn.


        **2. Labeling existing plot elements**

        To make a legend for lines which already exist on the axes
        (via plot for instance), simply call this function with an iterable
        of strings, one for each legend item. For example::

            ax.plot([1, 2, 3])
            ax.legend(['A simple line'])

        Note: This way of using is discouraged, because the relation between
        plot elements and labels is only implicit by their order and can
        easily be mixed up.


        **3. Explicitly defining the elements in the legend**

        For full control of which artists have a legend entry, it is possible
        to pass an iterable of legend artists followed by an iterable of
        legend labels respectively::

            legend((line1, line2, line3), ('label1', 'label2', 'label3'))

        Parameters
        ----------

        handles : sequence of `.Artist`, optional
            A list of Artists (lines, patches) to be added to the legend.
            Use this together with *labels*, if you need full control on what
            is shown in the legend and the automatic mechanism described above
            is not sufficient.

            The length of handles and labels should be the same in this
            case. If they are not, they are truncated to the smaller length.

        labels : sequence of strings, optional
            A list of labels to show next to the artists.
            Use this together with *handles*, if you need full control on what
            is shown in the legend and the automatic mechanism described above
            is not sufficient.

        Other Parameters
        ----------------

        %(_legend_kw_doc)s

        Returns
        -------

        :class:`matplotlib.legend.Legend` instance

        Notes
        -----

        Not all kinds of artist are supported by the legend command. See
        :doc:`/tutorials/intermediate/legend_guide` for details.

        Examples
        --------

        .. plot:: gallery/text_labels_and_annotations/legend.py

        z-legend only accepts two non-keyword arguments)rT   Z_parse_legend_argsr   	TypeErrorZLegendlegend__remove_legendZ_remove_method)r=   r"   rH   rU   rV   Z
extra_argsr   r   r   legend<  s    e
zAxes.legendc             C   s
   d | _ d S )N)rY   )r=   r[   r   r   r   rZ     s    zAxes._remove_legend   )	transformzorderc      	      K   sd   |dkr| j }|dd}t||| }|dd}t| j|jf||d|}|| | | |S )a  
        Add a child inset axes to this existing axes.

        Warnings
        --------

        This method is experimental as of 3.0, and the API may change.

        Parameters
        ----------

        bounds : [x0, y0, width, height]
            Lower-left corner of inset axes, and its width and height.

        transform : `.Transform`
            Defaults to `ax.transAxes`, i.e. the units of *rect* are in
            axes-relative coordinates.

        zorder : number
            Defaults to 5 (same as `.Axes.legend`).  Adjust higher or lower
            to change whether it is above or below data plotted on the
            parent axes.

        **kwargs

            Other *kwargs* are passed on to the `axes.Axes` child axes.

        Returns
        -------

        Axes
            The created `.axes.Axes` instance.

        Examples
        --------

        This example makes two inset axes, the first is in axes-relative
        coordinates, and the second in data-coordinates::

            fig, ax = plt.suplots()
            ax.plot(range(10))
            axin1 = ax.inset_axes([0.8, 0.1, 0.15, 0.15])
            axin2 = ax.inset_axes(
                    [5, 7, 2.3, 2.3], transform=ax.transData)

        NrF   
inset_axes)r^   rF   )Z	transAxespopr2   r3   r%   r/   Zset_axes_locatorZadd_child_axes)	r=   r/   r]   r^   rH   rF   r,   r(   inset_axr   r   r   r_     s    0


zAxes.inset_axesnonez0.5      ?g(\@)r]   	facecolor	edgecoloralphar^   c            K   s  |    |dkr| j}|dd}	|d |d f}
tj|
|d |d f|||||	|d|}| | |dk	r| }d	}g }|d |d |d  g}|d |d |d  g}xltdD ]`}xZtdD ]N}||f}|| || f}|tj||d	d
|| d|||d
g7 }| |d  qW qW | }|	| j
j}tjj| 	|}|j|jk }|j|jk }|j|jk }|j|jk }|d ||A  |d ||k |d ||k |d ||A  ||fS )a  
        Add an inset indicator to the axes.  This is a rectangle on the plot
        at the position indicated by *bounds* that optionally has lines that
        connect the rectangle to an inset axes
        (`.Axes.inset_axes`).

        Warnings
        --------

        This method is experimental as of 3.0, and the API may change.


        Parameters
        ----------

        bounds : [x0, y0, width, height]
            Lower-left corner of rectangle to be marked, and its width
            and height.

        inset_ax : `.Axes`
            An optional inset axes to draw connecting lines to.  Two lines are
            drawn connecting the indicator box to the inset axes on corners
            chosen so as to not overlap with the indicator box.

        transform : `.Transform`
            Transform for the rectangle co-ordinates. Defaults to
            `ax.transAxes`, i.e. the units of *rect* are in axes-relative
            coordinates.

        facecolor : Matplotlib color
            Facecolor of the rectangle (default 'none').

        edgecolor : Matplotlib color
            Color of the rectangle and color of the connecting lines.  Default
            is '0.5'.

        alpha : number
            Transparency of the rectangle and connector lines.  Default is 0.5.

        zorder : number
            Drawing order of the rectangle and connector lines. Default is 4.99
            (just below the default level of inset axes).

        **kwargs
            Other *kwargs* are passed on to the rectangle patch.

        Returns
        -------

        rectangle_patch: `.Patches.Rectangle`
             Rectangle artist.

        connector_lines: 4-tuple of `.Patches.ConnectionPatch`
            One for each of four connector lines.  Two are set with visibility
            to *False*,  but the user can set the visibility to True if the
            automatic choice is not deemed correct.

        NrF   indicate_insetr   r   r   r   )rd   re   rf   r^   rF   r]   zaxes fractionr   -)ZaxesAZaxesB
arrowstyler^   re   rf   )Zapply_aspect	transDatar`   mpatches	Rectangle	add_patchZget_positionrangeZConnectionPatchtransformedr%   r&   r$   r-   r.   x0x1y0y1Zset_visible)r=   r/   ra   r]   rd   re   rf   r^   rH   rF   xy	rectpatchposZcoordsAconnectsxrZyrZxcZycZxyAZxyBZbboxinsZrectbboxrq   rr   rs   rt   r   r   r   rg     sJ    @


zAxes.indicate_insetc             K   sX   |  }| }|d |d |d |d  |d |d  g}| j||f|\}}||fS )a  
        Add an inset indicator rectangle to the axes based on the axis
        limits for an *inset_ax* and draw connectors between *inset_ax*
        and the rectangle.

        Warnings
        --------

        This method is experimental as of 3.0, and the API may change.

        Parameters
        ----------

        inset_ax : `.Axes`
            Inset axes to draw connecting lines to.  Two lines are
            drawn connecting the indicator box to the inset axes on corners
            chosen so as to not overlap with the indicator box.

        **kwargs
            Other *kwargs* are passed on to `.Axes.inset_rectangle`

        Returns
        -------

        rectangle_patch: `.Patches.Rectangle`
             Rectangle artist.

        connector_lines: 4-tuple of `.Patches.ConnectionPatch`
            One for each of four connector lines.  Two are set with visibility
            to *False*,  but the user can set the visibility to True if the
            automatic choice is not deemed correct.

        r   r   )Zget_xlimZget_ylimrg   )r=   ra   rH   ZxlimZylimZrectrv   rx   r   r   r   indicate_inset_zoom^  s    #,zAxes.indicate_inset_zoomFc       	      K   sv   dd| j dd}|r&tj|||d}ntj|||d}|| |dk	rR|| || || j | | |S )at  
        Add text to the axes.

        Add the text *s* to the axes at location *x*, *y* in data coordinates.

        Parameters
        ----------
        x, y : scalars
            The position to place the text. By default, this is in data
            coordinates. The coordinate system can be changed using the
            *transform* parameter.

        s : str
            The text.

        fontdict : dictionary, optional, default: None
            A dictionary to override the default text properties. If fontdict
            is None, the defaults are determined by your rc parameters.

        withdash : boolean, optional, default: False
            Creates a `~matplotlib.text.TextWithDash` instance instead of a
            `~matplotlib.text.Text` instance.

        Returns
        -------
        text : `.Text`
            The created `.Text` instance.

        Other Parameters
        ----------------
        **kwargs : `~matplotlib.text.Text` properties.
            Other miscellaneous text parameters.

        Examples
        --------
        Individual keyword arguments can be used to override any given
        parameter::

            >>> text(x, y, s, fontsize=12)

        The default transform specifies that text is in data coords,
        alternatively, you can specify text in axis coords (0,0 is
        lower-left and 1,1 is upper-right).  The example below places
        text in the center of the axes::

            >>> text(0.5, 0.5, 'matplotlib', horizontalalignment='center',
            ...      verticalalignment='center', transform=ax.transAxes)

        You can put a rectangular box around the text instance (e.g., to
        set a background color) by using the keyword `bbox`.  `bbox` is
        a dictionary of `~matplotlib.patches.Rectangle`
        properties.  For example::

            >>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))
        r@   r5   F)rA   rB   r]   clip_on)r   r   textN)rk   mtextZTextWithDashZTextrE   set_clip_pathpatch	_add_text)	r=   r   r   srG   ZwithdashrH   rI   tr   r   r   r|     s     9



z	Axes.textc             O   sD   t j||f||}|t  d|kr6|| j | | |S )Nr{   )r}   
Annotationset_transformr$   IdentityTransformr~   r   r   )r=   r   ru   r"   rH   ar   r   r   annotate  s    
zAxes.annotater   r   c             K   s   d|krt d|  \}}| j||d | |}||k pB||k}| jdd}	tj||g||gfd|	i|}
| |
 | jd|d |
S )ag  
        Add a horizontal line across the axis.

        Parameters
        ----------
        y : scalar, optional, default: 0
            y position in data coordinates of the horizontal line.

        xmin : scalar, optional, default: 0
            Should be between 0 and 1, 0 being the far left of the plot, 1 the
            far right of the plot.

        xmax : scalar, optional, default: 1
            Should be between 0 and 1, 0 being the far left of the plot, 1 the
            far right of the plot.

        Returns
        -------
        line : :class:`~matplotlib.lines.Line2D`

        Other Parameters
        ----------------
        **kwargs :
            Valid kwargs are :class:`~matplotlib.lines.Line2D` properties,
            with the exception of 'transform':

            %(Line2D)s

        See also
        --------
        hlines : Add horizontal lines in data coordinates.
        axhspan : Add a horizontal span (rectangle) across the axis.

        Examples
        --------

        * draw a thick red hline at 'y' = 0 that spans the xrange::

            >>> axhline(linewidth=4, color='r')

        * draw a default hline at 'y' = 1 that spans the xrange::

            >>> axhline(y=1)

        * draw a default hline at 'y' = .5 that spans the middle half of
          the xrange::

            >>> axhline(y=.5, xmin=0.25, xmax=0.75)

        r]   zJ'transform' is not allowed as a kwarg;axhline generates its own transform.)ydatarH   grid)whichF)scalexscaley)	r   Z
get_ybound_process_unit_infoconvert_yunitsget_yaxis_transformmlinesLine2Dadd_lineautoscale_view)r=   r   xminxmaxrH   yminymaxZyyr   r0   lr   r   r   axhline  s    4
 
zAxes.axhlinec             K   s   d|krt d|  \}}| j||d | |}||k pB||k}| jdd}	tj||g||gfd|	i|}
| |
 | j|dd |
S )aM  
        Add a vertical line across the axes.

        Parameters
        ----------
        x : scalar, optional, default: 0
            x position in data coordinates of the vertical line.

        ymin : scalar, optional, default: 0
            Should be between 0 and 1, 0 being the bottom of the plot, 1 the
            top of the plot.

        ymax : scalar, optional, default: 1
            Should be between 0 and 1, 0 being the bottom of the plot, 1 the
            top of the plot.

        Returns
        -------
        line : :class:`~matplotlib.lines.Line2D`

        Other Parameters
        ----------------
        **kwargs :
            Valid kwargs are :class:`~matplotlib.lines.Line2D` properties,
            with the exception of 'transform':

            %(Line2D)s

        Examples
        --------
        * draw a thick red vline at *x* = 0 that spans the yrange::

            >>> axvline(linewidth=4, color='r')

        * draw a default vline at *x* = 1 that spans the yrange::

            >>> axvline(x=1)

        * draw a default vline at *x* = .5 that spans the middle half of
          the yrange::

            >>> axvline(x=.5, ymin=0.25, ymax=0.75)

        See also
        --------
        vlines : Add vertical lines in data coordinates.
        axvspan : Add a vertical span (rectangle) across the axis.
        r]   zJ'transform' is not allowed as a kwarg;axvline generates its own transform.)xdatarH   r   )r   F)r   r   )	r   Z
get_xboundr   convert_xunitsget_xaxis_transformr   r   r   r   )r=   r   r   r   rH   r   r   Zxxr   r0   r   r   r   r   axvline.  s    3
 
zAxes.axvlinec       	      K   s   | j dd}| j||g||g|d | ||g\}}| ||g\}}||f||f||f||ff}tj|f|}|| | | | jdd |S )a  
        Add a horizontal span (rectangle) across the axis.

        Draw a horizontal span (rectangle) from *ymin* to *ymax*.
        With the default values of *xmin* = 0 and *xmax* = 1, this
        always spans the xrange, regardless of the xlim settings, even
        if you change them, e.g., with the :meth:`set_xlim` command.
        That is, the horizontal extent is in axes coords: 0=left,
        0.5=middle, 1.0=right but the *y* location is in data
        coordinates.

        Parameters
        ----------
        ymin : float
               Lower limit of the horizontal span in data units.
        ymax : float
               Upper limit of the horizontal span in data units.
        xmin : float, optional, default: 0
               Lower limit of the vertical span in axes (relative
               0-1) units.
        xmax : float, optional, default: 1
               Upper limit of the vertical span in axes (relative
               0-1) units.

        Returns
        -------
        Polygon : `~matplotlib.patches.Polygon`

        Other Parameters
        ----------------
        **kwargs : `~matplotlib.patches.Polygon` properties.

        %(Polygon)s

        See Also
        --------
        axvspan : Add a vertical span across the axes.
        r   )r   )rH   F)r   )	r   r   r   r   rl   Polygonr   rn   r   )	r=   r   r   r   r   rH   r0   vertspr   r   r   axhspans  s    (

zAxes.axhspanc       	      K   s   | j dd}| j||g||g|d | ||g\}}| ||g\}}||f||f||f||fg}tj|f|}|| | | | jdd |S )a  
        Add a vertical span (rectangle) across the axes.

        Draw a vertical span (rectangle) from `xmin` to `xmax`.  With
        the default values of `ymin` = 0 and `ymax` = 1. This always
        spans the yrange, regardless of the ylim settings, even if you
        change them, e.g., with the :meth:`set_ylim` command.  That is,
        the vertical extent is in axes coords: 0=bottom, 0.5=middle,
        1.0=top but the x location is in data coordinates.

        Parameters
        ----------
        xmin : scalar
            Number indicating the first X-axis coordinate of the vertical
            span rectangle in data units.
        xmax : scalar
            Number indicating the second X-axis coordinate of the vertical
            span rectangle in data units.
        ymin : scalar, optional
            Number indicating the first Y-axis coordinate of the vertical
            span rectangle in relative Y-axis units (0-1). Default to 0.
        ymax : scalar, optional
            Number indicating the second Y-axis coordinate of the vertical
            span rectangle in relative Y-axis units (0-1). Default to 1.

        Returns
        -------
        rectangle : matplotlib.patches.Polygon
            Vertical span (rectangle) from (xmin, ymin) to (xmax, ymax).

        Other Parameters
        ----------------
        **kwargs
            Optional parameters are properties of the class
            matplotlib.patches.Polygon.

        See Also
        --------
        axhspan : Add a horizontal span across the axes.

        Examples
        --------
        Draw a vertical, green, translucent rectangle from x = 1.25 to
        x = 1.55 that spans the yrange of the axes.

        >>> axvspan(1.25, 1.55, facecolor='g', alpha=0.5)

        r   )r   )rH   F)r   )	r   r   r   r   rl   r   r   rn   r   )	r=   r   r   r   r   rH   r0   r   r   r   r   r   axvspan  s    1

zAxes.axvspanr   r   r   colors)replace_nameslabel_namerksolid c             K   s>  | j ||g||d | |}| |}| |}t|s@|g}t|sN|g}t|s\|g}t|||\}}}t|}t||j	}t||j	}dd t
|||D }tj||||d}	| j|	dd |	| t|dkr:t| | }
t| | }| }| }|
|f||ff}| | |   |	S )au  
        Plot horizontal lines at each *y* from *xmin* to *xmax*.

        Parameters
        ----------
        y : scalar or sequence of scalar
            y-indexes where to plot the lines.

        xmin, xmax : scalar or 1D array_like
            Respective beginning and end of each line. If scalars are
            provided, all lines will have same length.

        colors : array_like of colors, optional, default: 'k'

        linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, optional

        label : string, optional, default: ''

        Returns
        -------
        lines : `~matplotlib.collections.LineCollection`

        Other Parameters
        ----------------
        **kwargs :  `~matplotlib.collections.LineCollection` properties.

        See also
        --------
        vlines : vertical lines
        axhline: horizontal line across the axes
        )rH   c             S   s"   g | ]\}}}||f||ffqS r   r   ).0ZthisxminZthisxmaxthisyr   r   r   
<listcomp>$  s   zAxes.hlines.<locals>.<listcomp>)r   
linestylesrF   F)autolimr   )r   r   r   r   r   delete_masked_pointsnpravelresizeshapezipmcollLineCollectionadd_collectionrE   r   minmaxupdate_datalimr   )r=   r   r   r   r   r   rF   rH   r   linesminxmaxxminymaxycornersr   r   r   hlines  s:    &






zAxes.hlinesr   r   r   c             K   s>  | j |||g|d | |}| |}| |}t|s@|g}t|sN|g}t|s\|g}t|||\}}}t|}t||j	}t||j	}dd t
|||D }tj||||d}	| j|	dd |	| t|dkr:| }
| }t| | }t| | }|
|f||ff}| | |   |	S )a  
        Plot vertical lines.

        Plot vertical lines at each *x* from *ymin* to *ymax*.

        Parameters
        ----------
        x : scalar or 1D array_like
            x-indexes where to plot the lines.

        ymin, ymax : scalar or 1D array_like
            Respective beginning and end of each line. If scalars are
            provided, all lines will have same length.

        colors : array_like of colors, optional, default: 'k'

        linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, optional

        label : string, optional, default: ''

        Returns
        -------
        lines : `~matplotlib.collections.LineCollection`

        Other Parameters
        ----------------
        **kwargs : `~matplotlib.collections.LineCollection` properties.

        See also
        --------
        hlines : horizontal lines
        axvline: vertical line across the axes
        )r   r   rH   c             S   s"   g | ]\}}}||f||ffqS r   r   )r   thisxZthisyminZthisymaxr   r   r   r   r  s   zAxes.vlines.<locals>.<listcomp>)r   r   rF   F)r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   rE   r   r   r   r   r   )r=   r   r   r   r   r   rF   rH   r   r   r   r   r   r   r   r   r   r   vlines8  s:    &






zAxes.vlines	positionslineoffsetslinelengths
linewidthsr   
horizontalc          
   K   s  | j |||g|d | |}| |}| |}t|sB|g}n.tdd |D rddd |D }nt|g}t|dkrg S t	||d}t	||d}t	||d	}t|s|g}t|s|g}t|s|g}t|s|g}t
|d
st|s|g}t|}t|}t|}t|dkr,dg}t|dkr@dg}t|dkrTdg}t|dkrhdg}t|dkr|dg}yt|}W n tk
r   Y nX t|dkrt|dkrt|t|}d|d< t|}t|dkrt|t|}t|dkrt|t|}t|dkr>t|}|t| }t|dkrZ|gt| }t|t|krttdt|t|krtdt|t|krtdt|t|krtdt|t|krtdg }	xbt||||||D ]L\}
}}}}}tj|
||||||d}| j|dd || |	| qW t|dkrdd |D }t|dkrt| \}}t|}t|}||  }||  }|dk	r| dkr||f||ff}n||f||ff}| | |   |	S )a  
        Plot identical parallel lines at the given positions.

        *positions* should be a 1D or 2D array-like object, with each row
        corresponding to a row or column of lines.

        This type of plot is commonly used in neuroscience for representing
        neural events, where it is usually called a spike raster, dot raster,
        or raster plot.

        However, it is useful in any situation where you wish to show the
        timing or position of multiple sets of discrete events, such as the
        arrival times of people to a business on each day of the month or the
        date of hurricanes each year of the last century.

        Parameters
        ----------
        positions : 1D or 2D array-like object
            Each value is an event. If *positions* is a 2D array-like, each
            row corresponds to a row or a column of lines (depending on the
            *orientation* parameter).

        orientation : {'horizontal', 'vertical'}, optional
            Controls the direction of the event collections:

                - 'horizontal' : the lines are arranged horizontally in rows,
                  and are vertical.
                - 'vertical' : the lines are arranged vertically in columns,
                  and are horizontal.

        lineoffsets : scalar or sequence of scalars, optional, default: 1
            The offset of the center of the lines from the origin, in the
            direction orthogonal to *orientation*.

        linelengths : scalar or sequence of scalars, optional, default: 1
            The total height of the lines (i.e. the lines stretches from
            ``lineoffset - linelength/2`` to ``lineoffset + linelength/2``).

        linewidths : scalar, scalar sequence or None, optional, default: None
            The line width(s) of the event lines, in points. If it is None,
            defaults to its rcParams setting.

        colors : color, sequence of colors or None, optional, default: None
            The color(s) of the event lines. If it is None, defaults to its
            rcParams setting.

        linestyles : str or tuple or a sequence of such values, optional
            Default is 'solid'. Valid strings are ['solid', 'dashed',
            'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples
            should be of the form::

                (offset, onoffseq),

            where *onoffseq* is an even length tuple of on and off ink
            in points.

        **kwargs : optional
            Other keyword arguments are line collection properties.  See
            :class:`~matplotlib.collections.LineCollection` for a list of
            the valid properties.

        Returns
        -------

        list : A list of :class:`~.collections.EventCollection` objects.
            Contains the :class:`~.collections.EventCollection` that
            were added.

        Notes
        -----

        For *linelengths*, *linewidths*, *colors*, and *linestyles*, if only
        a single value is given, that value is applied to all lines.  If an
        array-like is given, it must have the same length as *positions*, and
        each value will be applied to the corresponding row of the array.

        Examples
        --------

        .. plot:: gallery/lines_bars_and_markers/eventplot_demo.py
        )r   r   rH   c             s   s   | ]}t |V  qd S )N)r   )r   positionr   r   r   	<genexpr>  s    z!Axes.eventplot.<locals>.<genexpr>c             S   s   g | ]}t |qS r   )r   
asanyarray)r   r   r   r   r   r     s    z"Axes.eventplot.<locals>.<listcomp>r   color	linewidth	linestyler:   Nr   z5lineoffsets and positions are unequal sized sequencesz5linelengths and positions are unequal sized sequencesz4linewidths and positions are unequal sized sequencesz0colors and positions are unequal sized sequencesz4linestyles and positions are unequal sized sequences)orientation
lineoffset
linelengthr   r   r   F)r   c             S   s,   g | ]$}t |d krt|t|fqS )r   )r   r   r   r   )r   Z_pr   r   r   r   I  s    vertical)r   r   r   r   anyr   r   r   r   Zlocal_over_kwdicthasattrasarraymcolorsto_rgba_arrayr   tilecumsumlistr   r   ZEventCollectionr   rE   appendr   r   r:   r   r   )r=   r   r   r   r   r   r   r   rH   Zcollsr   r   r   r   r   r   ZcollZmin_maxminsmaxesZminposZmaxposZminlineZmaxliner   r   r   r   	eventplot  s    Y












zAxes.eventplot)r   positional_parameter_namesr   T)r   r   c            O   sP   g }t |tjj}x(| j||D ]}| | || q"W | j||d |S )a!  
        Plot y versus x as lines and/or markers.

        Call signatures::

            plot([x], y, [fmt], data=None, **kwargs)
            plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

        The coordinates of the points or line nodes are given by *x*, *y*.

        The optional parameter *fmt* is a convenient way for defining basic
        formatting like color, marker and linestyle. It's a shortcut string
        notation described in the *Notes* section below.

        >>> plot(x, y)        # plot x and y using default line style and color
        >>> plot(x, y, 'bo')  # plot x and y using blue circle markers
        >>> plot(y)           # plot y using x as index array 0..N-1
        >>> plot(y, 'r+')     # ditto, but with red plusses

        You can use `.Line2D` properties as keyword arguments for more
        control on the appearance. Line properties and *fmt* can be mixed.
        The following two calls yield identical results:

        >>> plot(x, y, 'go--', linewidth=2, markersize=12)
        >>> plot(x, y, color='green', marker='o', linestyle='dashed',
        ...      linewidth=2, markersize=12)

        When conflicting with *fmt*, keyword arguments take precedence.

        **Plotting labelled data**

        There's a convenient way for plotting objects with labelled data (i.e.
        data that can be accessed by index ``obj['y']``). Instead of giving
        the data in *x* and *y*, you can provide the object in the *data*
        parameter and just give the labels for *x* and *y*::

        >>> plot('xlabel', 'ylabel', data=obj)

        All indexable objects are supported. This could e.g. be a `dict`, a
        `pandas.DataFame` or a structured numpy array.


        **Plotting multiple sets of data**

        There are various ways to plot multiple sets of data.

        - The most straight forward way is just to call `plot` multiple times.
          Example:

          >>> plot(x1, y1, 'bo')
          >>> plot(x2, y2, 'go')

        - Alternatively, if your data is already a 2d array, you can pass it
          directly to *x*, *y*. A separate data set will be drawn for every
          column.

          Example: an array ``a`` where the first column represents the *x*
          values and the other columns are the *y* columns::

          >>> plot(a[0], a[1:])

        - The third way is to specify multiple sets of *[x]*, *y*, *[fmt]*
          groups::

          >>> plot(x1, y1, 'g^', x2, y2, 'g-')

          In this case, any additional keyword argument applies to all
          datasets. Also this syntax cannot be combined with the *data*
          parameter.

        By default, each line is assigned a different style specified by a
        'style cycle'. The *fmt* and line property parameters are only
        necessary if you want explicit deviations from these defaults.
        Alternatively, you can also change the style cycle using the
        'axes.prop_cycle' rcParam.

        Parameters
        ----------
        x, y : array-like or scalar
            The horizontal / vertical coordinates of the data points.
            *x* values are optional. If not given, they default to
            ``[0, ..., N-1]``.

            Commonly, these parameters are arrays of length N. However,
            scalars are supported as well (equivalent to an array with
            constant value).

            The parameters can also be 2-dimensional. Then, the columns
            represent separate data sets.

        fmt : str, optional
            A format string, e.g. 'ro' for red circles. See the *Notes*
            section for a full description of the format strings.

            Format strings are just an abbreviation for quickly setting
            basic line properties. All of these and more can also be
            controlled by keyword arguments.

        data : indexable object, optional
            An object with labelled data. If given, provide the label names to
            plot in *x* and *y*.

            .. note::
                Technically there's a slight ambiguity in calls where the
                second label is a valid *fmt*. `plot('n', 'o', data=obj)`
                could be `plt(x, y)` or `plt(y, fmt)`. In such cases,
                the former interpretation is chosen, but a warning is issued.
                You may suppress the warning by adding an empty format string
                `plot('n', 'o', '', data=obj)`.


        Other Parameters
        ----------------
        scalex, scaley : bool, optional, default: True
            These parameters determined if the view limits are adapted to
            the data limits. The values are passed on to `autoscale_view`.

        **kwargs : `.Line2D` properties, optional
            *kwargs* are used to specify properties like a line label (for
            auto legends), linewidth, antialiasing, marker face color.
            Example::

            >>> plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
            >>> plot([1,2,3], [1,4,9], 'rs',  label='line 2')

            If you make multiple lines with one plot command, the kwargs
            apply to all those lines.

            Here is a list of available `.Line2D` properties:

            %(Line2D)s

        Returns
        -------
        lines
            A list of `.Line2D` objects representing the plotted data.


        See Also
        --------
        scatter : XY scatter plot with markers of varying size and/or color (
            sometimes also called bubble chart).


        Notes
        -----
        **Format Strings**

        A format string consists of a part for color, marker and line::

            fmt = '[color][marker][line]'

        Each of them is optional. If not provided, the value from the style
        cycle is used. Exception: If ``line`` is given, but no ``marker``,
        the data will be a line without markers.

        **Colors**

        The following color abbreviations are supported:

        =============    ===============================
        character        color
        =============    ===============================
        ``'b'``          blue
        ``'g'``          green
        ``'r'``          red
        ``'c'``          cyan
        ``'m'``          magenta
        ``'y'``          yellow
        ``'k'``          black
        ``'w'``          white
        =============    ===============================

        If the color is the only part of the format string, you can
        additionally use any  `matplotlib.colors` spec, e.g. full names
        (``'green'``) or hex strings (``'#008000'``).

        **Markers**

        =============    ===============================
        character        description
        =============    ===============================
        ``'.'``          point marker
        ``','``          pixel marker
        ``'o'``          circle marker
        ``'v'``          triangle_down marker
        ``'^'``          triangle_up marker
        ``'<'``          triangle_left marker
        ``'>'``          triangle_right marker
        ``'1'``          tri_down marker
        ``'2'``          tri_up marker
        ``'3'``          tri_left marker
        ``'4'``          tri_right marker
        ``'s'``          square marker
        ``'p'``          pentagon marker
        ``'*'``          star marker
        ``'h'``          hexagon1 marker
        ``'H'``          hexagon2 marker
        ``'+'``          plus marker
        ``'x'``          x marker
        ``'D'``          diamond marker
        ``'d'``          thin_diamond marker
        ``'|'``          vline marker
        ``'_'``          hline marker
        =============    ===============================

        **Line Styles**

        =============    ===============================
        character        description
        =============    ===============================
        ``'-'``          solid line style
        ``'--'``         dashed line style
        ``'-.'``         dash-dot line style
        ``':'``          dotted line style
        =============    ===============================

        Example format strings::

            'b'    # blue markers with default shape
            'ro'   # red circles
            'g-'   # green solid line
            '--'   # dashed line with default color
            'k^:'  # black triangle_up markers connected by a dotted line

        )r   r   )	r   normalize_kwargsr   r   
_alias_map
_get_linesr   r   r   )r=   r   r   r"   rH   r   liner   r   r   plot`  s     h
z	Axes.plotoc       	      K   s:   |r|  | |r| | | j|||f|}|   |S )aQ  
        Plot data that contains dates.

        Similar to `.plot`, this plots *y* vs. *x* as lines or markers.
        However, the axis labels are formatted as dates depending on *xdate*
        and *ydate*.

        Parameters
        ----------
        x, y : array-like
            The coordinates of the data points. If *xdate* or *ydate* is
            *True*, the respective values *x* or *y* are interpreted as
            :ref:`Matplotlib dates <date-format>`.

        fmt : str, optional
            The plot format string. For details, see the corresponding
            parameter in `.plot`.

        tz : [ *None* | timezone string | :class:`tzinfo` instance]
            The time zone to use in labeling dates. If *None*, defaults to
            rcParam ``timezone``.

        xdate : bool, optional, default: True
            If *True*, the *x*-axis will be interpreted as Matplotlib dates.

        ydate : bool, optional, default: False
            If *True*, the *y*-axis will be interpreted as Matplotlib dates.


        Returns
        -------
        lines
            A list of `~.Line2D` objects representing the plotted data.


        Other Parameters
        ----------------
        **kwargs
            Keyword arguments control the :class:`~matplotlib.lines.Line2D`
            properties:

            %(Line2D)s


        See Also
        --------
        matplotlib.dates : Helper functions on dates.
        matplotlib.dates.date2num : Convert dates to num.
        matplotlib.dates.num2date : Convert num to dates.
        matplotlib.dates.drange : Create an equally spaced sequence of dates.


        Notes
        -----
        If you are using custom date tickers and formatters, it may be
        necessary to set the formatters/locators after the call to
        `.plot_date`. `.plot_date` will set the default tick locator to
        `.AutoDateLocator` (if the tick locator is not already set to a
        `.DateLocator` instance) and the default tick formatter to
        `.AutoDateFormatter` (if the tick formatter is not already set to a
        `.DateFormatter` instance).
        )Z
xaxis_dateZ
yaxis_dater   r   )	r=   r   r   fmtZtzZxdateZydaterH   retr   r   r   	plot_dateR  s    B

zAxes.plot_datec                sL    fdddD } fdddD }| j d| | jd| | j| }|S )	a  
        Make a plot with log scaling on both the x and y axis.

        Call signatures::

            loglog([x], y, [fmt], data=None, **kwargs)
            loglog([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

        This is just a thin wrapper around `.plot` which additionally changes
        both the x-axis and the y-axis to log scaling. All of the concepts and
        parameters of plot can be used here as well.

        The additional parameters *basex/y*, *subsx/y* and *nonposx/y* control
        the x/y-axis properties. They are just forwarded to `.Axes.set_xscale`
        and `.Axes.set_yscale`.

        Parameters
        ----------
        basex, basey : scalar, optional, default 10
            Base of the x/y logarithm.

        subsx, subsy : sequence, optional
            The location of the minor x/y ticks. If *None*, reasonable
            locations are automatically chosen depending on the number of
            decades in the plot.
            See `.Axes.set_xscale` / `.Axes.set_yscale` for details.

        nonposx, nonposy : {'mask', 'clip'}, optional, default 'mask'
            Non-positive values in x or y can be masked as invalid, or clipped
            to a very small positive number.

        Returns
        -------
        lines
            A list of `~.Line2D` objects representing the plotted data.

        Other Parameters
        ----------------
        **kwargs
            All parameters supported by `.plot`.
        c                s    i | ]}| kr  ||qS r   )r`   )r   r   )rH   r   r   
<dictcomp>  s    zAxes.loglog.<locals>.<dictcomp>)basexsubsxnonposxc                s    i | ]}| kr  ||qS r   )r`   )r   r   )rH   r   r   r     s    )baseysubsynonposylog)r   )r   )
set_xscale
set_yscaler   )r=   r"   rH   dxdyr   r   )rH   r   loglog  s    +zAxes.loglogc                s.    fdddD }| j d| | j| }|S )aA  
        Make a plot with log scaling on the x axis.

        Call signatures::

            semilogx([x], y, [fmt], data=None, **kwargs)
            semilogx([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

        This is just a thin wrapper around `.plot` which additionally changes
        the x-axis to log scaling. All of the concepts and parameters of plot
        can be used here as well.

        The additional parameters *basex*, *subsx* and *nonposx* control the
        x-axis properties. They are just forwarded to `.Axes.set_xscale`.

        Parameters
        ----------
        basex : scalar, optional, default 10
            Base of the x logarithm.

        subsx : array_like, optional
            The location of the minor xticks. If *None*, reasonable locations
            are automatically chosen depending on the number of decades in the
            plot. See `.Axes.set_xscale` for details.

        nonposx : {'mask', 'clip'}, optional, default 'mask'
            Non-positive values in x can be masked as invalid, or clipped to a
            very small positive number.

        Returns
        -------
        lines
            A list of `~.Line2D` objects representing the plotted data.

        Other Parameters
        ----------------
        **kwargs
            All parameters supported by `.plot`.
        c                s    i | ]}| kr  ||qS r   )r`   )r   r   )rH   r   r   r      s    z!Axes.semilogx.<locals>.<dictcomp>)r   r   r   r   )r   )r   r   )r=   r"   rH   dr   r   )rH   r   semilogx  s    )zAxes.semilogxc                s.    fdddD }| j d| | j| }|S )aA  
        Make a plot with log scaling on the y axis.

        Call signatures::

            semilogy([x], y, [fmt], data=None, **kwargs)
            semilogy([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

        This is just a thin wrapper around `.plot` which additionally changes
        the y-axis to log scaling. All of the concepts and parameters of plot
        can be used here as well.

        The additional parameters *basey*, *subsy* and *nonposy* control the
        y-axis properties. They are just forwarded to `.Axes.set_yscale`.

        Parameters
        ----------
        basey : scalar, optional, default 10
            Base of the y logarithm.

        subsy : array_like, optional
            The location of the minor yticks. If *None*, reasonable locations
            are automatically chosen depending on the number of decades in the
            plot. See `.Axes.set_yscale` for details.

        nonposy : {'mask', 'clip'}, optional, default 'mask'
            Non-positive values in y can be masked as invalid, or clipped to a
            very small positive number.

        Returns
        -------
        lines
            A list of `~.Line2D` objects representing the plotted data.

        Other Parameters
        ----------------
        **kwargs
            All parameters supported by `.plot`.
        c                s    i | ]}| kr  ||qS r   )r`   )r   r   )rH   r   r   r   1  s    z!Axes.semilogy.<locals>.<dictcomp>)r   r   r   r   )r   )r   r   )r=   r"   rH   r   r   r   )rH   r   semilogy  s    )zAxes.semilogyc             K   s   | j ||f|S )aE  
        Plot the autocorrelation of *x*.

        Parameters
        ----------

        x : sequence of scalar

        detrend : callable, optional, default: `mlab.detrend_none`
            *x* is detrended by the *detrend* callable. Default is no
            normalization.

        normed : bool, optional, default: True
            If ``True``, input vectors are normalised to unit length.

        usevlines : bool, optional, default: True
            If ``True``, `Axes.vlines` is used to plot the vertical lines from
            the origin to the acorr. Otherwise, `Axes.plot` is used.

        maxlags : int, optional, default: 10
            Number of lags to show. If ``None``, will return all
            ``2 * len(x) - 1`` lags.

        Returns
        -------
        lags : array (length ``2*maxlags+1``)
            lag vector.
        c : array  (length ``2*maxlags+1``)
            auto correlation vector.
        line : `.LineCollection` or `.Line2D`
            `.Artist` added to the axes of the correlation.

             `.LineCollection` if *usevlines* is True
             `.Line2D` if *usevlines* is False
        b : `.Line2D` or None
            Horizontal line at 0 if *usevlines* is True
            None *usevlines* is False

        Other Parameters
        ----------------
        linestyle : `.Line2D` property, optional, default: None
            Only used if usevlines is ``False``.

        marker : str, optional, default: 'o'

        Notes
        -----
        The cross correlation is performed with :func:`numpy.correlate` with
        ``mode = 2``.
        )xcorr)r=   r   rH   r   r   r   acorr8  s    4z
Axes.acorr
   c             K   s0  t |}|t |krtd|t|}|t|}tj||dd}	|rn|	tt||t||  }	|dkr~|d }||ks|dk rtd| t| |d }
|	|d | ||  }	|r| j|
dg|	f|}|	dd	 | j
f |}n.|d
d |dd | j|
|	f|\}d}|
|	||fS )a+  
        Plot the cross correlation between *x* and *y*.

        The correlation with lag k is defined as
        :math:`\sum_n x[n+k] \cdot y^*[n]`, where :math:`y^*` is the complex
        conjugate of :math:`y`.

        Parameters
        ----------
        x : sequence of scalars of length n

        y : sequence of scalars of length n

        detrend : callable, optional, default: `mlab.detrend_none`
            *x* is detrended by the *detrend* callable. Default is no
            normalization.

        normed : bool, optional, default: True
            If ``True``, input vectors are normalised to unit length.

        usevlines : bool, optional, default: True
            If ``True``, `Axes.vlines` is used to plot the vertical lines from
            the origin to the acorr. Otherwise, `Axes.plot` is used.

        maxlags : int, optional
            Number of lags to show. If None, will return all ``2 * len(x) - 1``
            lags. Default is 10.

        Returns
        -------
        lags : array (length ``2*maxlags+1``)
            lag vector.
        c : array  (length ``2*maxlags+1``)
            auto correlation vector.
        line : `.LineCollection` or `.Line2D`
            `.Artist` added to the axes of the correlation

             `.LineCollection` if *usevlines* is True
             `.Line2D` if *usevlines* is False
        b : `.Line2D` or None
            Horizontal line at 0 if *usevlines* is True
            None *usevlines* is False

        Other Parameters
        ----------------
        linestyle : `.Line2D` property, optional
            Only used if usevlines is ``False``.

        marker : string, optional
            Default is 'o'.

        Notes
        -----
        The cross correlation is performed with :func:`numpy.correlate` with
        ``mode = 2``.
        zx and y must be equal lengthr   )modeNr   z.maxlags must be None or strictly positive < %dr   rF   r   markerr   r   None)r   r   r   r   Z	correlatesqrtdotaranger   r`   r   
setdefaultr   )r=   r   r   normeddetrendZ	usevlinesZmaxlagsrH   NxZcorrelsZlagsr   br   r   r   r   n  s0    ;"z
Axes.xcorrpre)wherec            O   s<   |dkrt dd| |dd |d< | j||f||S )a  
        Make a step plot.

        Call signatures::

            step(x, y, [fmt], *, data=None, where='pre', **kwargs)
            step(x, y, [fmt], x2, y2, [fmt2], ..., *, where='pre', **kwargs)

        This is just a thin wrapper around `.plot` which changes some
        formatting options. Most of the concepts and parameters of plot can be
        used here as well.

        Parameters
        ----------
        x : array_like
            1-D sequence of x positions. It is assumed, but not checked, that
            it is uniformly increasing.

        y : array_like
            1-D sequence of y levels.

        fmt : str, optional
            A format string, e.g. 'g' for a green line. See `.plot` for a more
            detailed description.

            Note: While full format strings are accepted, it is recommended to
            only specify the color. Line styles are currently ignored (use
            the keyword argument *linestyle* instead). Markers are accepted
            and plotted on the given positions, however, this is a rarely
            needed feature for step plots.

        data : indexable object, optional
            An object with labelled data. If given, provide the label names to
            plot in *x* and *y*.

        where : {'pre', 'post', 'mid'}, optional, default 'pre'
            Define where the steps should be placed:

            - 'pre': The y value is continued constantly to the left from
              every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
              value ``y[i]``.
            - 'post': The y value is continued constantly to the right from
              every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
              value ``y[i]``.
            - 'mid': Steps occur half-way between the *x* positions.

        Returns
        -------
        lines
            A list of `.Line2D` objects representing the plotted data.

        Other Parameters
        ----------------
        **kwargs
            Additional parameters are the same as those for `.plot`.

        Notes
        -----
        .. [notes section required to get data note injection right]
        )r  Zpostmidz7'where' argument to step must be 'pre', 'post' or 'mid'zsteps-r   r   )r   getr   )r=   r   r   r  r"   rH   r   r   r   step  s    >z	Axes.stepr5   heightwidthbottomr   re   r   
tick_labelxerryerrecolor)r   r   replace_all_args皙?)alignc      +   
   K   sd  t |tjj}|dd}|dkr.| j }|dd}|dd}	|dd}
|dd}|di }|dd	}|d
td }|	d| |	d
| |dd}|dd}|dd}|dd}d}d}|}|dkr|dkr.| 
 dkrd}d}n*|dkr.|dkr.|  dkr*d}d}|dkr^| j|||d |r| jddd n<|dkr| j|||d |r| jddd ntd| | jdk	r| |}| |}|
dk	r| |
}
| jdk	r| |}| |}|dk	r| |}tt|||||	\}}}}}	|dkr:| j}|}n|dkrN| j}|}tt|	}	ttt|td}|dkrtd}nttt|td}|dkr|dkr||d  }|}n|dkr||d  }|}n |dkr|}|}ntd| g }t|||||||	}x|D ]\}}}}}} }!tj||f|||| |!d d!}"|"| d"|"  _!|dkr|"j"j#$| n|dkr|"j"j%$| | &|" |$|" q0W |
dk	s|dk	rb|dkrd#d$ t||D }#d%d$ t||D }$n2|dkr8d&d$ t||D }#d'd$ t||D }$|	dd  | j'|#|$f||
dd(|}%nd}%|r| j(j)\}&}'t*d)d* |D }&|
dk	r|&t+|
 }&t+|&d+ d,}&|&|'f| j(_)|r| j(j,\}(})t*d-d* |D }(|dk	r|(t+| }(t+|(d+ d,}(|(|)f| j(_,| -  t.||%|d.}*| /|* |dk	r`t0|t1|}|2| |3| |*S )/a  
        Make a bar plot.

        The bars are positioned at *x* with the given *align*\ment. Their
        dimensions are given by *width* and *height*. The vertical baseline
        is *bottom* (default 0).

        Each of *x*, *height*, *width*, and *bottom* may either be a scalar
        applying to all bars, or it may be a sequence of length N providing a
        separate value for each bar.

        Parameters
        ----------
        x : sequence of scalars
            The x coordinates of the bars. See also *align* for the
            alignment of the bars to the coordinates.

        height : scalar or sequence of scalars
            The height(s) of the bars.

        width : scalar or array-like, optional
            The width(s) of the bars (default: 0.8).

        bottom : scalar or array-like, optional
            The y coordinate(s) of the bars bases (default: 0).

        align : {'center', 'edge'}, optional, default: 'center'
            Alignment of the bars to the *x* coordinates:

            - 'center': Center the base on the *x* positions.
            - 'edge': Align the left edges of the bars with the *x* positions.

            To align the bars on the right edge pass a negative *width* and
            ``align='edge'``.

        Returns
        -------
        container : `.BarContainer`
            Container with all the bars and optionally errorbars.

        Other Parameters
        ----------------
        color : scalar or array-like, optional
            The colors of the bar faces.

        edgecolor : scalar or array-like, optional
            The colors of the bar edges.

        linewidth : scalar or array-like, optional
            Width of the bar edge(s). If 0, don't draw edges.

        tick_label : string or array-like, optional
            The tick labels of the bars.
            Default: None (Use default numeric labels.)

        xerr, yerr : scalar or array-like of shape(N,) or shape(2,N), optional
            If not *None*, add horizontal / vertical errorbars to the bar tips.
            The values are +/- sizes relative to the data:

            - scalar: symmetric +/- values for all bars
            - shape(N,): symmetric +/- values for each bar
            - shape(2,N): Separate - and + values for each bar. First row
                contains the lower errors, the second row contains the
                upper errors.
            - *None*: No errorbar. (Default)

            See :doc:`/gallery/statistics/errorbar_features`
            for an example on the usage of ``xerr`` and ``yerr``.

        ecolor : scalar or array-like, optional, default: 'black'
            The line color of the errorbars.

        capsize : scalar, optional
           The length of the error bar caps in points.
           Default: None, which will take the value from
           :rc:`errorbar.capsize`.

        error_kw : dict, optional
            Dictionary of kwargs to be passed to the `~.Axes.errorbar`
            method. Values of *ecolor* or *capsize* defined here take
            precedence over the independent kwargs.

        log : bool, optional, default: False
            If *True*, set the y-axis to be log scale.

        orientation : {'vertical',  'horizontal'}, optional
            *This is for internal use only.* Please use `barh` for
            horizontal bar plots. Default: 'vertical'.

        See also
        --------
        barh: Plot a horizontal bar plot.

        Notes
        -----
        The optional arguments *color*, *edgecolor*, *linewidth*,
        *xerr*, and *yerr* can be either scalars or sequences of
        length equal to the number of bars.  This enables you to use
        bar as the basis for stacked bar charts, or candlestick plots.
        Detail: *xerr* and *yerr* are passed directly to
        :meth:`errorbar`, so they can also have shape 2xN for
        independent specification of lower and upper errors.

        Other optional kwargs:

        %(Rectangle)s

        r   Nre   r   r  r  error_kwr  r   capsizezerrorbar.capsizer   r   r   FrF   r   r  Tr   r   )r   r   rH   clip)r   )r   zinvalid orientation: %srb   r4   r   edgezinvalid alignment: %s
_nolegend_)ru   r  r  rd   re   r   rF   d   c             S   s   g | ]\}}|d |  qS )g      ?r   )r   r   wr   r   r   r   	  s    zAxes.bar.<locals>.<listcomp>c             S   s   g | ]\}}|| qS r   r   )r   r  hr   r   r   r   	  s    c             S   s   g | ]\}}|| qS r   r   )r   r   r  r   r   r   r   	  s    c             S   s   g | ]\}}|d |  qS )g      ?r   )r   r  r  r   r   r   r   	  s    )r  r  r   c             s   s   | ]}|d kr|V  qdS )r   Nr   )r   r  r   r   r   r   	  s    zAxes.bar.<locals>.<genexpr>g?g0.++c             s   s   | ]}|d kr|V  qdS )r   Nr   )r   r  r   r   r   r    	  s    )rF   )4r   r   rl   Patchr   r`   _get_patches_for_fillget_next_colorrC   r  Z
get_yscaleZ
get_xscaler   r   r   r   rK   r   rQ   r   r   broadcast_arrays
atleast_1d	itertoolscyclechainr   r   repeatr   rm   rE   get_pathZ_interpolation_stepssticky_edgesr   r   r   rn   errorbardataLimZ	intervalxr   r   	intervalyr   r
   add_containerbroadcast_tor   Z	set_ticksZset_ticklabels)+r=   r   r  r  r  r  rH   r   re   r   r  r  r  r  r  r   r   rF   Ztick_labelsZadjust_ylimZadjust_xlimr   Ztick_label_axisZtick_label_positionr5   patchesr"   r   r  r  r  r   eZlwrexZeyr(  r   r   r   r   Zbar_containerr   r   r   bar  s    x




































zAxes.barc            K   s,   | dd | jf |||||d|}|S )a  
        Make a horizontal bar plot.

        The bars are positioned at *y* with the given *align*\ment. Their
        dimensions are given by *width* and *height*. The horizontal baseline
        is *left* (default 0).

        Each of *y*, *width*, *height*, and *left* may either be a scalar
        applying to all bars, or it may be a sequence of length N providing a
        separate value for each bar.

        Parameters
        ----------
        y : scalar or array-like
            The y coordinates of the bars. See also *align* for the
            alignment of the bars to the coordinates.

        width : scalar or array-like
            The width(s) of the bars.

        height : sequence of scalars, optional, default: 0.8
            The heights of the bars.

        left : sequence of scalars
            The x coordinates of the left sides of the bars (default: 0).

        align : {'center', 'edge'}, optional, default: 'center'
            Alignment of the base to the *y* coordinates*:

            - 'center': Center the bars on the *y* positions.
            - 'edge': Align the bottom edges of the bars with the *y*
              positions.

            To align the bars on the top edge pass a negative *height* and
            ``align='edge'``.

        Returns
        -------
        container : `.BarContainer`
            Container with all the bars and optionally errorbars.

        Other Parameters
        ----------------
        color : scalar or array-like, optional
            The colors of the bar faces.

        edgecolor : scalar or array-like, optional
            The colors of the bar edges.

        linewidth : scalar or array-like, optional
            Width of the bar edge(s). If 0, don't draw edges.

        tick_label : string or array-like, optional
            The tick labels of the bars.
            Default: None (Use default numeric labels.)

        xerr, yerr : scalar or array-like of shape(N,) or shape(2,N), optional
            If not ``None``, add horizontal / vertical errorbars to the
            bar tips. The values are +/- sizes relative to the data:

            - scalar: symmetric +/- values for all bars
            - shape(N,): symmetric +/- values for each bar
            - shape(2,N): Separate - and + values for each bar. First row
                contains the lower errors, the second row contains the
                upper errors.
            - *None*: No errorbar. (default)

            See :doc:`/gallery/statistics/errorbar_features`
            for an example on the usage of ``xerr`` and ``yerr``.

        ecolor : scalar or array-like, optional, default: 'black'
            The line color of the errorbars.

        capsize : scalar, optional
           The length of the error bar caps in points.
           Default: None, which will take the value from
           :rc:`errorbar.capsize`.

        error_kw : dict, optional
            Dictionary of kwargs to be passed to the `~.Axes.errorbar`
            method. Values of *ecolor* or *capsize* defined here take
            precedence over the independent kwargs.

        log : bool, optional, default: False
            If ``True``, set the x-axis to be log scale.

        See also
        --------
        bar: Plot a vertical bar plot.

        Notes
        -----
        The optional arguments *color*, *edgecolor*, *linewidth*,
        *xerr*, and *yerr* can be either scalars or sequences of
        length equal to the number of bars.  This enables you to use
        bar as the basis for stacked bar charts, or candlestick plots.
        Detail: *xerr* and *yerr* are passed directly to
        :meth:`errorbar`, so they can also have shape 2xN for
        independent specification of lower and upper errors.

        Other optional kwargs:

        %(Rectangle)s

        r   r   )r   r  r  r  r  )r  r1  )r=   r   r  r  r5   r  rH   r-  r   r   r   barh1	  s    lz	Axes.barh)r   c             K   s~   t |rt|}nd}t |r,t|}nd}| j|||d | |}| |}tj||f|}| j|dd | 	  |S )a  
        Plot a horizontal sequence of rectangles.

        A rectangle is drawn for each element of *xranges*. All rectangles
        have the same vertical position and size defined by *yrange*.

        This is a convenience function for instantiating a
        `.BrokenBarHCollection`, adding it to the axes and autoscaling the
        view.

        Parameters
        ----------
        xranges : sequence of tuples (*xmin*, *xwidth*)
            The x-positions and extends of the rectangles. For each tuple
            (*xmin*, *xwidth*) a rectangle is drawn from *xmin* to *xmin* +
            *xwidth*.
        yranges : (*ymin*, *ymax*)
            The y-position and extend for all the rectangles.

        Other Parameters
        ----------------
        **kwargs : :class:`.BrokenBarHCollection` properties

            Each *kwarg* can be either a single argument applying to all
            rectangles, e.g.::

                facecolors='black'

            or a sequence of arguments over which is cycled, e.g.::

                facecolors=('black', 'blue')

            would create interleaving black and blue rectangles.

            Supported keywords:

            %(BrokenBarHCollection)s

        Returns
        -------
        collection : A :class:`~.collections.BrokenBarHCollection`

        Notes
        -----
        .. [Notes section required for data comment. See #10189.]

        N)r   r   rH   T)r   )
r   r   r	   r   r   r   r   ZBrokenBarHCollectionr   r   )r=   ZxrangesZyrangerH   r   r   colr   r   r   broken_barh	  s    3

zAxes.broken_barh)r  r   )linefmt	markerfmtbasefmtr  rF   c         	   G   s8  dt |  krdks(n td|t|d }|dd }|sVtt |}n"|}tj|d td}|dd }|dkry|d }W n  tk
r   d}	d}
d	}Y qX t|\}}
}	nt|\}}
}	|dkry|d }W n" tk
r   d}d
}d}Y nX t|\}}}nt|\}}}|dkr~y|d }W n2 tk
rl   t	d r\d}nd}d}d	}Y nX t|\}}}nt|\}}}| j
|||||dd\}g }xBt||D ]4\}}| j
||g||g|	||
dd\}|| qW | j
t|t|g||g|||dd\}t|||f|d}| | |S )a[	  
        Create a stem plot.

        A stem plot plots vertical lines at each *x* location from the baseline
        to *y*, and places a marker there.

        Call signature::

          stem([x,] y, linefmt=None, markerfmt=None, basefmt=None)

        The x-positions are optional. The formats may be provided either as
        positional or as keyword-arguments.

        Parameters
        ----------
        x : array-like, optional
            The x-positions of the stems. Default: (0, 1, ..., len(y) - 1).

        y : array-like
            The y-values of the stem heads.

        linefmt : str, optional
            A string defining the properties of the vertical lines. Usually,
            this will be a color or a color and a linestyle:

            =========  =============
            Character  Line Style
            =========  =============
            ``'-'``    solid line
            ``'--'``   dashed line
            ``'-.'``   dash-dot line
            ``':'``    dotted line
            =========  =============

            Default: 'C0-', i.e. solid line with the first color of the color
            cycle.

            Note: While it is technically possible to specify valid formats
            other than color or color and linestyle (e.g. 'rx' or '-.'), this
            is beyond the intention of the method and will most likely not
            result in a reasonable reasonable plot.

        markerfmt : str, optional
            A string defining the properties of the markers at the stem heads.
            Default: 'C0o', i.e. filled circles with the first color of the
            color cycle.

        basefmt : str, optional
            A format string defining the properties of the baseline.

            Default: 'C3-' ('C2-' in classic mode).

        bottom : float, optional, default: 0
            The y-position of the baseline.

        label : str, optional, default: None
            The label to use for the stems in legends.


        Returns
        -------
        container : :class:`~matplotlib.container.StemContainer`
            The container may be treated like a tuple
            (*markerline*, *stemlines*, *baseline*)


        Notes
        -----

        .. seealso::
            The MATLAB function
            `stem <http://www.mathworks.com/help/techdoc/ref/stem.html>`_
            which inspired this method.

        r   r\   z:stem expected between 1 and 5 positional arguments, got {}r   N)r   C0r   rh   r   r   z_internal.classic_modeZC2ZC3r  )r   r   r   rF   )rF   )r   rX   r    r   r   r   rD   
IndexErrorr   rC   r   r   r   r   r   r   r+  )r=   r5  r6  r7  r  rF   r"   r   r   Z	linecolorZ
linemarkerr   ZmarkercolorZmarkermarkerZmarkerstyleZ	basecolorZ
basemarkerZ	basestyleZ
markerlineZ	stemlinesr   r   r   r@   Zstem_containerr   r   r   stem	  sl    N







z	Axes.stemexploderV   333333?皙?r   r   c       (   	      s  |  d t|tj}| }|dkr0|| }|dkrFdgt| }|dkr\dgt| }t|t|krttdt|t|krtd|dkr| jj}nt	
|  fdd	}|
dkrd}
|	dkrd}n|	d
 }|dkri }|dd |dkri }|dd g }g }g }d}xjt|||D ]X\}}}|\}}|rH|| n|| }dtj d ||  }||t| 7 }||t| 7 }tj||f|
d
t|| d
t|| fd| i|}|| | | || |rt|dd}|d|   |d | | |||
 t|  } |||
 t|  }!| dkrTdpVd}"d}#d}$|r|!dkrvdpxd}#t|| dkrdnd }$t|"|#|$td d}%|%| | j| |!|f|%}&||& |dk	rr|||
 t|  } |||
 t|  }!t |t!r |d|  }'n t"|r8|d| }'nt#dtddd}%|%| | j| |!|'f|%}&||& |}|d7 }q&W |s| $d | %d|d  d |d  f | &d|d  d |d  f | 'g  | (g  |dkr||fS |||fS dS )!a   
        Plot a pie chart.

        Make a pie chart of array *x*.  The fractional area of each wedge is
        given by ``x/sum(x)``.  If ``sum(x) < 1``, then the values of *x* give
        the fractional area directly and the array will not be normalized. The
        resulting pie will have an empty wedge of size ``1 - sum(x)``.

        The wedges are plotted counterclockwise, by default starting from the
        x-axis.

        Parameters
        ----------
        x : array-like
            The wedge sizes.

        explode : array-like, optional, default: None
            If not *None*, is a ``len(x)`` array which specifies the fraction
            of the radius with which to offset each wedge.

        labels : list, optional, default: None
            A sequence of strings providing the labels for each wedge

        colors : array-like, optional, default: None
            A sequence of matplotlib color args through which the pie chart
            will cycle.  If *None*, will use the colors in the currently
            active cycle.

        autopct : None (default), string, or function, optional
            If not *None*, is a string or function used to label the wedges
            with their numeric value.  The label will be placed inside the
            wedge.  If it is a format string, the label will be ``fmt%pct``.
            If it is a function, it will be called.

        pctdistance : float, optional, default: 0.6
            The ratio between the center of each pie slice and the start of
            the text generated by *autopct*.  Ignored if *autopct* is *None*.

        shadow : bool, optional, default: False
            Draw a shadow beneath the pie.

        labeldistance : float, optional, default: 1.1
            The radial distance at which the pie labels are drawn

        startangle : float, optional, default: None
            If not *None*, rotates the start of the pie chart by *angle*
            degrees counterclockwise from the x-axis.

        radius : float, optional, default: None
            The radius of the pie, if *radius* is *None* it will be set to 1.

        counterclock : bool, optional, default: True
            Specify fractions direction, clockwise or counterclockwise.

        wedgeprops : dict, optional, default: None
            Dict of arguments passed to the wedge objects making the pie.
            For example, you can pass in ``wedgeprops = {'linewidth': 3}``
            to set the width of the wedge border lines equal to 3.
            For more details, look at the doc/arguments of the wedge object.
            By default ``clip_on=False``.

        textprops : dict, optional, default: None
            Dict of arguments to pass to the text objects.

        center :  list of float, optional, default: (0, 0)
            Center position of the chart. Takes value (0, 0) or is a sequence
            of 2 scalars.

        frame : bool, optional, default: False
            Plot axes frame with the chart if true.

        rotatelabels : bool, optional, default: False
            Rotate each label to the angle of the corresponding slice if true.

        Returns
        -------
        patches : list
            A sequence of :class:`matplotlib.patches.Wedge` instances

        texts : list
            A list of the label :class:`matplotlib.text.Text` instances.

        autotexts : list
            A list of :class:`~matplotlib.text.Text` instances for the numeric
            labels. This will only be returned if the parameter *autopct* is
            not *None*.

        Notes
        -----
        The pie chart will probably look best if the figure and axes are
        square, or the Axes aspect is equal.
        This method sets the aspect ratio of the axis to "equal".
        The axes aspect ratio can be controlled with `Axes.set_aspect`.
        equalr   Nr   r   z'label' must be of length 'x'z'explode' must be of length 'x'c                  s   t  S )N)nextr   )color_cycler   r   r    s    z Axes.pie.<locals>.get_next_colorg     v@r{   Fr   g      ?rd   g{Gzg?r  r5   r6   r4   r   r  top   zxtick.labelsize)rB   rA   Zrotationsizeg      Y@z+autopct must be callable or a format string)rB   rA   g      g      ?))
set_aspectr   arrayZfloat32sumr   r   r  r  r"  r#  r  r   ZpimathZcosZsinrl   ZWedger   r   r   rn   	set_labelZShadowZ
set_zorderZ
get_zorderZrad2degdictrC   rE   r|   
isinstancestrcallablerX   Zset_frame_onset_xlimset_ylim
set_xticks
set_yticks)(r=   r   r;  rV   r   ZautopctZpctdistanceZshadowZlabeldistanceZ
startangleZradiusZcounterclockZ
wedgepropsZ	textpropsr4   frameZrotatelabelssxr  Ztheta1ZtextsZslicesZ	autotextsiZfracrF   Zexplr   Ztheta2Zthetamr  ZshadZxtytZlabel_alignment_hZlabel_alignment_vZlabel_rotationZpropsr   r   r   )rA  r   pie
  s    e

















zAxes.piec       6      K   s  t |tjj}dd | D }|dd |dk r>td| j|||d |	 dk}|
d	d
}|dkrti }ndd tdt|D }|dkr|
d d|ksd|ks|d
k	ri }d|kr|
d|d< nt| jj}d|d	< || d|krd|d< |d
kr|d }t|s$|g}t|s4|g}|d
k	rVt|sV|gt| }|d
k	rxt|sx|gt| }||d|	r|d d n
|d d i}t|}|
dd
 |
dd
 ||d< |r||d< nd|kr|d |d< x$dD ]}||kr|| ||< qW t|}|
dd
 |
dd
 |
dd
 |
dd
 |
dd
 d|d< |d
krrtd }|dkrd| |d< |d
k	r||d< x$dD ]}||kr|| ||< qW ||d< d
}|rtj||f|}| | g }g }t|
t|t}
t|t|t}t|t|t}t|t|t}tt|| dk}dd  }d!d" }|d
k	r|||\}} ||B  }!|! st|!dkr2||| |!|@ \}"}#||| |!|@ \}$}%|| j|"|$|%f| |dkr2|tj|$|"fdd#i| |tj|%|"fdd#i| | r||| ||@ \}"}#||| ||@ \}$}%|| j|"|$|%f| || |||@ \}&}'|  rtj}(ntj }(|tj|&|'fd$|(d%| |dkr|||||@ \})}*|tj|)|*fdd#i| | r||| ||@ \}"}#|||||@ \}$}%|| j|"|$|%f| |||||@ \}+}*|  rttj }(ntj}(|tj|+|*fd$|(d%| |dkr|||||@ \},}'|tj|,|'fdd#i| |d
k	r:|||\}-}.|
|B  }/|/ st|/dkr|||-|/|@ \}0}#||-|.|/|@ \}$}1|| j!|0|$|1f| |dkr|tj|0|$fdd&i| |tj|0|1fdd&i| |
 rh|||-|
|@ \}0}#|||.|
|@ \}$}1|| j!|0|$|1f| |||.|
|@ \},}2| " rtj#}(ntj$}(|tj|,|2fd$|(d%| |dkrh||||
|@ \})}*|tj|)|*fdd&i| | r:|||-||@ \}0}#||-|||@ \}$}1|| j!|0|$|1f| |||-||@ \})}3| " rtj$}(ntj#}(|tj|)|3fd$|(d%| |dkr:|||||@ \},}'|tj|,|'fdd&i| x|D ]}4| |4 q@W | %  t&|t'|t'|f|d
k	|d
k	|d'}5| j(|5 |5S )(a~  
        Plot y versus x as lines and/or markers with attached errorbars.

        *x*, *y* define the data locations, *xerr*, *yerr* define the errorbar
        sizes. By default, this draws the data markers/lines as well the
        errorbars. Use fmt='none' to draw errorbars without any data markers.

        Parameters
        ----------
        x, y : scalar or array-like
            The data positions.

        xerr, yerr : scalar or array-like, shape(N,) or shape(2,N), optional
            The errorbar sizes:

            - scalar: Symmetric +/- values for all data points.
            - shape(N,): Symmetric +/-values for each data point.
            - shape(2,N): Separate - and + values for each bar. First row
                contains the lower errors, the second row contains the
                upper errors.
            - *None*: No errorbar.

            Note that all error arrays should have *positive* values.

            See :doc:`/gallery/statistics/errorbar_features`
            for an example on the usage of ``xerr`` and ``yerr``.

        fmt : plot format string, optional, default: ''
            The format for the data points / data lines. See `.plot` for
            details.

            Use 'none' (case insensitive) to plot errorbars without any data
            markers.

        ecolor : mpl color, optional, default: None
            A matplotlib color arg which gives the color the errorbar lines.
            If None, use the color of the line connecting the markers.

        elinewidth : scalar, optional, default: None
            The linewidth of the errorbar lines. If None, the linewidth of
            the current style is used.

        capsize : scalar, optional, default: None
            The length of the error bar caps in points. If None, it will take
            the value from :rc:`errorbar.capsize`.

        capthick : scalar, optional, default: None
            An alias to the keyword argument *markeredgewidth* (a.k.a. *mew*).
            This setting is a more sensible name for the property that
            controls the thickness of the error bar cap in points. For
            backwards compatibility, if *mew* or *markeredgewidth* are given,
            then they will over-ride *capthick*. This may change in future
            releases.

        barsabove : bool, optional, default: False
            If True, will plot the errorbars above the plot
            symbols. Default is below.

        lolims, uplims, xlolims, xuplims : bool, optional, default: None
            These arguments can be used to indicate that a value gives only
            upper/lower limits. In that case a caret symbol is used to
            indicate this. *lims*-arguments may be of the same type as *xerr*
            and *yerr*.  To use limits with inverted axes, :meth:`set_xlim`
            or :meth:`set_ylim` must be called before :meth:`errorbar`.

        errorevery : positive integer, optional, default: 1
            Subsamples the errorbars. e.g., if errorevery=5, errorbars for
            every 5-th datapoint will be plotted. The data plot itself still
            shows all data points.

        Returns
        -------
        container : :class:`~.container.ErrorbarContainer`
            The container contains:

            - plotline: :class:`~matplotlib.lines.Line2D` instance of
              x, y plot markers and/or line.
            - caplines: A tuple of :class:`~matplotlib.lines.Line2D` instances
              of the error bar caps.
            - barlinecols: A tuple of
              :class:`~matplotlib.collections.LineCollection` with the
              horizontal and vertical error ranges.

        Other Parameters
        ----------------
        **kwargs :
            All other keyword arguments are passed on to the plot
            command for the markers. For example, this code makes big red
            squares with thick green edges::

                x,y,yerr = rand(3,10)
                errorbar(x, y, yerr, marker='s', mfc='red',
                         mec='green', ms=20, mew=4)

            where *mfc*, *mec*, *ms* and *mew* are aliases for the longer
            property names, *markerfacecolor*, *markeredgecolor*, *markersize*
            and *markeredgewidth*.

            Valid kwargs for the marker properties are `.Lines2D` properties:

            %(Line2D)s

        Notes
        -----
        .. [Notes section required for data comment. See #10189.]

        c             S   s   i | ]\}}|d k	r||qS )Nr   )r   r   vr   r   r   r     s    z!Axes.errorbar.<locals>.<dictcomp>r^   r   r   z0errorevery has to be a strictly positive integer)r   r   rH   rb   rF   Nr   c             S   s   i | ]\}}|d k	r||qS )Nr   )r   r   rW  r   r   r   r     s    )r   r   r   r   r  r8  g?r   r   r   )r]   rf   r^   
rasterizedmarkerfacecolormarkeredgewidthmarkeredgecolorlszerrorbar.capsizer   g       @
markersize)rZ  r]   rf   r^   rX  c             S   sX   t | t |kstt | t |ks(tdd t| |D } dd t||D }| |fS )zo
            return xs[mask], ys[mask] where mask is True but xs and
            ys are not arrays
            c             S   s   g | ]\}}|r|qS r   r   )r   r   r  r   r   r   r   [  s    z2Axes.errorbar.<locals>.xywhere.<locals>.<listcomp>c             S   s   g | ]\}}|r|qS r   r   )r   r   r  r   r   r   r   \  s    )r   AssertionErrorr   )xsysmaskr   r   r   xywhereT  s
    zAxes.errorbar.<locals>.xywherec          	   S   s   y| \}}W n t tfk
r$   Y nFX t|rjt|rjdd t||D }dd t||D }||fS t| dkrt| }t| t|kst|dkrtddd t|| D }dd t|| D }||fS )zprivate function to compute error bars

            Parameters
            ----------
            err : iterable
                xerr or yerr from errorbar
            data : iterable
                x or y from errorbar
            c             S   s   g | ]\}}|| qS r   r   )r   r   thiserrr   r   r   r   p  s    z6Axes.errorbar.<locals>.extract_err.<locals>.<listcomp>c             S   s   g | ]\}}|| qS r   r   )r   r   rc  r   r   r   r   r  s    r   z1err must be [ scalar | N, Nx1 or 2xN array-like ]c             S   s   g | ]\}}|| qS r   r   )r   r   rc  r   r   r   r     s    c             S   s   g | ]\}}|| qS r   r   )r   r   rc  r   r   r   r     s    )	rX   r   r   r   Zsafezipr   r	   r   rD  )errr   r   r  ZlowZhighZfer   r   r   extract_err_  s&    
z"Axes.errorbar.<locals>.extract_err|r   )r\  r   _)Zhas_xerrZhas_yerrrF   ))r   r   r   r   r   itemsr  r   r   r:   r`   r   r   r@  r   Zprop_cyclerrE   r   r   rJ  rC   r   r   r,  astypeboolr   r   r   r   Zxaxis_invertedZCARETLEFTBASEZCARETRIGHTBASEr   Zyaxis_invertedZCARETDOWNBASEZCARETUPBASEr   r   tupleZ
containers)6r=   r   r   r  r  r   r  Z
elinewidthr  Z	barsaboveZlolimsZuplimsZxlolimsZxuplimsZ
erroreveryZcapthickrH   Z	plot_linerF   Zfmt_style_kwargsZ
base_styleZplot_line_styleZeb_lines_stylekeyZeb_cap_styleZ	data_lineZbarcolsZcaplinesZ	everymaskrb  re  r5   r6   ZnoxlimsZyorg  loZroZrightupZyupr   ZxloZyloZleftloZxupr:   upperZnoylimsZxoZuoZupperupZlowerlor   Zerrorbar_containerr   r   r   r(  j  sb   s



















&































zAxes.errorbarc       '      C   s  |dkrt d }|	dkr t d }	tj|||	||d}|dkrDt d }|dkrTt d }|dkrdt d }|dkrtt d }|dkrt d	 }|dkrt d
 }|dkrt d }|dkrt d }dd }dddddddg}dddg}||d|}||d|}||d|}||d|}||d|}||d|}|r<d|d< |d|d< |dk	r|dkrdtdddd }d!}nBt|\}} }!| dk	r| |d< |!dk	r|!|d< |!|d< |!|d< |
dk	rtt|
t|kst	|
d" t|krt
d#n,x*t||
D ]\}"}#|#dk	r|#|"d$< qW |dk	rt	|d" t|krFd%}$t
|$npxnt||D ]`\}"}%|%dk	rRt|%d&kr|t
d'n4|%d" dk	r|%d" |"d(< |%d) dk	rR|%d) |"d*< qRW | j|||||||||||||||||||d+}&|&S ),a  
        Make a box and whisker plot.

        Make a box and whisker plot for each column of ``x`` or each
        vector in sequence ``x``.  The box extends from the lower to
        upper quartile values of the data, with a line at the median.
        The whiskers extend from the box to show the range of the
        data.  Flier points are those past the end of the whiskers.

        Parameters
        ----------
        x : Array or a sequence of vectors.
            The input data.

        notch : bool, optional (False)
            If `True`, will produce a notched box plot. Otherwise, a
            rectangular boxplot is produced. The notches represent the
            confidence interval (CI) around the median. See the entry
            for the ``bootstrap`` parameter for information regarding
            how the locations of the notches are computed.

            .. note::

                In cases where the values of the CI are less than the
                lower quartile or greater than the upper quartile, the
                notches will extend beyond the box, giving it a
                distinctive "flipped" appearance. This is expected
                behavior and consistent with other statistical
                visualization packages.

        sym : str, optional
            The default symbol for flier points. Enter an empty string
            ('') if you don't want to show fliers. If `None`, then the
            fliers default to 'b+'  If you want more control use the
            flierprops kwarg.

        vert : bool, optional (True)
            If `True` (default), makes the boxes vertical. If `False`,
            everything is drawn horizontally.

        whis : float, sequence, or string (default = 1.5)
            As a float, determines the reach of the whiskers to the beyond the
            first and third quartiles. In other words, where IQR is the
            interquartile range (`Q3-Q1`), the upper whisker will extend to
            last datum less than `Q3 + whis*IQR`). Similarly, the lower whisker
            will extend to the first datum greater than `Q1 - whis*IQR`.
            Beyond the whiskers, data
            are considered outliers and are plotted as individual
            points. Set this to an unreasonably high value to force the
            whiskers to show the min and max values. Alternatively, set
            this to an ascending sequence of percentile (e.g., [5, 95])
            to set the whiskers at specific percentiles of the data.
            Finally, ``whis`` can be the string ``'range'`` to force the
            whiskers to the min and max of the data.

        bootstrap : int, optional
            Specifies whether to bootstrap the confidence intervals
            around the median for notched boxplots. If ``bootstrap`` is
            None, no bootstrapping is performed, and notches are
            calculated using a Gaussian-based asymptotic approximation
            (see McGill, R., Tukey, J.W., and Larsen, W.A., 1978, and
            Kendall and Stuart, 1967). Otherwise, bootstrap specifies
            the number of times to bootstrap the median to determine its
            95% confidence intervals. Values between 1000 and 10000 are
            recommended.

        usermedians : array-like, optional
            An array or sequence whose first dimension (or length) is
            compatible with ``x``. This overrides the medians computed
            by matplotlib for each element of ``usermedians`` that is not
            `None`. When an element of ``usermedians`` is None, the median
            will be computed by matplotlib as normal.

        conf_intervals : array-like, optional
            Array or sequence whose first dimension (or length) is
            compatible with ``x`` and whose second dimension is 2. When
            the an element of ``conf_intervals`` is not None, the
            notch locations computed by matplotlib are overridden
            (provided ``notch`` is `True`). When an element of
            ``conf_intervals`` is `None`, the notches are computed by the
            method specified by the other kwargs (e.g., ``bootstrap``).

        positions : array-like, optional
            Sets the positions of the boxes. The ticks and limits are
            automatically set to match the positions. Defaults to
            `range(1, N+1)` where N is the number of boxes to be drawn.

        widths : scalar or array-like
            Sets the width of each box either with a scalar or a
            sequence. The default is 0.5, or ``0.15*(distance between
            extreme positions)``, if that is smaller.

        patch_artist : bool, optional (False)
            If `False` produces boxes with the Line2D artist. Otherwise,
            boxes and drawn with Patch artists.

        labels : sequence, optional
            Labels for each dataset. Length must be compatible with
            dimensions of ``x``.

        manage_xticks : bool, optional (True)
            If the function should adjust the xlim and xtick locations.

        autorange : bool, optional (False)
            When `True` and the data are distributed such that the 25th and
            75th percentiles are equal, ``whis`` is set to ``'range'`` such
            that the whisker ends are at the minimum and maximum of the data.

        meanline : bool, optional (False)
            If `True` (and ``showmeans`` is `True`), will try to render
            the mean as a line spanning the full width of the box
            according to ``meanprops`` (see below). Not recommended if
            ``shownotches`` is also True. Otherwise, means will be shown
            as points.

        zorder : scalar, optional (None)
            Sets the zorder of the boxplot.

        Other Parameters
        ----------------
        showcaps : bool, optional (True)
            Show the caps on the ends of whiskers.
        showbox : bool, optional (True)
            Show the central box.
        showfliers : bool, optional (True)
            Show the outliers beyond the caps.
        showmeans : bool, optional (False)
            Show the arithmetic means.
        capprops : dict, optional (None)
            Specifies the style of the caps.
        boxprops : dict, optional (None)
            Specifies the style of the box.
        whiskerprops : dict, optional (None)
            Specifies the style of the whiskers.
        flierprops : dict, optional (None)
            Specifies the style of the fliers.
        medianprops : dict, optional (None)
            Specifies the style of the median.
        meanprops : dict, optional (None)
            Specifies the style of the mean.

        Returns
        -------
        result : dict
          A dictionary mapping each component of the boxplot to a list
          of the :class:`matplotlib.lines.Line2D` instances
          created. That dictionary has the following keys (assuming
          vertical boxplots):

          - ``boxes``: the main body of the boxplot showing the
            quartiles and the median's confidence intervals if
            enabled.

          - ``medians``: horizontal lines at the median of each box.

          - ``whiskers``: the vertical lines extending to the most
            extreme, non-outlier data points.

          - ``caps``: the horizontal lines at the ends of the
            whiskers.

          - ``fliers``: points representing data that extend beyond
            the whiskers (fliers).

          - ``means``: points or lines representing the means.

        Notes
        -----
        .. [Notes section required for data comment. See #10189.]

        Nzboxplot.whiskerszboxplot.bootstrap)whis	bootstraprV   	autorangezboxplot.notchzboxplot.verticalzboxplot.patchartistzboxplot.meanlinezboxplot.showmeanszboxplot.showcapszboxplot.showboxzboxplot.showfliersc          	   S   s<   d}| dkrt  } x$|D ]}| |t|||  qW | S )z] Loads properties in the dictionary from rc file if not already
            in the dictionaryzboxplot.{0}.{1}N)rJ  r  rC   r    )Z
dictionaryZrc_nameZ
propertiesZrc_strZ	prop_dictr   r   r   _update_dict  s    
z"Axes.boxplot.<locals>._update_dictr   r   rY  r[  r]  r   r   boxpropswhiskerpropscappropsmedianprops	meanprops
flierpropsr   re   r   rb   )r   r   r   Fr   z(usermedians length not compatible with xmedz+conf_intervals length not compatible with xr   z-each confidence interval must have two valuescilor   cihi)r   widthsvertpatch_artistshownotches	showmeansshowcapsshowboxrs  rx  rv  rw  meanline
showfliersru  rt  manage_xticksr^   )rC   r   Zboxplot_statsr`   rJ  r   r   r   r   r   r   r   bxp)'r=   r   ZnotchZsymr}  ro  r   r|  r~  rp  ZusermediansZconf_intervalsr  r  r  r  r  rs  rV   rx  rv  rw  ru  rt  r  rq  r^   bxpstatsrr  Zflier_propsZdefault_propsrg  r   r   statsry  Zerr_messZciartistsr   r   r   boxplot  s     7
















zAxes.boxplotc       =         s  g }g }g }g }g }g }g }|dkr,t jj}d}|rfttd td td td d}td rzd	|d
< nttd td d}||d< |dk	r|| ttd td td d}ttd td td d}||d< |dk	r|| ||d< |dk	r|| ttd td td td td td td d}||d< |dk	rJ|| ttd td td d} || | d< |dk	r| | |rttd td  td! d}!n"td"td# td$ td% td& d'}!|| |!d< |dk	r|!| d(d) fd*d+ |rfd,d-}" fd.d/}#nfd0d-}" fd1d/}#t|}$d2}%|dkr`ttd3|$d3 }nt||$kr|t	|%
d4|dkrtd5t| d5d6g|$ }n4t|r|g|$ }nt||$krt	|%
d7xt|||D ]\}&}'}(||(d8|& td9|& })t|(d: |(d; g}*t|(d< |(d= g}+|&|'d>  },|&|'d>  }-t|,|-g}.td9|(d;  }/td9|(d=  }0|&|'d6  }1|&|'d6  }2|(d? |(d? g}3|r |1|2|2|-|2|2|1|1|,|1|1g}4|(d: |(d: |(d@ |(d? |(dA |(d< |(d< |(dA |(d? |(d@ |(d: g}5|.}6n8|1|2|2|1|1g}4|(d: |(d: |(d< |(d< |(d: g}5|1|2g}6|	r|rz||#|4|5f| n||"|4|5f| ||"|)|*f| ||"|)|+f| |r||"|.|/f| ||"|.|0f| ||"|6|3f|  |rF|r*||"|1|2g|(dB |(dB gf|! n||"|&g|(dB gf|! |
rtt|(dC |& }7|(dC }8||"|7|8f| qW |rj}9j}:j};nj}9j}:j};|rt|d6 t|d6 f}<|:|< |9| |;| t||||||dDS )EaZ  
        Drawing function for box and whisker plots.

        Make a box and whisker plot for each column of *x* or each
        vector in sequence *x*.  The box extends from the lower to
        upper quartile values of the data, with a line at the median.
        The whiskers extend from the box to show the range of the
        data.  Flier points are those past the end of the whiskers.

        Parameters
        ----------

        bxpstats : list of dicts
          A list of dictionaries containing stats for each boxplot.
          Required keys are:

          - ``med``: The median (scalar float).

          - ``q1``: The first quartile (25th percentile) (scalar
            float).

          - ``q3``: The third quartile (75th percentile) (scalar
            float).

          - ``whislo``: Lower bound of the lower whisker (scalar
            float).

          - ``whishi``: Upper bound of the upper whisker (scalar
            float).

          Optional keys are:

          - ``mean``: The mean (scalar float). Needed if
            ``showmeans=True``.

          - ``fliers``: Data beyond the whiskers (sequence of floats).
            Needed if ``showfliers=True``.

          - ``cilo`` & ``cihi``: Lower and upper confidence intervals
            about the median. Needed if ``shownotches=True``.

          - ``label``: Name of the dataset (string). If available,
            this will be used a tick label for the boxplot

        positions : array-like, default = [1, 2, ..., n]
          Sets the positions of the boxes. The ticks and limits
          are automatically set to match the positions.

        widths : array-like, default = None
          Either a scalar or a vector and sets the width of each
          box. The default is ``0.15*(distance between extreme
          positions)``, clipped to no less than 0.15 and no more than
          0.5.

        vert : bool, default = True
          If `True` (default), makes the boxes vertical.  If `False`,
          makes horizontal boxes.

        patch_artist : bool, default = False
          If `False` produces boxes with the
          `~matplotlib.lines.Line2D` artist.  If `True` produces boxes
          with the `~matplotlib.patches.Patch` artist.

        shownotches : bool, default = False
          If `False` (default), produces a rectangular box plot.
          If `True`, will produce a notched box plot

        showmeans : bool, default = False
          If `True`, will toggle on the rendering of the means

        showcaps  : bool, default = True
          If `True`, will toggle on the rendering of the caps

        showbox  : bool, default = True
          If `True`, will toggle on the rendering of the box

        showfliers : bool, default = True
          If `True`, will toggle on the rendering of the fliers

        boxprops : dict or None (default)
          If provided, will set the plotting style of the boxes

        whiskerprops : dict or None (default)
          If provided, will set the plotting style of the whiskers

        capprops : dict or None (default)
          If provided, will set the plotting style of the caps

        flierprops : dict or None (default)
          If provided will set the plotting style of the fliers

        medianprops : dict or None (default)
          If provided, will set the plotting style of the medians

        meanprops : dict or None (default)
          If provided, will set the plotting style of the means

        meanline : bool, default = False
          If `True` (and *showmeans* is `True`), will try to render the mean
          as a line spanning the full width of the box according to
          *meanprops*. Not recommended if *shownotches* is also True.
          Otherwise, means will be shown as points.

        manage_xticks : bool, default = True
          If the function should adjust the xlim and xtick locations.

        zorder : scalar,  default = None
          The zorder of the resulting boxplot

        Returns
        -------
        result : dict
          A dictionary mapping each component of the boxplot to a list
          of the :class:`matplotlib.lines.Line2D` instances
          created. That dictionary has the following keys (assuming
          vertical boxplots):

          - ``boxes``: the main body of the boxplot showing the
            quartiles and the median's confidence intervals if
            enabled.

          - ``medians``: horizontal lines at the median of each box.

          - ``whiskers``: the vertical lines extending to the most
            extreme, non-outlier data points.

          - ``caps``: the horizontal lines at the ends of the
            whiskers.

          - ``fliers``: points representing data that extend beyond
            the whiskers (fliers).

          - ``means``: points or lines representing the means.

        Examples
        --------

        .. plot:: gallery/statistics/bxp.py

        Ng?zboxplot.boxprops.linestylezboxplot.boxprops.colorzpatch.facecolorzboxplot.boxprops.linewidth)r   re   rd   r   z_internal.classic_modeZwhiterd   )r   r   r^   zboxplot.whiskerprops.linestylezboxplot.whiskerprops.linewidthzboxplot.whiskerprops.color)r   r   r   zboxplot.capprops.linestylezboxplot.capprops.linewidthzboxplot.capprops.colorzboxplot.flierprops.linestylezboxplot.flierprops.linewidthzboxplot.flierprops.colorzboxplot.flierprops.markerz"boxplot.flierprops.markerfacecolorz"boxplot.flierprops.markeredgecolorzboxplot.flierprops.markersize)r   r   r   r   rY  r[  r]  zboxplot.medianprops.linestylezboxplot.medianprops.linewidthzboxplot.medianprops.colorzboxplot.meanprops.linestylezboxplot.meanprops.linewidthzboxplot.meanprops.colorr   zboxplot.meanprops.markerz!boxplot.meanprops.markerfacecolorz!boxplot.meanprops.markeredgecolorzboxplot.meanprops.markersize)r   r   rY  r[  r]  c             S   sL   t t | |gdgd}tjjgtjjgt|d   tjjg }||fS )N)r   r   r   r   )	r   r   column_stackmpathPathZMOVETOZLINETOr   Z	CLOSEPOLY)r_  r`  r   codesr   r   r   to_vc  s    *zAxes.bxp.<locals>.to_vcc                s8   | |\}}t ||}tj|f|} | |gS )N)r  r  rl   Z	PathPatch
add_artist)r_  r`  rH   r   r  pathr   )r=   r  r   r   
patch_list"  s
    
zAxes.bxp.<locals>.patch_listc                 s    j | |S )N)r   )r"   rH   )r=   r   r   doplot+  s    zAxes.bxp.<locals>.doplotc                s    | |f|S )Nr   )r_  r`  rH   )r  r   r   dopatch.  s    zAxes.bxp.<locals>.dopatchc                 sD   g }x2t dt| dD ]}|| |d  | | g qW  j||S )Nr   r   r   )ro   r   extendr   )r"   rH   ZshuffledrT  )r=   r   r   r  2  s    c                s   ||  } } | |f|S )Nr   )r_  r`  rH   )r  r   r   r  8  s    
zEList of boxplot statistics and `{0}` values must have same the lengthr   r   g333333?g      ?r|  rF   r   Zq1ZwhisloZq3Zwhishig      ?ry  rz  r{  meanfliers)whiskerscapsboxesmediansr  means)r   r   r^   rJ  rC   rE   r   r   ro   r   r    r   r  ptpisscalarr   r   r	  onesrF  r  rP  rN  Zset_xticklabelsrQ  rO  Zset_yticklabelsr   r   )=r=   r  r   r|  r}  r~  r  r  r  r  r  rs  rt  rx  rv  ru  rw  r  r  r^   r  r  r  r  r  r  Z
datalabelsZzdeltaZfinal_boxpropsZfinal_whiskerpropsZfinal_cappropsZfinal_flierpropsZfinal_medianpropsZfinal_meanpropsr  r  Ndatashape_messagerw   r  r  Z	whisker_xZwhiskerlo_yZwhiskerhi_yZcap_leftZ	cap_rightZcap_xZcap_loZcap_hiZbox_leftZ	box_rightZmed_yZbox_xZbox_yZmed_xZflier_xZflier_yZsetticksZsetlimZ	setlabelsZ	newlimitsr   )r  r=   r  r   r  "  s4    











 



zAxes.bxpr   
edgecolorsr   rd   
facecolorsc             K   s  d}| d|}| dd}| d|}|dk	r4|}| dd}|dk	ryt| W n tk
rr   tdY nX |dkr|}|dkr|}|dk	rtd|dkr|dk	r|}ntd rd	}n
| j }d
}nd}|dkrtd sd}| j|||d | |}| 	|}t
|t
|f}t
j|}t
j|}|j|jkrNtd|dkrttd rhd}ntd d }t
j|}d
}d}|s|dk	st|tst|tjrt|dkrtt|trd}npyTt
j|td}|jd }|j|krt
j|}n|jdkr"td d}d}W n tk
rF   d}Y nX |dkry<t|}|jd }|jd dd|j|jfkrd}tW nB tk
r   |stdj||j|jdtd|Y nX nd}t|||||||\}}}}}}}|}|dk	r*tjddddd |dkr*|}|dkr<td  }t|tjrP|}n
t|}|  |! }|" sd}td! }t
#||g}t$j%|f|||||| d"| j&|
d#}|'t()  |*| |dkrF|dk	rt|tj+std$|,t
-| |.| |/| |dk	s0|	dk	r>|0||	 n|1  td r| j2d%k rr|jdkrr| 3d% | j4d%k r|jdkr| 5d% | 6| | 7  |S )&a  
        A scatter plot of *y* vs *x* with varying marker size and/or color.

        Parameters
        ----------
        x, y : array_like, shape (n, )
            The data positions.

        s : scalar or array_like, shape (n, ), optional
            The marker size in points**2.
            Default is ``rcParams['lines.markersize'] ** 2``.

        c : color, sequence, or sequence of color, optional
            The marker color. Possible values:

            - A single color format string.
            - A sequence of color specifications of length n.
            - A sequence of n numbers to be mapped to colors using *cmap* and
              *norm*.
            - A 2-D array in which the rows are RGB or RGBA.

            Note that *c* should not be a single numeric RGB or RGBA sequence
            because that is indistinguishable from an array of values to be
            colormapped. If you want to specify the same RGB or RGBA value for
            all points, use a 2-D array with a single row.  Otherwise, value-
            matching will have precedence in case of a size matching with *x*
            and *y*.

            Defaults to ``None``. In that case the marker color is determined
            by the value of ``color``, ``facecolor`` or ``facecolors``. In case
            those are not specified or ``None``, the marker color is determined
            by the next color of the ``Axes``' current "shape and fill" color
            cycle. This cycle defaults to :rc:`axes.prop_cycle`.

        marker : `~matplotlib.markers.MarkerStyle`, optional
            The marker style. *marker* can be either an instance of the class
            or the text shorthand for a particular marker.
            Defaults to ``None``, in which case it takes the value of
            :rc:`scatter.marker` = 'o'.
            See `~matplotlib.markers` for more information about marker styles.

        cmap : `~matplotlib.colors.Colormap`, optional, default: None
            A `.Colormap` instance or registered colormap name. *cmap* is only
            used if *c* is an array of floats. If ``None``, defaults to rc
            ``image.cmap``.

        norm : `~matplotlib.colors.Normalize`, optional, default: None
            A `.Normalize` instance is used to scale luminance data to 0, 1.
            *norm* is only used if *c* is an array of floats. If *None*, use
            the default `.colors.Normalize`.

        vmin, vmax : scalar, optional, default: None
            *vmin* and *vmax* are used in conjunction with *norm* to normalize
            luminance data. If None, the respective min and max of the color
            array is used. *vmin* and *vmax* are ignored if you pass a *norm*
            instance.

        alpha : scalar, optional, default: None
            The alpha blending value, between 0 (transparent) and 1 (opaque).

        linewidths : scalar or array_like, optional, default: None
            The linewidth of the marker edges. Note: The default *edgecolors*
            is 'face'. You may want to change this as well.
            If *None*, defaults to rcParams ``lines.linewidth``.

        edgecolors : color or sequence of color, optional, default: 'face'
            The edge color of the marker. Possible values:

            - 'face': The edge color will always be the same as the face color.
            - 'none': No patch boundary will be drawn.
            - A matplotib color.

            For non-filled markers, the *edgecolors* kwarg is ignored and
            forced to 'face' internally.

        Returns
        -------
        paths : `~matplotlib.collections.PathCollection`

        Other Parameters
        ----------------
        **kwargs : `~matplotlib.collections.Collection` properties

        See Also
        --------
        plot : To plot scatter plots when markers are identical in size and
            color.

        Notes
        -----

        * The `.plot` function will be faster for scatterplots where markers
          don't vary in size or color.

        * Any or all of *x*, *y*, *s*, and *c* may be masked arrays, in which
          case all masks will be combined and only unmasked points will be
          plotted.

        * Fundamentally, scatter works with 1-D arrays; *x*, *y*, *s*, and *c*
          may be input as 2-D arrays, but within scatter they will be
          flattened. The exception is *c*, which will be flattened only if its
          size matches the size of *x* and *y*.

        Nre   r  rd   r   z'color' kwarg must be an mpl color spec or sequence of color specs.
For a sequence of values to be color-mapped, use the 'c' argument instead.zeSupply a 'c' argument or a 'color' kwarg but not both; they differ but their functionalities overlap.z_internal.classic_moder  TFface)r   r   rH   zx and y must be the same size   zlines.markersizeg       @rj   r   )r   ))r   )   a  'c' argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with 'x' & 'y'.  Please use a 2-D array with a single row if you really want to specify the same RGB or RGBA value for all points.r   zl'c' argument has {nc} elements, which is not acceptable for use with 'x' with size {xs}, 'y' with size {ys}.)ncr_  r`  zd'c' argument must either be valid as mpl color(s) or as numbers to be mapped to colors. Here c = {}.z3.0z'verts'kwargz'marker')r   obj_typealternativezscatter.markerzlines.linewidthr]   )r  r  r   offsetstransOffsetrf   z1'norm' must be an instance of 'mcolors.Normalize'g?)8r`   r   r   r   rC   r  r  r   r   r   r   r   r   r   rD  rK  rL  collectionsIterabler   r   r	   r   rD   _logZwarningr    r   r   mmarkersZMarkerStyler&  rp   Zget_transformZ	is_filledr  r   ZPathCollectionrk   r   r$   r   rE   	Normalize	set_arrayr   set_cmapset_normset_climautoscale_NoneZ_xmarginZset_xmarginZ_ymarginZset_ymarginr   r   )r=   r   r   r   r   r   cmapnormvminvmaxrf   r   r   r  rH   r  ZfccoZc_noneZxy_shapeZvalid_shapeZn_elemZc_arrayr   ZscalesZ
marker_objr  r  
collectionr   r   r   scatter  s    q










 














zAxes.scatterr  linearr  c       J   	      s  | j |||d t|||\}}}t|r6|\}}n|}t|td }t|t	}t|t	}|dkrt
|dkrtdt|}|dkrt
|dkrtdt|}|dk	r|\}}}}nrt|rt|t|fnd\}}t|rt|t|fnd\}}tj||d	d
\}}tj||d	d
\}}d||  }||8 }||7 }|| | }|| | }|r| }| }|| | }|| | }t|t}t|t} t|t}!t|t}"|d }#|d }$|}%|}&|#|$ |%|&  }'|| d d||  d   }(||! d d d||" d d   })|(|)k }*|dkrt|#|$f}+t|%|&f},d|k||#k  d| k | |$k  }-d|!k|!|%k  d|"k |"|&k  }.|-|*9 }-|.t|*9 }.||- | |-  }} |!|. |"|.  }!}"x,t|| D ]\}/}0|+|/|0f  d7  < qW x,t|!|"D ]\}/}0|,|/|0f  d7  < q(W |dk	rptj|+|+|k < tj|,|,|k < t|+ |, f}1t|1 }2nl|dkrd}tj|#|$ftd}+x2t|#D ]&}3xt|$D ]}4g |+|3|4f< qW qW tj|%|&ftd},x2t|%D ]&}3xt|&D ]}4g |,|3|4f< qW qW xtt|D ]}3|*|3 rd||3   krh|#k r
n n>d| |3   kr|$k r
n n|+||3 | |3 f  ||3  n^d|!|3   kr|%k r>n n>d|"|3   kr|&k r>n n|,|!|3 |"|3 f  ||3  q>W x`t|#D ]T}3xLt|$D ]@}4|+|3|4f }5t|5|krX|5|+|3|4f< ntj|+|3|4f< q(W qW x`t|%D ]T}3xLt|&D ]@}4|,|3|4f }5t|5|kr|5|,|3|4f< ntj|,|3|4f< qW q|W t|+t	 |,t	 f}1t|1 }2t|'dft	}6t!t"|#|$|6d|#|$ df< t#t"|$|#|6d|#|$ df< t!t"|%d |&|6|#|$ ddf< t#t"|&|%d |6|#|$ ddf< |6dddf  |9  < |6dddf  |9  < |6dddf  |7  < |6dddf  |7  < |6|2ddf }6|1|2 }1tdt	}7|tddddddg |7dddf< |tddddddg d |7dddf< |dkrdg}|dks|dkrdt$|7dt$|6d }8|dkrd|8dddddf  |8dddddf< d| }d| }| %| |dkrRd|8dddddf  |8dddddf< d| }d| }| &| t'j(|8||d}9nt'j(|7g|||6t) dd}9|
dk	rt*|
t+j,sd}:t|:|dkr|
dk	rt-.d/| nt+0 }
d}t*|
t+j0r|1dk
 r|1d7 }1|
dk		r&|
j1dk	r&|
j2dk	r&|
3|1 |dk		rt|	snt|1t|1 };}<|d8 }|;|<|; t"| |  }t4|}|5|1}1|96|1 |97|	 |98|
 |99| |9:| |dk		s|dk		r|9;|| n|9<  ||f||ff}=| =|= ||g|9j>j?dd< ||g|9j>j@dd< | jAdd | jB|9dd |
sD|9S |dk
r\tCt|}fd d!}>tD|||}?|>|||?}@t|@ }Ag g  }B}CxtE|@D ]~\}3}D|?|3 }E|3t|?d k 
r|?|3d  }Fn|EtF|?d"  }F|A|3 
s
q|B |Edf|Ed#f|Fd#f|Fdfg |C |D 
qW t|C}C| jGd$d%}Gt'j(|B|Gd&d'  6|C  7|	  8|
  9|  :| | jB dd tD|||}?|>|||?}Ht|H }Ag g  }B}CxtE|HD ]~\}3}D|?|3 }E|3t|?d k r|?|3d  }Fn|EtF|?d"  }F|A|3 sq|B d|Efd|Ffd#|Ffd#|Efg |C |D qW t|C}C| jHd$d%}Gt'j(|B|Gd&d'6|C 7|	 8|
 9| :| | jBdd  |9_I|9_J fd(d)}I|9jKLd*|I |9S )+a  
        Make a hexagonal binning plot.

        Make a hexagonal binning plot of *x* versus *y*, where *x*,
        *y* are 1-D sequences of the same length, *N*. If *C* is *None*
        (the default), this is a histogram of the number of occurrences
        of the observations at (x[i],y[i]).

        If *C* is specified, it specifies values at the coordinate
        (x[i], y[i]). These values are accumulated for each hexagonal
        bin and then reduced according to *reduce_C_function*, which
        defaults to `numpy.mean`. (If *C* is specified, it must also
        be a 1-D sequence of the same length as *x* and *y*.)

        Parameters
        ----------
        x, y : array or masked array

        C : array or masked array, optional, default is *None*

        gridsize : int or (int, int), optional, default is 100
            The number of hexagons in the *x*-direction, default is
            100. The corresponding number of hexagons in the
            *y*-direction is chosen such that the hexagons are
            approximately regular. Alternatively, gridsize can be a
            tuple with two elements specifying the number of hexagons
            in the *x*-direction and the *y*-direction.

        bins : 'log' or int or sequence, optional, default is *None*
            If *None*, no binning is applied; the color of each hexagon
            directly corresponds to its count value.

            If 'log', use a logarithmic scale for the color
            map. Internally, :math:`log_{10}(i+1)` is used to
            determine the hexagon color.

            If an integer, divide the counts in the specified number
            of bins, and color the hexagons accordingly.

            If a sequence of values, the values of the lower bound of
            the bins to be used.

        xscale : {'linear', 'log'}, optional, default is 'linear'
            Use a linear or log10 scale on the horizontal axis.

        yscale : {'linear', 'log'}, optional, default is 'linear'
            Use a linear or log10 scale on the vertical axis.

        mincnt : int > 0, optional, default is *None*
            If not *None*, only display cells with more than *mincnt*
            number of points in the cell

        marginals : bool, optional, default is *False*
            if marginals is *True*, plot the marginal density as
            colormapped rectagles along the bottom of the x-axis and
            left of the y-axis

        extent : scalar, optional, default is *None*
            The limits of the bins. The default assigns the limits
            based on *gridsize*, *x*, *y*, *xscale* and *yscale*.

            If *xscale* or *yscale* is set to 'log', the limits are
            expected to be the exponent for a power of 10. E.g. for
            x-limits of 1 and 50 in 'linear' scale and y-limits
            of 10 and 1000 in 'log' scale, enter (1, 50, 1, 3).

            Order of scalars is (left, right, bottom, top).

        Other Parameters
        ----------------
        cmap : object, optional, default is *None*
            a :class:`matplotlib.colors.Colormap` instance. If *None*,
            defaults to rc ``image.cmap``.

        norm : object, optional, default is *None*
            :class:`matplotlib.colors.Normalize` instance is used to
            scale luminance data to 0,1.

        vmin, vmax : scalar, optional, default is *None*
            *vmin* and *vmax* are used in conjunction with *norm* to
            normalize luminance data. If *None*, the min and max of the
            color array *C* are used.  Note if you pass a norm instance
            your settings for *vmin* and *vmax* will be ignored.

        alpha : scalar between 0 and 1, optional, default is *None*
            the alpha value for the patches

        linewidths : scalar, optional, default is *None*
            If *None*, defaults to 1.0.

        edgecolors : {'face', 'none', *None*} or color, optional

            If 'face' (the default), draws the edges in the same color as the
            fill color.

            If 'none', no edge is drawn; this can sometimes lead to unsightly
            unpainted pixels between the hexagons.

            If *None*, draws outlines in the default color.

            If a matplotlib color arg, draws outlines in the specified color.

        Returns
        -------
        polycollection
            A `.PolyCollection` instance; use `.PolyCollection.get_array` on
            this to get the counts in each hexagon.

            If *marginals* is *True*, horizontal
            bar and vertical bar (both PolyCollections) will be attached
            to the return collection as attributes *hbar* and *vbar*.

        Notes
        -----
        The standard descriptions of all the
        :class:`~matplotlib.collections.Collection` parameters:

            %(Collection)s

        )r   r   rH   r   r   g        z8x contains non-positive values, so can not be log-scaledz8y contains non-positive values, so can not be log-scaledN)r   r   g?)Zexpanderg&.>r   r   g      @g      ?r   )r   )   r   g      g      ?g      g      $@)r  r   r   )r  r   r  r  Zoffset_positionz1'norm' must be an instance of 'mcolors.Normalize'zIOnly one of 'bins' and 'norm' arguments can be supplied, ignoring bins={}T)tightF)r   c                sr   | | dt|d }tt|}xDtt|D ]4}|||k }t|dkr\ |}ntj}|||< q6W |S )Nr   r   )searchsortedr  r   r   zerosro   nan)r   r   coarseindZmusrT  ZyiZmu)reduce_C_functionr   r   
coarse_binS  s    
zAxes.hexbin.<locals>.coarse_binrj   g?r   )r   r  )r]   r  c                s<     |    |    |   |   d S )N)r  Zget_cmapr  Zget_clim)r  )hbarvbarr   r   
on_changed  s    zAxes.hexbin.<locals>.on_changedZchanged)Mr   r   r   r   intrH  r   r   rF  rD   r   r   log10r   r   r   r$   Znonsingularcopyroundri  floorr  Zlogical_notr   r  Zhstackr   Zisnanemptyobjectro   r   r%  r   r   Zexpand_dimsr   r   r   PolyCollectionr   rK  r   r  warningswarnr    ZLogNormr  r  Z	autoscalesortr  r  r  r  	set_alpharE   r  r  r   r'  r   r   r   r   r  Zlinspace	enumeratediffr   r   r  r  ZcallbacksSMZconnect)Jr=   r   r   CZgridsizebinsZxscaleZyscaleextentr  r  r  r  rf   r   r  r  ZmincntZ	marginalsrH   nxZnyr   r   r   r   ZpaddingrS  ZsyZxorigZyorigZix1Ziy1Zix2Ziy2Znx1Zny1Znx2Zny2nZd1Zd2ZbdistZlattice1Zlattice2Zcond1Zcond2ZixZiyZaccumZ	good_idxsrT  jvalsr  ZpolygonZpolygonsr  msgminimumZmaximumr   r  r  ZxcoarseZvalidr   valuesvalZthisminZthismaxr0   Zycoarser  r   )r  r  r  r   hexbin  s    


$&$
  



@ @$""&&&*

,

,


































zAxes.hexbinc             K   sJ   |  |}| |}|  |}| |}tj||||f|}| | |S )a  
        Add an arrow to the axes.

        This draws an arrow from ``(x, y)`` to ``(x+dx, y+dy)``.

        Parameters
        ----------
        x, y : float
            The x/y-coordinate of the arrow base.
        dx, dy : float
            The length of the arrow along x/y-direction.

        Returns
        -------
        arrow : `.FancyArrow`
            The created `.FancyArrow` object.

        Other Parameters
        ----------------
        **kwargs
            Optional kwargs (inherited from `.FancyArrow` patch) control the
            arrow construction and properties:

        %(FancyArrow)s

        Notes
        -----
        The resulting arrow is affected by the axes aspect ratio and limits.
        This may produce an arrow whose head is not square with its stem. To
        create an arrow whose head is square with its stem,
        use :meth:`annotate` for example:

        >>> ax.annotate("", xy=(0.5, 0.5), xytext=(0, 0),
        ...             arrowprops=dict(arrowstyle="->"))

        )r   r   rl   Z
FancyArrowr  )r=   r   r   r   r   rH   r   r   r   r   arrow  s    (




z
Axes.arrowc             K   s$   t j|||||f|}| | |S )N)mquiver	QuiverKeyr  )r=   QXYUrF   kwZqkr   r   r   	quiverkey  s    
zAxes.quiverkeyc             C   sX   t |dkrT|dd \}}| j|||d | |}| |}||f|dd   S |S )Nr   r   r   )r   r   rH   )r   r   r   r   )r=   r"   r  r   r   r   r   r   _quiver_units  s    

zAxes._quiver_unitsc             O   s8   |  ||}tj| f||}| j|dd |   |S )NT)r   )r  r  Quiverr   r   )r=   r"   r  qr   r   r   quiver  s
    zAxes.quiverc             O   s   t j| |f||S )N)mstack	stackplot)r=   r   r"   rH   r   r   r   r    s    zAxes.stackploturW  start_points-|>皙?      @bothc             C   s2   t j| |||||||||	|
|||||||d}|S )N)densityr   r   r  r  	arrowsizeri   	minlengthr  r]   r^   	maxlengthintegration_direction)mstream
streamplot)r=   r   r   r  rW  r  r   r   r  r  r  ri   r  r]   r^   r  r  r  Zstream_containerr   r   r   r     s     
zAxes.streamplotc             O   s8   |  ||}tj| f||}| j|dd |   |S )z
        %(barbs_doc)s
        T)r   )r  r  ZBarbsr   r   )r=   r"   r  r  r   r   r   barbs  s
    z
Axes.barbs)r   r   r   c             O   sJ   t |tjj}g }x(| j||D ]}| | || q"W |   |S )a  
        Plot filled polygons.

        Parameters
        ----------
        args : sequence of x, y, [color]
            Each polygon is defined by the lists of *x* and *y* positions of
            its nodes, optionally followed by a *color* specifier. See
            :mod:`matplotlib.colors` for supported color specifiers. The
            standard color cycle is used for polygons without a color
            specifier.

            You can plot multiple polygons by providing multiple *x*, *y*,
            *[color]* groups.

            For example, each of the following is legal::

                ax.fill(x, y)                    # a polygon with default color
                ax.fill(x, y, "b")               # a blue polygon
                ax.fill(x, y, x2, y2)            # two polygons
                ax.fill(x, y, "b", x2, y2, "r")  # a blue and a red polygon

        Returns
        -------
        a list of :class:`~matplotlib.patches.Polygon`

        Other Parameters
        ----------------
        **kwargs : :class:`~matplotlib.patches.Polygon` properties

        Notes
        -----
        Use :meth:`fill_between` if you would like to fill the region between
        two curves.
        )	r   r   r   r   r   r  rn   r   r   )r=   r"   rH   r-  Zpolyr   r   r   fill%  s    '
z	Axes.fillrt   y2r  c          	      s   t d s<t tjj t fdddD s<| j  d< | j	 d | j	d t
| t
| t
| x<dfd	fd
fgD ]"\}}	|	jdkrtd| d qW |dkrd}|ttjttj
jg @ }tt\g }
x^t|D ]N\}}|| }|| }|| }|dk	rxtd|  }||||\}}}t|sq"t|}td| d dft}|r·fdd}||}||}n |d |d f}|d |d f}||d< |||d < ||d|d df< ||d|d df< |ddd ||d ddf< |ddd ||d ddf< |
| q"W tj|
f }t| | gj }t| | gj }| j!j"|| j#ddd d| _#| j!j"|| j#ddd | j$|dd | %  |S )a  
        Fill the area between two horizontal curves.

        The curves are defined by the points (*x*, *y1*) and (*x*, *y2*). This
        creates one or multiple polygons describing the filled area.

        You may exclude some horizontal sections from filling using *where*.

        By default, the edges connect the given points directly. Use *step* if
        the filling should be a step function, i.e. constant in between *x*.


        Parameters
        ----------
        x : array (length N)
            The x coordinates of the nodes defining the curves.

        y1 : array (length N) or scalar
            The y coordinates of the nodes defining the first curve.

        y2 : array (length N) or scalar, optional, default: 0
            The y coordinates of the nodes defining the second curve.

        where : array of bool (length N), optional, default: None
            Define *where* to exclude some horizontal regions from being
            filled. The filled regions are defined by the coordinates
            ``x[where]``.  More precisely, fill between ``x[i]`` and ``x[i+1]``
            if ``where[i] and where[i+1]``.  Note that this definition implies
            that an isolated *True* value between two *False* values in
            *where* will not result in filling.  Both sides of the *True*
            position remain unfilled due to the adjacent *False* values.

        interpolate : bool, optional
            This option is only relvant if *where* is used and the two curves
            are crossing each other.

            Semantically, *where* is often used for *y1* > *y2* or similar.
            By default, the nodes of the polygon defining the filled region
            will only be placed at the positions in the *x* array.  Such a
            polygon cannot describe the above semantics close to the
            intersection.  The x-sections containing the intersection are
            simply clipped.

            Setting *interpolate* to *True* will calculate the actual
            intersection point and extend the filled region up to this point.

        step : {'pre', 'post', 'mid'}, optional
            Define *step* if the filling should be a step function,
            i.e. constant in between *x*. The value determines where the
            step will occur:

            - 'pre': The y value is continued constantly to the left from
              every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
              value ``y[i]``.
            - 'post': The y value is continued constantly to the right from
              every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
              value ``y[i]``.
            - 'mid': Steps occur half-way between the *x* positions.

        Other Parameters
        ----------------
        **kwargs
            All other keyword arguments are passed on to `.PolyCollection`.
            They control the `.Polygon` properties:

            %(PolyCollection)s

        Returns
        -------
        `.PolyCollection`
            A `.PolyCollection` containing the plotted polygons.

        See Also
        --------
        fill_betweenx : Fill between two sets of x-values.

        Notes
        -----
        .. [notes section required to get data note injection right]

        z_internal.classic_modec             3   s   | ]}| kV  qd S )Nr   )r   r   )rH   r   r   r     s    z$Axes.fill_between.<locals>.<genexpr>)r   rd   rd   )r   r   rH   )r   r   rt   r  r   zInput passed into argument "%r"zis not 1-dimensional.NTzsteps-r   c       	         s   t | d d} || d  }|| d  || d   }|| d  }t|dkrtj|d rz | | fS tj|d r |  |  fS | }td|| || }| }t||| || }||fS )Nr   r   r   )r   r   r   r   	is_maskedargsortinterp)	r  im1Zx_valuesdiff_valuesZ	y1_values
diff_orderdiff_root_xZx_orderdiff_root_y)r   rt   r  r   r   get_interp_point  s      
z+Axes.fill_between.<locals>.get_interp_pointr   rj   )updatexupdateyF)r   )&rC   r   r   r   
Collectionr   r   r  r  r   r   masked_invalidr   r   ndimr   	functoolsreducer   
logical_ormapgetmaskr   r!  contiguous_regionsr   r   r  rD   r   r  rF  Tr)  update_from_data_xyignore_existing_data_limitsr   r   )r=   r   rt   r  r  interpolater
  rH   r   rF  polysind0ind1ZxsliceZy1sliceZy2slice	step_funcr  r  r  startendr  ZXY1ZXY2r   )rH   r   rt   r  r   fill_betweenU  sn    V 






zAxes.fill_betweenrr   x2c          	      s   t d s<t tjj t fdddD s<| j  d< | j	 d | j	d t
| t
| t
| x<dfd	fd
fgD ]"\}}	|	jdkrtd| d qW |dkrd}|ttjttj
jg @ }tt\g }
x^t|D ]N\}}|| }|| }|| }|dk	rxtd|  }||||\}}}t|sq"t|}td| d dft}|r·fdd}||}||}n |d |d f}|d |d f}||d< |||d < ||d|d df< ||d|d df< |ddd ||d ddf< |ddd ||d ddf< |
| q"W tj|
f }t| | gj }t| | gj }| j!j"|| j#ddd d| _#| j!j"|| j#ddd | j$|dd | %  |S )a  
        Fill the area between two vertical curves.

        The curves are defined by the points (*x1*, *y*) and (*x2*, *y*). This
        creates one or multiple polygons describing the filled area.

        You may exclude some vertical sections from filling using *where*.

        By default, the edges connect the given points directly. Use *step* if
        the filling should be a step function, i.e. constant in between *y*.


        Parameters
        ----------
        y : array (length N)
            The y coordinates of the nodes defining the curves.

        x1 : array (length N) or scalar
            The x coordinates of the nodes defining the first curve.

        x2 : array (length N) or scalar, optional, default: 0
            The x coordinates of the nodes defining the second curve.

        where : array of bool (length N), optional, default: None
            Define *where* to exclude some vertical regions from being
            filled. The filled regions are defined by the coordinates
            ``y[where]``.  More precisely, fill between ``y[i]`` and ``y[i+1]``
            if ``where[i] and where[i+1]``.  Note that this definition implies
            that an isolated *True* value between two *False* values in
            *where* will not result in filling.  Both sides of the *True*
            position remain unfilled due to the adjacent *False* values.

        interpolate : bool, optional
            This option is only relvant if *where* is used and the two curves
            are crossing each other.

            Semantically, *where* is often used for *x1* > *x2* or similar.
            By default, the nodes of the polygon defining the filled region
            will only be placed at the positions in the *y* array.  Such a
            polygon cannot describe the above semantics close to the
            intersection.  The y-sections containing the intersecion are
            simply clipped.

            Setting *interpolate* to *True* will calculate the actual
            interscection point and extend the filled region up to this point.

        step : {'pre', 'post', 'mid'}, optional
            Define *step* if the filling should be a step function,
            i.e. constant in between *y*. The value determines where the
            step will occur:

            - 'pre': The y value is continued constantly to the left from
              every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
              value ``y[i]``.
            - 'post': The y value is continued constantly to the right from
              every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
              value ``y[i]``.
            - 'mid': Steps occur half-way between the *x* positions.

        Other Parameters
        ----------------
        **kwargs
            All other keyword arguments are passed on to `.PolyCollection`.
            They control the `.Polygon` properties:

            %(PolyCollection)s

        Returns
        -------
        `.PolyCollection`
            A `.PolyCollection` containing the plotted polygons.

        See Also
        --------
        fill_between : Fill between two sets of y-values.

        Notes
        -----
        .. [notes section required to get data note injection right]

        z_internal.classic_modec             3   s   | ]}| kV  qd S )Nr   )r   r   )rH   r   r   r   e  s    z%Axes.fill_betweenx.<locals>.<genexpr>)r   rd   rd   )r   r   rH   )r   r   rr   r#  r   zInput passed into argument "%r"zis not 1-dimensional.NTzsteps-r   c       	         s   t | d d}|| d  } || d  || d   } || d  }t|dkrtj|d rz | | fS tj|d r |  |  fS | }td|| || }| }t||| || }||fS )Nr   r   r   )r   r   r   r   r  r  r  )	r  r  Zy_valuesr  Z	x1_valuesr	  r  Zy_orderr
  )rr   r#  r   r   r   r    s      
z,Axes.fill_betweenx.<locals>.get_interp_pointr   rj   )r  r  F)r   )&rC   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  rD   r   r  rF  r  r)  r  r  r   r   )r=   r   rr   r#  r  r
  r  rH   r   rF  r  r  r  ZysliceZx1sliceZx2slicer  r  r  r  r   r!  r  ZX1YZX2Yr   )rH   rr   r#  r   r   fill_betweenx  sn    V 






zAxes.fill_betweenxc             K   s   |dk	rt |tjstd|dkr,td }| | tj| ||||	|
f|||d|}|| |	| |
 dkr|| j |dk	s|dk	r||| n|  || ||  | | |S )a  
        Display an image, i.e. data on a 2D regular raster.

        Parameters
        ----------
        X : array-like or PIL image
            The image data. Supported array shapes are:

            - (M, N): an image with scalar data. The data is visualized
              using a colormap.
            - (M, N, 3): an image with RGB values (float or uint8).
            - (M, N, 4): an image with RGBA values (float or uint8), i.e.
              including transparency.

            The first two dimensions (M, N) define the rows and columns of
            the image.

            The RGB(A) values should be in the range [0 .. 1] for floats or
            [0 .. 255] for integers.  Out-of-range values will be clipped to
            these bounds.

        cmap : str or `~matplotlib.colors.Colormap`, optional
            A Colormap instance or registered colormap name. The colormap
            maps scalar data to colors. It is ignored for RGB(A) data.
            Defaults to :rc:`image.cmap`.

        aspect : {'equal', 'auto'} or float, optional
            Controls the aspect ratio of the axes. The aspect is of particular
            relevance for images since it may distort the image, i.e. pixel
            will not be square.

            This parameter is a shortcut for explicitly calling
            `.Axes.set_aspect`. See there for further details.

            - 'equal': Ensures an aspect ratio of 1. Pixels will be square
              (unless pixel sizes are explicitly made non-square in data
              coordinates using *extent*).
            - 'auto': The axes is kept fixed and the aspect is adjusted so
              that the data fit in the axes. In general, this will result in
              non-square pixels.

            If not given, use :rc:`image.aspect` (default: 'equal').

        interpolation : str, optional
            The interpolation method used. If *None*
            :rc:`image.interpolation` is used, which defaults to 'nearest'.

            Supported values are 'none', 'nearest', 'bilinear', 'bicubic',
            'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser',
            'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc',
            'lanczos'.

            If *interpolation* is 'none', then no interpolation is performed
            on the Agg, ps and pdf backends. Other backends will fall back to
            'nearest'.

            See
            :doc:`/gallery/images_contours_and_fields/interpolation_methods`
            for an overview of the supported interpolation methods.

            Some interpolation methods require an additional radius parameter,
            which can be set by *filterrad*. Additionally, the antigrain image
            resize filter is controlled by the parameter *filternorm*.

        norm : `~matplotlib.colors.Normalize`, optional
            If scalar data are used, the Normalize instance scales the
            data values to the canonical colormap range [0,1] for mapping
            to colors. By default, the data range is mapped to the
            colorbar range using linear scaling. This parameter is ignored for
            RGB(A) data.

        vmin, vmax : scalar, optional
            When using scalar data and no explicit *norm*, *vmin* and *vmax*
            define the data range that the colormap covers. By default,
            the colormap covers the complete value range of the supplied
            data. *vmin*, *vmax* are ignored if the *norm* parameter is used.

        alpha : scalar, optional
            The alpha blending value, between 0 (transparent) and 1 (opaque).
            This parameter is ignored for RGBA input data.

        origin : {'upper', 'lower'}, optional
            Place the [0,0] index of the array in the upper left or lower left
            corner of the axes. The convention 'upper' is typically used for
            matrices and images.
            If not given, :rc:`image.origin` is used, defaulting to 'upper'.

            Note that the vertical axes points upward for 'lower'
            but downward for 'upper'.

        extent : scalars (left, right, bottom, top), optional
            The bounding box in data coordinates that the image will fill.
            The image is stretched individually along x and y to fill the box.

            The default extent is determined by the following conditions.
            Pixels have unit size in data coordinates. Their centers are on
            integer coordinates, and their center coordinates range from 0 to
            columns-1 horizontally and from 0 to rows-1 vertically.

            Note that the direction of the vertical axis and thus the default
            values for top and bottom depend on *origin*:

            - For ``origin == 'upper'`` the default is
              ``(-0.5, numcols-0.5, numrows-0.5, -0.5)``.
            - For ``origin == 'lower'`` the default is
              ``(-0.5, numcols-0.5, -0.5, numrows-0.5)``.

            See the example :doc:`/tutorials/intermediate/imshow_extent` for a
            more detailed description.

        shape : scalars (columns, rows), optional, default: None
            For raw buffer images.

        filternorm : bool, optional, default: True
            A parameter for the antigrain image resize filter (see the
            antigrain documentation).  If *filternorm* is set, the filter
            normalizes integer values and corrects the rounding errors. It
            doesn't do anything with the source floating point values, it
            corrects only integers according to the rule of 1.0 which means
            that any sum of pixel weights must be equal to 1.0.  So, the
            filter function must produce a graph of the proper shape.

        filterrad : float > 0, optional, default: 4.0
            The filter radius for filters that have a radius parameter, i.e.
            when interpolation is one of: 'sinc', 'lanczos' or 'blackman'.

        resample : bool, optional
            When *True*, use a full resampling method.  When *False*, only
            resample when the output image is larger than the input image.

        url : str, optional
            Set the url of the created `.AxesImage`. See `.Artist.set_url`.

        Returns
        -------
        image : `~matplotlib.image.AxesImage`

        Other Parameters
        ----------------
        **kwargs : `~matplotlib.artist.Artist` properties
            These parameters are passed on to the constructor of the
            `.AxesImage` artist.

        See also
        --------
        matshow : Plot a matrix or an array as an image.

        Notes
        -----
        Unless *extent* is used, pixel centers will be located at integer
        coordinates. In other words: the origin will coincide with the center
        of pixel (0, 0).

        There are two common representations for RGB images with an alpha
        channel:

        -   Straight (unassociated) alpha: R, G, and B channels represent the
            color of the pixel, disregarding its opacity.
        -   Premultiplied (associated) alpha: R, G, and B channels represent
            the color of the pixel, adjusted for its opacity by multiplication.

        `~matplotlib.pyplot.imshow` expects RGB images adopting the straight
        (unassociated) alpha representation.
        Nz1'norm' must be an instance of 'mcolors.Normalize'zimage.aspect)
filternorm	filterradresample)rK  r   r  r   rC   rE  mimage	AxesImageset_datar  Zget_clip_pathr~   r   r  r  Zset_url
set_extentZ
get_extent	add_image)r=   r  r  r  aspectinterpolationrf   r  r  originr  r   r%  r&  Zimlimr'  ZurlrH   imr   r   r   imshow  s*     *




zAxes.imshow)allmatchc            G   s`  t |dkr~t|d }|j\}}|rFtt|t|\}}n$tt|d t|d \}}t|}|||fS t |dkrt|d }dd |d d D \}}| dkrtj	|stj	|rt
dt|tjjjr|j}t|tjjjr|j}|j\}}ntd	| | f |jd
 }|jd }	|jdksX|jd dkrr|d|}
|
j|	dd}|jdks|jd dkr||	d}|j|dd}|j|jkrtd| | f |r||	f||fkrLtd|j||	| f nV|||d fkr||	|	d fks0td|j||	| f |d |	d d |d f }t|}|||fS )Nr   r   r   r   c             S   s   g | ]}t |qS r   )r   safe_masked_invalid)r   r   r   r   r   r     s    z$Axes._pcolorargs.<locals>.<listcomp>
pcolormeshzxx and y arguments to pcolormesh cannot have non-finite values or be of type numpy.ma.core.MaskedArray with masked valuesz%Illegal arguments to %s; see help(%s)rj   )axisz,Incompatible X, Y inputs to %s; see help(%s)zKDimensions of C %s are incompatible with X (%d) and/or Y (%d); see help(%s))r   r   r   r   Zmeshgridr   r   r3  r   r  r   rK  ZcoreZMaskedArrayr   rX   r  reshaper%  )funcnamer2  r"   r  ZnumRowsZnumColsr  r  r  Nyr   r   r   r   r   _pcolorargs  sZ    






$
zAxes._pcolorargs)rf   r  r  r  r  c      *      O   s  | j d|ddi\}}	}
|j\}}| j||	|d | |}| |	}	t|
}
t|}t|	}	t|t|	 }|ddddf |ddddf  |ddddf  |ddddf  }t|
| }tj	}|dk
 }||t|ddddf 
 }||t|	ddddf 
 }||t|ddddf 
 }||t|	ddddf 
 }||t|ddddf 
 }||t|	ddddf 
 }||t|ddddf 
 }||t|	ddddf 
 }t|}tj||||||||||g
dd	}||d
df}||t|
d|d d|d f 
 }
d}d|kr|d|d< |d| d|kr|d|d< |dd}d|kr|d|d< d|krt|drd|d< |dd tj|f|}|| ||
 |dk	rBt|tjsBtd|| || ||| |  | d |  }|	  } |j!}!t|!t"j#st$|!dr|!%| j&}!|!rt'|!(| j)r|!| j) }"t*|| gj+,t-}#|".|#}$|$d }|$d } | j/|dd t0|}%t1|}&t0| }'t1| }(|%|&g|j2j3dd< |'|(g|j2j4dd< |%|'f|&|(ff})| 5|) | 6  |S )ad  
        Create a pseudocolor plot with a non-regular rectangular grid.

        Call signature::

            pcolor([X, Y,] C, **kwargs)

        *X* and *Y* can be used to specify the corners of the quadrilaterals.

        .. hint::

            ``pcolor()`` can be very slow for large arrays. In most
            cases you should use the similar but much faster
            `~.Axes.pcolormesh` instead. See there for a discussion of the
            differences.

        Parameters
        ----------
        C : array_like
            A scalar 2-D array. The values will be color-mapped.

        X, Y : array_like, optional
            The coordinates of the quadrilateral corners. The quadrilateral
            for ``C[i,j]`` has corners at::

                (X[i+1, j], Y[i+1, j])          (X[i+1, j+1], Y[i+1, j+1])
                                      +--------+
                                      | C[i,j] |
                                      +--------+
                    (X[i, j], Y[i, j])          (X[i, j+1], Y[i, j+1]),

            Note that the column index corresponds to the
            x-coordinate, and the row index corresponds to y. For
            details, see the :ref:`Notes <axes-pcolor-grid-orientation>`
            section below.

            The dimensions of *X* and *Y* should be one greater than those of
            *C*. Alternatively, *X*, *Y* and *C* may have equal dimensions, in
            which case the last row and column of *C* will be ignored.

            If *X* and/or *Y* are 1-D arrays or column vectors they will be
            expanded as needed into the appropriate 2-D arrays, making a
            rectangular grid.

        cmap : str or `~matplotlib.colors.Colormap`, optional
            A Colormap instance or registered colormap name. The colormap
            maps the *C* values to colors. Defaults to :rc:`image.cmap`.

        norm : `~matplotlib.colors.Normalize`, optional
            The Normalize instance scales the data values to the canonical
            colormap range [0, 1] for mapping to colors. By default, the data
            range is mapped to the colorbar range using linear scaling.

        vmin, vmax : scalar, optional, default: None
            The colorbar range. If *None*, suitable min/max values are
            automatically chosen by the `~.Normalize` instance (defaults to
            the respective min/max values of *C* in case of the default linear
            scaling).

        edgecolors : {'none', None, 'face', color, color sequence}, optional
            The color of the edges. Defaults to 'none'. Possible values:

            - 'none' or '': No edge.
            - *None*: :rc:`patch.edgecolor` will be used. Note that currently
              :rc:`patch.force_edgecolor` has to be True for this to work.
            - 'face': Use the adjacent face color.
            - An mpl color or sequence of colors will set the edge color.

            The singular form *edgecolor* works as an alias.

        alpha : scalar, optional, default: None
            The alpha blending value of the face color, between 0 (transparent)
            and 1 (opaque). Note: The edgecolor is currently not affected by
            this.

        snap : bool, optional, default: False
            Whether to snap the mesh to pixel boundaries.

        Returns
        -------
        collection : `matplotlib.collections.Collection`

        Other Parameters
        ----------------
        antialiaseds : bool, optional, default: False
            The default *antialiaseds* is False if the default
            *edgecolors*\ ="none" is used.  This eliminates artificial lines
            at patch boundaries, and works regardless of the value of alpha.
            If *edgecolors* is not "none", then the default *antialiaseds*
            is taken from :rc:`patch.antialiased`, which defaults to True.
            Stroking the edges may be preferred if *alpha* is 1, but will
            cause artifacts otherwise.

        **kwargs :
            Additionally, the following arguments are allowed. They are passed
            along to the `~matplotlib.collections.PolyCollection` constructor:

        %(PolyCollection)s

        See Also
        --------
        pcolormesh : for an explanation of the differences between
            pcolor and pcolormesh.
        imshow : If *X* and *Y* are each equidistant, `~.Axes.imshow` can be a
            faster alternative.

        Notes
        -----

        **Masked arrays**

        *X*, *Y* and *C* may be masked arrays. If either ``C[i, j]``, or one
        of the vertices surrounding ``C[i,j]`` (*X* or *Y* at
        ``[i, j], [i+1, j], [i, j+1], [i+1, j+1]``) is masked, nothing is
        plotted.

        .. _axes-pcolor-grid-orientation:

        **Grid orientation**

        The grid orientation follows the standard matrix convention: An array
        *C* with shape (nrows, ncolumns) is plotted with the column number as
        *X* and the row number as *Y*.

        **Handling of pcolor() end-cases**

        ``pcolor()`` displays all columns of *C* if *X* and *Y* are not
        specified, or if *X* and *Y* have one more column than *C*.
        If *X* and *Y* have the same number of columns as *C* then the last
        column of *C* is dropped. Similarly for the rows.

        Note: This behavior is different from MATLAB's ``pcolor()``, which
        always discards the last row and column of *C*.
        pcolorr2  F)r   r   rH   r   rj   r   N)r5  r\   r   )g      ?r   r   re   r  rb   antialiasedZantialiasedsZsnapz1'norm' must be an instance of 'mcolors.Normalize'_as_mpl_transform).r   ).r   )r   )r:  )7r9  r   r   r   r   r   r   Zgetmaskarrayr   compressr   filledr   stackr6  r`   r  r   Z_str_lower_equalr   r  r  r  rK  r   r  r   r  r  r  r  r   Z
compressed
_transformr$   	Transformr   r<  axesr   contains_branch_seperatelyrk   Zvstackr  ri  rD   r]   r   r   r   r'  r   r   r   r   )*r=   rf   r  r  r  r  r"   rH   r  r  r  r8  r  ra  Zxymaskr=  Z	ravelmaskZX1ZY1ZX2ZY2ZX3ZY3ZX4ZY4Znpolyru   r   r   Zecr  r   r   r   trans_to_dataZptsZtransformed_ptsr   r   r   r   r   r   r   r   r:    s     





P$$$$$$$$",














zAxes.pcolorZflat)rf   r  r  r  r  shadingr;  c            O   s  |  }|	dd |dk}
| jd|d|
i\}}}|j\}}| }| }| j|||	d | |}| |}| }t	||fj
tdd}tj|d	 |d	 |f||d
|	}|| || |dk	rt|tjstd|| || ||| |  | d |j}t|tjsFt|drF|| j}|rrt| | j!rr|| j! }|"|}| j#|dd tj$|dd\}}tj%|dd\}}||g|j&j'dd< ||g|j&j(dd< ||f||ff}| )| | *  |S )a  
        Create a pseudocolor plot with a non-regular rectangular grid.

        Call signature::

            pcolor([X, Y,] C, **kwargs)

        *X* and *Y* can be used to specify the corners of the quadrilaterals.

        .. note::

           ``pcolormesh()`` is similar to :func:`~Axes.pcolor`. It's much
           faster and preferred in most cases. For a detailed discussion on
           the differences see
           :ref:`Differences between pcolor() and pcolormesh()
           <differences-pcolor-pcolormesh>`.

        Parameters
        ----------
        C : array_like
            A scalar 2-D array. The values will be color-mapped.

        X, Y : array_like, optional
            The coordinates of the quadrilateral corners. The quadrilateral
            for ``C[i,j]`` has corners at::

                (X[i+1, j], Y[i+1, j])          (X[i+1, j+1], Y[i+1, j+1])
                                      +--------+
                                      | C[i,j] |
                                      +--------+
                    (X[i, j], Y[i, j])          (X[i, j+1], Y[i, j+1]),

            Note that the column index corresponds to the
            x-coordinate, and the row index corresponds to y. For
            details, see the :ref:`Notes <axes-pcolormesh-grid-orientation>`
            section below.

            The dimensions of *X* and *Y* should be one greater than those of
            *C*. Alternatively, *X*, *Y* and *C* may have equal dimensions, in
            which case the last row and column of *C* will be ignored.

            If *X* and/or *Y* are 1-D arrays or column vectors they will be
            expanded as needed into the appropriate 2-D arrays, making a
            rectangular grid.

        cmap : str or `~matplotlib.colors.Colormap`, optional
            A Colormap instance or registered colormap name. The colormap
            maps the *C* values to colors. Defaults to :rc:`image.cmap`.

        norm : `~matplotlib.colors.Normalize`, optional
            The Normalize instance scales the data values to the canonical
            colormap range [0, 1] for mapping to colors. By default, the data
            range is mapped to the colorbar range using linear scaling.

        vmin, vmax : scalar, optional, default: None
            The colorbar range. If *None*, suitable min/max values are
            automatically chosen by the `~.Normalize` instance (defaults to
            the respective min/max values of *C* in case of the default linear
            scaling).

        edgecolors : {'none', None, 'face', color, color sequence}, optional
            The color of the edges. Defaults to 'none'. Possible values:

            - 'none' or '': No edge.
            - *None*: :rc:`patch.edgecolor` will be used. Note that currently
              :rc:`patch.force_edgecolor` has to be True for this to work.
            - 'face': Use the adjacent face color.
            - An mpl color or sequence of colors will set the edge color.

            The singular form *edgecolor* works as an alias.

        alpha : scalar, optional, default: None
            The alpha blending value, between 0 (transparent) and 1 (opaque).

        shading : {'flat', 'gouraud'}, optional
            The fill style, Possible values:

            - 'flat': A solid color is used for each quad. The color of the
              quad (i, j), (i+1, j), (i, j+1), (i+1, j+1) is given by
              ``C[i,j]``.
            - 'gouraud': Each quad will be Gouraud shaded: The color of the
              corners (i', j') are given by ``C[i',j']``. The color values of
              the area in between is interpolated from the corner values.
              When Gouraud shading is used, *edgecolors* is ignored.

        snap : bool, optional, default: False
            Whether to snap the mesh to pixel boundaries.

        Returns
        -------
        mesh : `matplotlib.collections.QuadMesh`

        Other Parameters
        ----------------
        **kwargs
            Additionally, the following arguments are allowed. They are passed
            along to the `~matplotlib.collections.QuadMesh` constructor:

        %(QuadMesh)s


        See Also
        --------
        pcolor : An alternative implementation with slightly different
            features. For a detailed discussion on the differences see
            :ref:`Differences between pcolor() and pcolormesh()
            <differences-pcolor-pcolormesh>`.
        imshow : If *X* and *Y* are each equidistant, `~.Axes.imshow` can be a
            faster alternative.

        Notes
        -----

        **Masked arrays**

        *C* may be a masked array. If ``C[i, j]`` is masked, the corresponding
        quadrilateral will be transparent. Masking of *X* and *Y* is not
        supported. Use `~.Axes.pcolor` if you need this functionality.

        .. _axes-pcolormesh-grid-orientation:

        **Grid orientation**

        The grid orientation follows the standard matrix convention: An array
        *C* with shape (nrows, ncolumns) is plotted with the column number as
        *X* and the row number as *Y*.

        .. _differences-pcolor-pcolormesh:

        **Differences between pcolor() and pcolormesh()**

        Both methods are used to create a pseudocolor plot of a 2-D array
        using quadrilaterals.

        The main difference lies in the created object and internal data
        handling:
        While `~.Axes.pcolor` returns a `.PolyCollection`, `~.Axes.pcolormesh`
        returns a `.QuadMesh`. The latter is more specialized for the given
        purpose and thus is faster. It should almost always be preferred.

        There is also a slight difference in the handling of masked arrays.
        Both `~.Axes.pcolor` and `~.Axes.pcolormesh` support masked arrays
        for *C*. However, only `~.Axes.pcolor` supports masked arrays for *X*
        and *Y*. The reason lies in the internal handling of the masked values.
        `~.Axes.pcolor` leaves out the respective polygons from the
        PolyCollection. `~.Axes.pcolormesh` sets the facecolor of the masked
        elements to transparent. You can see the difference when using
        edgecolors. While all edges are drawn irrespective of masking in a
        QuadMesh, the edge between two adjacent masked quadrilaterals in
        `~.Axes.pcolor` is not drawn as the corresponding polygons do not
        exist in the PolyCollection.

        Another difference is the support of Gouraud shading in
        `~.Axes.pcolormesh`, which is not available with `~.Axes.pcolor`.

        r  r   Zgouraudr4  r2  )r   r   rH   F)r  r   )r;  rE  Nz1'norm' must be an instance of 'mcolors.Normalize'r<  )r   r   )r5  )r4  )+r:   r  r9  r   r   r   r   r   r   r  ri  rD   r   QuadMeshr  r  rK  r   r  r   r  r  r  r  r   r@  r$   rA  r   r<  rB  r   rC  rk   r]   r   r   r   r'  r   r   r   r   )r=   rf   r  r  r  r  rE  r;  r"   rH   r2  r  r  r  r8  r  coordsr  r   rD  r   r   r   r   r   r   r   r   r4    sT     !










zAxes.pcolormeshc            O   sP  |dk	rt |tjstd|d }|j\}	}
t|dkrPd}d|
g}d|	g}nt|dkr8|dd \}}t|}t|}|jdkr|jdkr|j	dkr|j	dkrd}nZt
|}t
|}t|d	t|  k r
t|d	t|  k r
d}nd
}n&|jdkr.|jdkr.d}ntdntd|dkrt|}| }| }|
d }|	d }t|| dftj}||dddf< ||dddf< tj|
|	|ddd}|| || || || | j|dd | | | | f\}}}}|}n|d |d |d |d f\}}}}|dkrtj| ||fdd||||fd|}|| || n<|d
krtj| |||f|||d|}| ||||f | !| |}|dk	s|dk	r|"|| n|#  ||g|j$j%dd< ||g|j$j&dd< | 't(||g||gg | j)dd |S )a  
        Create a pseudocolor plot with a non-regular rectangular grid.

        Call signatures::

          ax.pcolorfast(C, **kwargs)
          ax.pcolorfast(xr, yr, C, **kwargs)
          ax.pcolorfast(x, y, C, **kwargs)
          ax.pcolorfast(X, Y, C, **kwargs)

        This method is similar to ~.Axes.pcolor` and `~.Axes.pcolormesh`.
        It's designed to provide the fastest pcolor-type plotting with the
        Agg backend. To achieve this, it uses different algorithms internally
        depending on the complexity of the input grid (regular rectangular,
        non-regular rectangular or arbitrary quadrilateral).

        .. warning::

           This method is experimental. Compared to `~.Axes.pcolor` or
           `~.Axes.pcolormesh` it has some limitations:

           - It supports only flat shading (no outlines)
           - It lacks support for log scaling of the axes.
           - It does not have a have a pyplot wrapper.

        Parameters
        ----------
        C : array-like(M, N)
            A scalar 2D array. The values will be color-mapped.
            *C* may be a masked array.

        x, y : tuple or array-like
            *X* and *Y* are used to specify the coordinates of the
            quadilaterals. There are different ways to do this:

            - Use tuples ``xr=(xmin, xmax)`` and ``yr=(ymin, ymax)`` to define
              a *uniform rectiangular grid*.

              The tuples define the outer edges of the grid. All individual
              quadrilaterals will be of the same size. This is the fastest
              version.

            - Use 1D arrays *x*, *y* to specify a *non-uniform rectangular
              grid*.

              In this case *x* and *y* have to be monotonic 1D arrays of length
              *N+1* and *M+1*, specifying the x and y boundaries of the cells.

              The speed is intermediate. Note: The grid is checked, and if
              found to be uniform the fast version is used.

            - Use 2D arrays *X*, *Y* if you need an *arbitrary quadrilateral
              grid* (i.e. if the quadrilaterals are not rectangular).

              In this case *X* and *Y* are 2D arrays with shape (M, N),
              specifying the x and y coordinates of the corners of the colored
              quadrilaterals. See `~.Axes.pcolormesh` for details.

              This is the most general, but the slowest to render.  It may
              produce faster and more compact output using ps, pdf, and
              svg backends, however.

            Leaving out *x* and *y* defaults to ``xr=(0, N)``, ``yr=(O, M)``.

        cmap : str or `~matplotlib.colors.Colormap`, optional
            A Colormap instance or registered colormap name. The colormap
            maps the *C* values to colors. Defaults to :rc:`image.cmap`.

        norm : `~matplotlib.colors.Normalize`, optional
            The Normalize instance scales the data values to the canonical
            colormap range [0, 1] for mapping to colors. By default, the data
            range is mapped to the colorbar range using linear scaling.

        vmin, vmax : scalar, optional, default: None
            The colorbar range. If *None*, suitable min/max values are
            automatically chosen by the `~.Normalize` instance (defaults to
            the respective min/max values of *C* in case of the default linear
            scaling).

        alpha : scalar, optional, default: None
            The alpha blending value, between 0 (transparent) and 1 (opaque).

        snap : bool, optional, default: False
            Whether to snap the mesh to pixel boundaries.

        Returns
        -------
        image : `.AxesImage` or `.PcolorImage` or `.QuadMesh`
            The return type depends on the type of grid:

            - `.AxesImage` for a regular rectangular grid.
            - `.PcolorImage` for a non-regular rectangular grid.
            - `.QuadMesh` for a non-rectangular grid.

        Notes
        -----
        .. [notes section required to get data note injection right]

        Nz1'norm' must be an instance of 'mcolors.Normalize'rj   r   imager   r   r   g{Gz?ZpcolorimageZquadmeshz'arguments do not match valid signatureszneed 1 argument or 3 argumentsr   )r  F)r   nearestr:   )r.  r/  r  )r  r  rf   T)r  )*rK  r   r  r   r   r   r   r   r  rD  r  r  absr  rX   r   r   r  Zfloat64r   rF  r  r  r  r  r   r   r   r(  r)  r*  ZPcolorImager+  r,  r  r  r'  r   r   r   rF  r   )r=   rf   r  r  r  r  r"   rH   r  nrr  Zstyler   r   r   r   r  r  r  r8  rG  r  Zxlry   ZybrU  r   r0  r   r   r   
pcolorfast  s    g












$$



zAxes.pcolorfastc             O   s&   d|d< t j| f||}|   |S )NFr>  )mcontourQuadContourSetr   )r=   r"   rH   contoursr   r   r   contourT  s    zAxes.contourc             O   s&   d|d< t j| f||}|   |S )NTr>  )rM  rN  r   )r=   r"   rH   rO  r   r   r   contourf\  s    zAxes.contourfc             O   s   |j ||S )N)clabel)r=   ZCSr"   rH   r   r   r   rR  d  s    zAxes.clabelc             K   s   t j| f|S )a#  
        Add a table to the current axes.

        Call signature::

          table(cellText=None, cellColours=None,
                cellLoc='right', colWidths=None,
                rowLabels=None, rowColours=None, rowLoc='left',
                colLabels=None, colColours=None, colLoc='center',
                loc='bottom', bbox=None)

        Returns a :class:`matplotlib.table.Table` instance. Either `cellText`
        or `cellColours` must be provided. For finer grained control over
        tables, use the :class:`~matplotlib.table.Table` class and add it to
        the axes with :meth:`~matplotlib.axes.Axes.add_table`.

        Thanks to John Gill for providing the class and table.

        kwargs control the :class:`~matplotlib.table.Table`
        properties:

        %(Table)s
        )mtabletable)r=   rH   r   r   r   rT  h  s    z
Axes.tableweightsr1  r  r   c       ;         s
  |}ddl m} t|r |g} dkr0td  |dkrDtd| |	dkrXtd|	 |
d	krltd
|
 |dkr||s|d}|dk	r|dk	rtd|dk	rtjdddddd t|dk}|rt	g g}nt
|d}t|}j|d |d fdd|D }|dk	r|}t p.|dk	}|dk	rHt
|d}n
dg| }t||krhtdx<t||D ].\}}|dk	rtt|t|krttdqtW |dkrȇfdd||D }n0t|}t||krd|t|f }t||sX|sXtj}tj }x<|D ]4}t|dkrt|t|}t|t|}qW ||f}t|pht|}|r|st||d}n
t|d}g }d}x||D ]x}tj||  fd|| i|\}  | t} |dkrtt d | j}|r| |7 } | |dd< ||  qW |r^|r^t }!x*|D ]"} | |! |d    | dd< q8W |rt!dt"|t#r|dk rt!ddd|r fdd|D }nfd d|D }g }"$ }#% }$&d! 'd! |(d"rt }%|dk	rt)|dd}&n(t|dkr8|r2td# r8d$}&nd%}&|d"krv|sv|&|% | }'|'}(d&|& |% dd|   })n |dks|r|&|% }'d'\})}(|	d(ks|	d)kr|)d*|% 7 })n|	d+kr|)|%7 })|
d,krj*}*d-}+n
j+}*d.}+xt||D ]\} },|dkrtt| }|r&| | }-n| }-|* dd |) |-|'fd/||,d0|+|i}.|"|. |rr| |dd< |)|(7 })qW n
|(d1	rtd2t  d3 }td2t  d3 }/  dd  |dd4t  d d4< |dd4t  d d4< |dd4t  d  ddd |d4t  d d< |dkrLtt d }|| |/dd4t  d d4< |/d4d4t  d4< |/dd4t  d  ddd |/d4t  d d< |r`|
d,krވj,d5d6d7 j-j.j/}0nj0d5d6d8 j1j.j/}0t|dkrt|}1n:|s"|dk	rDt	|}2t|2|2dk |0 }1nd%|0 }1|1|1 |/d< |/d< nd}1|	d-ksx|	d/kr|d* d  d   8 }n"|	d+kr|d* d  d   7 }|d9k}3g g  }4}5x|D ]} |r|/d |/d< |/dd4t  d  ddd |/d4t  d d< | | | |  |/dd4t  d d4< |/d4d4t  d4< |rd|1|/|/|1k < |
d,kr|4|/2  |5|2  n|4|2  |5|/2  qW |3rdn
d4t  }6xnt3t4t|4|5|D ]V\}}/},|"j5|d|6 |/d|6 |3	r
dnd|,|3	rdn|,|3	r$|3ndd: qW xP|"D ]H}7x@|7D ]8}.|
d;k	rb|.j6j7|1 n|
d,k	rD|.j6j8|1 	qDW 	q:W |"9  &|# '|$ :  |dk	rdg}8n:t"|t;	r|g}8n&t|	st;|g}8nd<d |D }8xrt<=|"|8D ]b\}.}9|.
r|.d }:|:>| |9dk	
r8|:?|9 x*|.dd D ]}:|:>| |:?d= 
qFW 
qW |dk
r|d  t@d>|"d fS | t@d?|"fS dS )@a   
        Plot a histogram.

        Compute and draw the histogram of *x*. The return value is a
        tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*,
        [*patches0*, *patches1*,...]) if the input contains multiple
        data.

        Multiple data can be provided via *x* as a list of datasets
        of potentially different length ([*x0*, *x1*, ...]), or as
        a 2-D ndarray in which each column is a dataset.  Note that
        the ndarray form is transposed relative to the list form.

        Masked arrays are not supported at present.

        Parameters
        ----------
        x : (n,) array or sequence of (n,) arrays
            Input values, this takes either a single array or a sequence of
            arrays which are not required to be of the same length.

        bins : int or sequence or str, optional
            If an integer is given, ``bins + 1`` bin edges are calculated and
            returned, consistent with `numpy.histogram`.

            If `bins` is a sequence, gives bin edges, including left edge of
            first bin and right edge of last bin.  In this case, `bins` is
            returned unmodified.

            All but the last (righthand-most) bin is half-open.  In other
            words, if `bins` is::

                [1, 2, 3, 4]

            then the first bin is ``[1, 2)`` (including 1, but excluding 2) and
            the second ``[2, 3)``.  The last bin, however, is ``[3, 4]``, which
            *includes* 4.

            Unequally spaced bins are supported if *bins* is a sequence.

            With Numpy 1.11 or newer, you can alternatively provide a string
            describing a binning strategy, such as 'auto', 'sturges', 'fd',
            'doane', 'scott', 'rice', 'sturges' or 'sqrt', see
            `numpy.histogram`.

            The default is taken from :rc:`hist.bins`.

        range : tuple or None, optional
            The lower and upper range of the bins. Lower and upper outliers
            are ignored. If not provided, *range* is ``(x.min(), x.max())``.
            Range has no effect if *bins* is a sequence.

            If *bins* is a sequence or *range* is specified, autoscaling
            is based on the specified bin range instead of the
            range of x.

            Default is ``None``

        density : bool, optional
            If ``True``, the first element of the return tuple will
            be the counts normalized to form a probability density, i.e.,
            the area (or integral) under the histogram will sum to 1.
            This is achieved by dividing the count by the number of
            observations times the bin width and not dividing by the total
            number of observations. If *stacked* is also ``True``, the sum of
            the histograms is normalized to 1.

            Default is ``None`` for both *normed* and *density*. If either is
            set, then that value will be used. If neither are set, then the
            args will be treated as ``False``.

            If both *density* and *normed* are set an error is raised.

        weights : (n, ) array_like or None, optional
            An array of weights, of the same shape as *x*.  Each value in *x*
            only contributes its associated weight towards the bin count
            (instead of 1).  If *normed* or *density* is ``True``,
            the weights are normalized, so that the integral of the density
            over the range remains 1.

            Default is ``None``

        cumulative : bool, optional
            If ``True``, then a histogram is computed where each bin gives the
            counts in that bin plus all bins for smaller values. The last bin
            gives the total number of datapoints. If *normed* or *density*
            is also ``True`` then the histogram is normalized such that the
            last bin equals 1. If *cumulative* evaluates to less than 0
            (e.g., -1), the direction of accumulation is reversed.
            In this case, if *normed* and/or *density* is also ``True``, then
            the histogram is normalized such that the first bin equals 1.

            Default is ``False``

        bottom : array_like, scalar, or None
            Location of the bottom baseline of each bin.  If a scalar,
            the base line for each bin is shifted by the same amount.
            If an array, each bin is shifted independently and the length
            of bottom must match the number of bins.  If None, defaults to 0.

            Default is ``None``

        histtype : {'bar', 'barstacked', 'step',  'stepfilled'}, optional
            The type of histogram to draw.

            - 'bar' is a traditional bar-type histogram.  If multiple data
              are given the bars are arranged side by side.

            - 'barstacked' is a bar-type histogram where multiple
              data are stacked on top of each other.

            - 'step' generates a lineplot that is by default
              unfilled.

            - 'stepfilled' generates a lineplot that is by default
              filled.

            Default is 'bar'

        align : {'left', 'mid', 'right'}, optional
            Controls how the histogram is plotted.

                - 'left': bars are centered on the left bin edges.

                - 'mid': bars are centered between the bin edges.

                - 'right': bars are centered on the right bin edges.

            Default is 'mid'

        orientation : {'horizontal', 'vertical'}, optional
            If 'horizontal', `~matplotlib.pyplot.barh` will be used for
            bar-type histograms and the *bottom* kwarg will be the left edges.

        rwidth : scalar or None, optional
            The relative width of the bars as a fraction of the bin width.  If
            ``None``, automatically compute the width.

            Ignored if *histtype* is 'step' or 'stepfilled'.

            Default is ``None``

        log : bool, optional
            If ``True``, the histogram axis will be set to a log scale. If
            *log* is ``True`` and *x* is a 1D array, empty bins will be
            filtered out and only the non-empty ``(n, bins, patches)``
            will be returned.

            Default is ``False``

        color : color or array_like of colors or None, optional
            Color spec or sequence of color specs, one per dataset.  Default
            (``None``) uses the standard line color sequence.

            Default is ``None``

        label : str or None, optional
            String, or sequence of strings to match multiple datasets.  Bar
            charts yield multiple patches per dataset, but only the first gets
            the label, so that the legend command will work as expected.

            default is ``None``

        stacked : bool, optional
            If ``True``, multiple data are stacked on top of each other If
            ``False`` multiple data are arranged side by side if histtype is
            'bar' or on top of each other if histtype is 'step'

            Default is ``False``

        normed : bool, optional
            Deprecated; use the density keyword argument instead.

        Returns
        -------
        n : array or list of arrays
            The values of the histogram bins. See *normed* or *density*
            and *weights* for a description of the possible semantics.
            If input *x* is an array, then this is an array of length
            *nbins*. If input is a sequence of arrays
            ``[data1, data2,..]``, then this is a list of arrays with
            the values of the histograms for each of the arrays in the
            same order.

        bins : array
            The edges of the bins. Length nbins + 1 (nbins left edges and right
            edge of last bin).  Always a single array even when multiple data
            sets are passed in.

        patches : list or list of lists
            Silent list of individual patches used to create the histogram
            or list of such list if multiple input datasets.

        Other Parameters
        ----------------
        **kwargs : `~matplotlib.patches.Patch` properties

        See also
        --------
        hist2d : 2D histograms

        Notes
        -----
        .. [Notes section required for data comment. See #10189.]

        r   )ro   Nz	hist.bins)r1  
barstackedr
  
stepfilledzhisttype %s is not recognized)r5   r  r6   z align kwarg %s is not recognized)r   r   z&orientation kwarg %s is not recognizedrV  Tztkwargs 'density' and 'normed' cannot be used simultaneously. Please only use 'density', since 'normed'is deprecated.z2.1z'normed'r  z	'density'z3.1)r   r  r  Zremovalr   )r   rH   c                s   g | ]}  |qS r   )r   )r   xi)r=   r   r   r     s    zAxes.hist.<locals>.<listcomp>rU  z'weights should have the same shape as xc                s   g | ]} j  qS r   )r   r  )r   rT  )r=   r   r   r     s    zVcolor kwarg must have one color per data set. %d data sets and %d colors were provided)ro   r  r   rj   c                s&   g | ]}|t      qS r   )r   r  r   )r   m)r  slcr   r   r     s    c                s   g | ]}|      qS r   )r   )r   rY  )rZ  r   r   r     s    Fr1  z_internal.classic_modeg?g      ?g      )g        g        r  r  g      ?r6   r   r5   r  r4   )r  r   r   r
  r  r   r   r   r  )r   )r   rW  )closedrd   re   r  r   c             S   s   g | ]}t |qS r   )rL  )r   Zlabr   r   r   r   x  s    r  r  zLists of Patches)Abuiltinsro   r   r  rC   r   r   r   rD  rF  Z_reshape_2Dr   r   r   r   r   r   r   infr   Znanminr   Znanmaxrj  rJ  Z	histogramri  rD   r  r   r   r  rG  slicerK  r   Zget_autoscalex_onZget_autoscaley_onZset_autoscalex_onZset_autoscaley_on
startswithr  r2  r1  r   rK   Z_scalebaser   rQ   r  reversedr   r  r'  r   r   reverser   rL  r"  zip_longestrE   rI  Zsilent_list);r=   r   r  ro   r  rU  Z
cumulativer  Zhisttyper  r   Zrwidthr   r   rF   Zstackedr  rH   Z	bin_rangeZinput_emptyr  Z	binsgivenr  rX  ZwiZerror_messager   r   Zhist_kwargsZtopsZmlastrT  rY  Zdbr-  Z_saved_autoscalexZ_saved_autoscaleyZtotwidthZdrr  ZdwZboffsetZ_barfuncZbottom_kwargr   r  r   r   Zlogbaser  Zndatar  ZxvalsZyvalssplitr  rV   Zlblr   r   )r  r=   rZ  r   hist  s    V











$



"








>6
26





64
 











z	Axes.histc	             K   s   t j||||||d\}
}}|dk	r0d|
|
|k < |dk	rDd|
|
|k< | j|||
jf|	}| |d |d  | |d |d  |
|||fS )aF  
        Make a 2D histogram plot.

        Parameters
        ----------
        x, y : array_like, shape (n, )
            Input values

        bins : None or int or [int, int] or array_like or [array, array]

            The bin specification:

                - If int, the number of bins for the two dimensions
                  (nx=ny=bins).

                - If ``[int, int]``, the number of bins in each dimension
                  (nx, ny = bins).

                - If array_like, the bin edges for the two dimensions
                  (x_edges=y_edges=bins).

                - If ``[array, array]``, the bin edges in each dimension
                  (x_edges, y_edges = bins).

            The default value is 10.

        range : array_like shape(2, 2), optional, default: None
             The leftmost and rightmost edges of the bins along each dimension
             (if not specified explicitly in the bins parameters): ``[[xmin,
             xmax], [ymin, ymax]]``. All values outside of this range will be
             considered outliers and not tallied in the histogram.

        normed : bool, optional, default: False
             Normalize histogram.

        weights : array_like, shape (n, ), optional, default: None
            An array of values w_i weighing each sample (x_i, y_i).

        cmin : scalar, optional, default: None
             All bins that has count less than cmin will not be displayed and
             these count values in the return value count histogram will also
             be set to nan upon return

        cmax : scalar, optional, default: None
             All bins that has count more than cmax will not be displayed (set
             to none before passing to imshow) and these count values in the
             return value count histogram will also be set to nan upon return

        Returns
        -------
        h : 2D array
            The bi-dimensional histogram of samples x and y. Values in x are
            histogrammed along the first dimension and values in y are
            histogrammed along the second dimension.
        xedges : 1D array
            The bin edges along the x axis.
        yedges : 1D array
            The bin edges along the y axis.
        image : `~.matplotlib.collections.QuadMesh`

        Other Parameters
        ----------------
        cmap : Colormap or str, optional
            A `.colors.Colormap` instance.  If not set, use rc settings.

        norm : Normalize, optional
            A `.colors.Normalize` instance is used to
            scale luminance data to ``[0, 1]``. If not set, defaults to
            `.colors.Normalize()`.

        vmin/vmax : None or scalar, optional
            Arguments passed to the `~.colors.Normalize` instance.

        alpha : ``0 <= scalar <= 1`` or ``None``, optional
            The alpha blending value.

        See also
        --------
        hist : 1D histogram plotting

        Notes
        -----
        - Currently ``hist2d`` calculates it's own axis limits, and any limits
          previously set are ignored.
        - Rendering the histogram with a logarithmic color scale is
          accomplished by passing a `.colors.LogNorm` instance to the *norm*
          keyword argument. Likewise, power-law normalization (similar
          in effect to gamma correction) can be accomplished with
          `.colors.PowerNorm`.
        )r  ro   r  rU  Nr   rj   )r   Zhistogram2dr4  r  rN  rO  )r=   r   r   r  ro   r  rU  ZcminZcmaxrH   r  ZxedgesZyedgesZpcr   r   r   hist2d  s    ^zAxes.hist2dc             K   s  |dkrd}t j||||||||	|
d	\}}||7 }|
dkrBd}nd}| j|dt| f|}| d | d	|  | d
 | jj	\}}|| }t
t|}|dkrd}d| }tt|t|d |}| | |dks|s||fS |||fS dS )a  
        Plot the power spectral density.

        Call signature::

          psd(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
              window=mlab.window_hanning, noverlap=0, pad_to=None,
              sides='default', scale_by_freq=None, return_line=None, **kwargs)

        The power spectral density :math:`P_{xx}` by Welch's average
        periodogram method.  The vector *x* is divided into *NFFT* length
        segments.  Each segment is detrended by function *detrend* and
        windowed by function *window*.  *noverlap* gives the length of
        the overlap between segments.  The :math:`|\mathrm{fft}(i)|^2`
        of each segment :math:`i` are averaged to compute :math:`P_{xx}`,
        with a scaling to correct for power loss due to windowing.

        If len(*x*) < *NFFT*, it will be zero padded to *NFFT*.

        Parameters
        ----------
        x : 1-D array or sequence
            Array or sequence containing the data

        %(Spectral)s

        %(PSD)s

        noverlap : int
            The number of points of overlap between segments.
            The default value is 0 (no overlap).

        Fc : int
            The center frequency of *x* (defaults to 0), which offsets
            the x extents of the plot to reflect the frequency range used
            when a signal is acquired and then filtered and downsampled to
            baseband.

        return_line : bool
            Whether to include the line object plotted in the returned values.
            Default is False.

        Returns
        -------
        Pxx : 1-D array
            The values for the power spectrum `P_{xx}` before scaling
            (real valued).

        freqs : 1-D array
            The frequencies corresponding to the elements in *Pxx*.

        line : a :class:`~matplotlib.lines.Line2D` instance
            The line created by this function.
            Only returned if *return_line* is True.

        Other Parameters
        ----------------
        **kwargs :
            Keyword arguments control the :class:`~matplotlib.lines.Line2D`
            properties:

            %(Line2D)s

        See Also
        --------
        :func:`specgram`
            :func:`specgram` differs in the default overlap; in not returning
            the mean of the segment periodograms; in returning the times of the
            segments; and in plotting a colormap instead of a line.

        :func:`magnitude_spectrum`
            :func:`magnitude_spectrum` plots the magnitude spectrum.

        :func:`csd`
            :func:`csd` plots the spectral density between two signals.

        Notes
        -----
        For plotting, the power is plotted as
        :math:`10\log_{10}(P_{xx})` for decibels, though *Pxx* itself
        is returned.

        References
        ----------
        Bendat & Piersol -- Random Data: Analysis and Measurement Procedures,
        John Wiley & Sons (1986)
        Nr   )	r   NFFTFsr  windownoverlappad_tosidesscale_by_freq)NTzdB/HzdBr   	FrequencyzPower Spectral Density (%s)Tg?r   )mlabpsdr   r   r  rP   rS   r   viewLimr*  r  r   rH  r  ceilrQ  )r=   r   rg  rh  Fcr  ri  rj  rk  rl  rm  return_linerH   ZpxxfreqsZ	psd_unitsr   r  r  intvZlogir
  ticksr   r   r   rq    s0    \


zAxes.psdc             K   s   |dkrd}t j||||||||	|
|d
\}}||7 }| j|dtt| f|}| d | d | d | j	j
\}}|| }dtt| }tt|t|d |}| | |dks|s||fS |||fS dS )	aZ
  
        Plot the cross-spectral density.

        Call signature::

          csd(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
              window=mlab.window_hanning, noverlap=0, pad_to=None,
              sides='default', scale_by_freq=None, return_line=None, **kwargs)

        The cross spectral density :math:`P_{xy}` by Welch's average
        periodogram method.  The vectors *x* and *y* are divided into
        *NFFT* length segments.  Each segment is detrended by function
        *detrend* and windowed by function *window*.  *noverlap* gives
        the length of the overlap between segments.  The product of
        the direct FFTs of *x* and *y* are averaged over each segment
        to compute :math:`P_{xy}`, with a scaling to correct for power
        loss due to windowing.

        If len(*x*) < *NFFT* or len(*y*) < *NFFT*, they will be zero
        padded to *NFFT*.

        Parameters
        ----------
        x, y : 1-D arrays or sequences
            Arrays or sequences containing the data.

        %(Spectral)s

        %(PSD)s

        noverlap : int
            The number of points of overlap between segments.
            The default value is 0 (no overlap).

        Fc : int
            The center frequency of *x* (defaults to 0), which offsets
            the x extents of the plot to reflect the frequency range used
            when a signal is acquired and then filtered and downsampled to
            baseband.

        return_line : bool
            Whether to include the line object plotted in the returned values.
            Default is False.

        Returns
        -------
        Pxy : 1-D array
            The values for the cross spectrum `P_{xy}` before scaling
            (complex valued).

        freqs : 1-D array
            The frequencies corresponding to the elements in *Pxy*.

        line : a :class:`~matplotlib.lines.Line2D` instance
            The line created by this function.
            Only returned if *return_line* is True.

        Other Parameters
        ----------------
        **kwargs :
            Keyword arguments control the :class:`~matplotlib.lines.Line2D`
            properties:

            %(Line2D)s

        See Also
        --------
        :func:`psd`
            :func:`psd` is the equivalent to setting y=x.

        Notes
        -----
        For plotting, the power is plotted as
        :math:`10\log_{10}(P_{xy})` for decibels, though `P_{xy}` itself
        is returned.

        References
        ----------
        Bendat & Piersol -- Random Data: Analysis and Measurement Procedures,
        John Wiley & Sons (1986)
        Nr   )
r   r   rg  rh  r  ri  rj  rk  rl  rm  r   ro  zCross Spectrum Magnitude (dB)Tr   )rp  csdr   r   r  rJ  rP   rS   r   rr  r*  r  r   rH  r  rs  rQ  )r=   r   r   rg  rh  rt  r  ri  rj  rk  rl  rm  ru  rH   Zpxyrv  r   r  r  rw  r
  rx  r   r   r   ry  q  s$    V 



zAxes.csdc             K   s   |dkrd}|dks|dkr d}t j|||||d\}	}
|
|7 }
|dkrR|	}d}n&|dkrndt|	 }d}n
td	|| j|
|f|}| d
 | d|  |	|
|d fS )a  
        Plot the magnitude spectrum.

        Call signature::

          magnitude_spectrum(x, Fs=2, Fc=0,  window=mlab.window_hanning,
                             pad_to=None, sides='default', **kwargs)

        Compute the magnitude spectrum of *x*.  Data is padded to a
        length of *pad_to* and the windowing function *window* is applied to
        the signal.

        Parameters
        ----------
        x : 1-D array or sequence
            Array or sequence containing the data.

        %(Spectral)s

        %(Single_Spectrum)s

        scale : {'default', 'linear', 'dB'}
            The scaling of the values in the *spec*.  'linear' is no scaling.
            'dB' returns the values in dB scale, i.e., the dB amplitude
            (20 * log10). 'default' is 'linear'.

        Fc : int
            The center frequency of *x* (defaults to 0), which offsets
            the x extents of the plot to reflect the frequency range used
            when a signal is acquired and then filtered and downsampled to
            baseband.

        Returns
        -------
        spectrum : 1-D array
            The values for the magnitude spectrum before scaling (real valued).

        freqs : 1-D array
            The frequencies corresponding to the elements in *spectrum*.

        line : a :class:`~matplotlib.lines.Line2D` instance
            The line created by this function.

        Other Parameters
        ----------------
        **kwargs :
            Keyword arguments control the :class:`~matplotlib.lines.Line2D`
            properties:

            %(Line2D)s

        See Also
        --------
        :func:`psd`
            :func:`psd` plots the power spectral density.`.

        :func:`angle_spectrum`
            :func:`angle_spectrum` plots the angles of the corresponding
            frequencies.

        :func:`phase_spectrum`
            :func:`phase_spectrum` plots the phase (unwrapped angle) of the
            corresponding frequencies.

        :func:`specgram`
            :func:`specgram` can plot the magnitude spectrum of segments within
            the signal in a colormap.

        Notes
        -----
        .. [Notes section required for data comment. See #10189.]

        Nr   rI   r  )r   rh  ri  rk  rl  Zenergyrn  g      4@zUnknown scale %sro  zMagnitude (%s))rp  magnitude_spectrumr   r  r   r   rP   rS   )r=   r   rh  rt  ri  rk  rl  scalerH   specrv  ZZyunitsr   r   r   r   rz    s$    N


zAxes.magnitude_spectrumc             K   s^   |dkrd}t j|||||d\}}	|	|7 }	| j|	|f|}
| d | d ||	|
d fS )ae  
        Plot the angle spectrum.

        Call signature::

          angle_spectrum(x, Fs=2, Fc=0,  window=mlab.window_hanning,
                         pad_to=None, sides='default', **kwargs)

        Compute the angle spectrum (wrapped phase spectrum) of *x*.
        Data is padded to a length of *pad_to* and the windowing function
        *window* is applied to the signal.

        Parameters
        ----------
        x : 1-D array or sequence
            Array or sequence containing the data.

        %(Spectral)s

        %(Single_Spectrum)s

        Fc : int
            The center frequency of *x* (defaults to 0), which offsets
            the x extents of the plot to reflect the frequency range used
            when a signal is acquired and then filtered and downsampled to
            baseband.

        Returns
        -------
        spectrum : 1-D array
            The values for the angle spectrum in radians (real valued).

        freqs : 1-D array
            The frequencies corresponding to the elements in *spectrum*.

        line : a :class:`~matplotlib.lines.Line2D` instance
            The line created by this function.

        Other Parameters
        ----------------
        **kwargs :
            Keyword arguments control the :class:`~matplotlib.lines.Line2D`
            properties:

            %(Line2D)s

        See Also
        --------
        :func:`magnitude_spectrum`
            :func:`angle_spectrum` plots the magnitudes of the corresponding
            frequencies.

        :func:`phase_spectrum`
            :func:`phase_spectrum` plots the unwrapped version of this
            function.

        :func:`specgram`
            :func:`specgram` can plot the angle spectrum of segments within the
            signal in a colormap.

        Notes
        -----
        .. [Notes section required for data comment. See #10189.]

        Nr   )r   rh  ri  rk  rl  ro  zAngle (radians))rp  angle_spectrumr   rP   rS   )r=   r   rh  rt  ri  rk  rl  rH   r|  rv  r   r   r   r   r~  H  s    E


zAxes.angle_spectrumc             K   s^   |dkrd}t j|||||d\}}	|	|7 }	| j|	|f|}
| d | d ||	|
d fS )a\  
        Plot the phase spectrum.

        Call signature::

          phase_spectrum(x, Fs=2, Fc=0,  window=mlab.window_hanning,
                         pad_to=None, sides='default', **kwargs)

        Compute the phase spectrum (unwrapped angle spectrum) of *x*.
        Data is padded to a length of *pad_to* and the windowing function
        *window* is applied to the signal.

        Parameters
        ----------
        x : 1-D array or sequence
            Array or sequence containing the data

        %(Spectral)s

        %(Single_Spectrum)s

        Fc : int
            The center frequency of *x* (defaults to 0), which offsets
            the x extents of the plot to reflect the frequency range used
            when a signal is acquired and then filtered and downsampled to
            baseband.

        Returns
        -------
        spectrum : 1-D array
            The values for the phase spectrum in radians (real valued).

        freqs : 1-D array
            The frequencies corresponding to the elements in *spectrum*.

        line : a :class:`~matplotlib.lines.Line2D` instance
            The line created by this function.

        Other Parameters
        ----------------
        **kwargs :
            Keyword arguments control the :class:`~matplotlib.lines.Line2D`
            properties:

            %(Line2D)s

        See Also
        --------
        :func:`magnitude_spectrum`
            :func:`magnitude_spectrum` plots the magnitudes of the
            corresponding frequencies.

        :func:`angle_spectrum`
            :func:`angle_spectrum` plots the wrapped version of this function.

        :func:`specgram`
            :func:`specgram` can plot the phase spectrum of segments within the
            signal in a colormap.

        Notes
        -----
        .. [Notes section required for data comment. See #10189.]

        Nr   )r   rh  ri  rk  rl  ro  zPhase (radians))rp  phase_spectrumr   rP   rS   )r=   r   rh  rt  ri  rk  rl  rH   r|  rv  r   r   r   r   r    s    D


zAxes.phase_spectrum   r   rI   c          
   K   s\   t j||||||||d\}}||7 }| j||f| | d | d | d ||fS )a  
        Plot the coherence between *x* and *y*.

        Plot the coherence between *x* and *y*.  Coherence is the
        normalized cross spectral density:

        .. math::

          C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}}

        Parameters
        ----------
        %(Spectral)s

        %(PSD)s

        noverlap : int
            The number of points of overlap between blocks.  The
            default value is 0 (no overlap).

        Fc : int
            The center frequency of *x* (defaults to 0), which offsets
            the x extents of the plot to reflect the frequency range used
            when a signal is acquired and then filtered and downsampled to
            baseband.


        Returns
        -------
        Cxy : 1-D array
            The coherence vector.

        freqs : 1-D array
            The frequencies for the elements in *Cxy*.

        Other Parameters
        ----------------
        **kwargs :
            Keyword arguments control the :class:`~matplotlib.lines.Line2D`
            properties:

            %(Line2D)s

        References
        ----------
        Bendat & Piersol -- Random Data: Analysis and Measurement Procedures,
        John Wiley & Sons (1986)
        )r   r   rg  rh  r  ri  rj  rm  ro  Z	CoherenceT)rp  coherer   rP   rS   r   )r=   r   r   rg  rh  rt  r  ri  rj  rk  rl  rm  rH   Zcxyrv  r   r   r   r    s    5


zAxes.coherec             K   s  |dkrd}|dkrd}|dkr$d}|dkr4t d|dksD|dkrX|dkrRd	}qpd
}n|dkrp|d
krpt dtj|||||||
|||d
\}}}|d	kr|}nJ|d
kr|dks|dks|dkrdt| }qdt| }n
t d|t|}|	dkr,|| | d }t|| t|| f}	|	\}}||7 }|||d |d f}| j||f|||d|}| 	d ||||fS )a@  
        Plot a spectrogram.

        Call signature::

          specgram(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
                   window=mlab.window_hanning, noverlap=128,
                   cmap=None, xextent=None, pad_to=None, sides='default',
                   scale_by_freq=None, mode='default', scale='default',
                   **kwargs)

        Compute and plot a spectrogram of data in *x*.  Data are split into
        *NFFT* length segments and the spectrum of each section is
        computed.  The windowing function *window* is applied to each
        segment, and the amount of overlap of each segment is
        specified with *noverlap*. The spectrogram is plotted as a colormap
        (using imshow).

        Parameters
        ----------
        x : 1-D array or sequence
            Array or sequence containing the data.

        %(Spectral)s

        %(PSD)s

        mode : {'default', 'psd', 'magnitude', 'angle', 'phase'}
            What sort of spectrum to use.  Default is 'psd', which takes
            the power spectral density.  'complex' returns the complex-valued
            frequency spectrum.  'magnitude' returns the magnitude spectrum.
            'angle' returns the phase spectrum without unwrapping.  'phase'
            returns the phase spectrum with unwrapping.

        noverlap : int
            The number of points of overlap between blocks.  The
            default value is 128.

        scale : {'default', 'linear', 'dB'}
            The scaling of the values in the *spec*.  'linear' is no scaling.
            'dB' returns the values in dB scale.  When *mode* is 'psd',
            this is dB power (10 * log10).  Otherwise this is dB amplitude
            (20 * log10). 'default' is 'dB' if *mode* is 'psd' or
            'magnitude' and 'linear' otherwise.  This must be 'linear'
            if *mode* is 'angle' or 'phase'.

        Fc : int
            The center frequency of *x* (defaults to 0), which offsets
            the x extents of the plot to reflect the frequency range used
            when a signal is acquired and then filtered and downsampled to
            baseband.

        cmap :
            A :class:`matplotlib.colors.Colormap` instance; if *None*, use
            default determined by rc

        xextent : *None* or (xmin, xmax)
            The image extent along the x-axis. The default sets *xmin* to the
            left border of the first bin (*spectrum* column) and *xmax* to the
            right border of the last bin. Note that for *noverlap>0* the width
            of the bins is smaller than those of the segments.

        **kwargs :
            Additional kwargs are passed on to imshow which makes the
            specgram image.

        Returns
        -------
        spectrum : 2-D array
            Columns are the periodograms of successive segments.

        freqs : 1-D array
            The frequencies corresponding to the rows in *spectrum*.

        t : 1-D array
            The times corresponding to midpoints of segments (i.e., the columns
            in *spectrum*).

        im : instance of class :class:`~matplotlib.image.AxesImage`
            The image created by imshow containing the spectrogram

        See Also
        --------
        :func:`psd`
            :func:`psd` differs in the default overlap; in returning the mean
            of the segment periodograms; in not returning times; and in
            generating a line plot instead of colormap.

        :func:`magnitude_spectrum`
            A single spectrum, similar to having a single segment when *mode*
            is 'magnitude'. Plots a line instead of a colormap.

        :func:`angle_spectrum`
            A single spectrum, similar to having a single segment when *mode*
            is 'angle'. Plots a line instead of a colormap.

        :func:`phase_spectrum`
            A single spectrum, similar to having a single segment when *mode*
            is 'phase'. Plots a line instead of a colormap.

        Notes
        -----
        The parameters *detrend* and *scale_by_freq* do only apply when *mode*
        is set to 'psd'.
        Nr  r      complexzCannot plot a complex specgramrI   )ZangleZphaser  rn  z,Cannot use dB scale with angle or phase mode)
r   rg  rh  r  ri  rj  rk  rl  rm  r   rq  g      $@g      4@zUnknown scale %sr   rj   )r  r  r  auto)
r   rp  specgramr   r  Zflipudr   r   r1  r5  )r=   r   rg  rh  rt  r  ri  rj  r  Zxextentrk  rl  rm  r   r{  r  r  rH   r|  rv  r   r}  Zpad_xextentr   r   r  r0  r   r   r   r  ,  sL    p




zAxes.specgramr?  rn  c             K   s  |dkr|dkrt |drd}|dkr|dkrt|}t||k}d|krdtjddgdd|d< |j\}	}
d	|
d
 |	d
 d	g}| j|fd|||d|}nt |dr| }|dkr|j	}|j
}n$t|j|k}|j	| }|j
| }n&t|}t||k}t|\}}|dkr"d}|dkr0d}tj||fd||d|}| | |j\}	}
| d	|
d
  | |	d
 d	 | | |}| jd | j  | jd | jtjdddddgdd | jtjdddddgdd |S )a  
        Plot the sparsity pattern of a 2D array.

        This visualizes the non-zero values of the array.

        Two plotting styles are available: image and marker. Both
        are available for full arrays, but only the marker style
        works for `scipy.sparse.spmatrix` instances.

        **Image style**

        If *marker* and *markersize* are *None*, `~.Axes.imshow` is used. Any
        extra remaining kwargs are passed to this method.

        **Marker style**

        If *Z* is a `scipy.sparse.spmatrix` or *marker* or *markersize* are
        *None*, a `~matplotlib.lines.Line2D` object will be returned with
        the value of marker determining the marker type, and any
        remaining kwargs passed to `~.Axes.plot`.

        Parameters
        ----------
        Z : array-like (M, N)
            The array to be plotted.

        precision : float or 'present', optional, default: 0
            If *precision* is 0, any non-zero value will be plotted. Otherwise,
            values of :math:`|Z| > precision` will be plotted.

            For :class:`scipy.sparse.spmatrix` instances, you can also
            pass 'present'. In this case any value present in the array
            will be plotted, even if it is identically zero.

        origin : {'upper', 'lower'}, optional
            Place the [0,0] index of the array in the upper left or lower left
            corner of the axes. The convention 'upper' is typically used for
            matrices and images.
            If not given, :rc:`image.origin` is used, defaulting to 'upper'.


        aspect : {'equal', 'auto', None} or float, optional
            Controls the aspect ratio of the axes. The aspect is of particular
            relevance for images since it may distort the image, i.e. pixel
            will not be square.

            This parameter is a shortcut for explicitly calling
            `.Axes.set_aspect`. See there for further details.

            - 'equal': Ensures an aspect ratio of 1. Pixels will be square.
            - 'auto': The axes is kept fixed and the aspect is adjusted so
              that the data fit in the axes. In general, this will result in
              non-square pixels.
            - *None*: Use :rc:`image.aspect` (default: 'equal').

            Default: 'equal'

        Returns
        -------
        ret : `~matplotlib.image.AxesImage` or `.Line2D`
            The return type depends on the plotting style (see above).

        Other Parameters
        ----------------
        **kwargs
            The supported additional parameters depend on the plotting style.

            For the image style, you can pass the following additional
            parameters of `~.Axes.imshow`:

            - *cmap*
            - *alpha*
            - *url*
            - any `.Artist` properties (passed on to the `.AxesImage`)

            For the marker style, you can pass any `.Line2D` property except
            for *linestyle*:

            %(Line2D)s
        Ntocoor   r  r  r   Zbinary)r   g      g      ?rI  )r.  r-  r  r/  Zpresentr   r   )r   r   r]  g?r  	   r   r   r\   T)nbinsstepsinteger)r   r   r   rJ  r   ZListedColormapr   r1  r  rowr3  r   nonzeror   r   r   rN  rO  rE  r8   set_yrK   tick_topset_ticks_positionset_major_locatormtickerMaxNLocatorrQ   )r=   r}  Z	precisionr   r]  r-  r/  rH   ra  rK  r  r  r   r   r   r   r  Zmarksr   r   r   spy  sZ    S















zAxes.spyc             K   s   t |}|j\}}dddd|}| j|f|}| jd | j  | jd | j	t
jddd	d
dgdd | j	t
jddd	d
dgdd |S )a  
        Plot the values of a 2D matrix or array as color-coded image.

        The matrix will be shown the way it would be printed, with the first
        row at the top.  Row and column numbering is zero-based.

        Parameters
        ----------
        Z : array-like(M, N)
            The matrix to be displayed.

        Returns
        -------
        image : `~matplotlib.image.AxesImage`

        Other Parameters
        ----------------
        **kwargs : `~matplotlib.axes.Axes.imshow` arguments

        See Also
        --------
        imshow : More general function to plot data on a 2D regular raster.

        Notes
        -----
        This is just a convenience function wrapping `.imshow` to set useful
        defaults for a displaying a matrix. In particular:

        - Set ``origin='upper'``.
        - Set ``interpolation='nearest'``.
        - Set ``aspect='equal'``.
        - Ticks are placed to the left and above.
        - Ticks are formatted to show integer indices.

        rn  rI  r?  )r/  r.  r-  g?r  r  r   r   r\   r   T)r  r  r  )r   r   r   r1  r8   r  rK   r  r  r  r  r  rQ   )r=   r}  rH   rK  r  r  r0  r   r   r   matshowS  s"    $






zAxes.matshowdatasetc
          	      s4    fdd}
t j||
|d}| j|||||||dS )a  
        Make a violin plot.

        Make a violin plot for each column of *dataset* or each vector in
        sequence *dataset*.  Each filled area extends to represent the
        entire data range, with optional lines at the mean, the median,
        the minimum, and the maximum.

        Parameters
        ----------
        dataset : Array or a sequence of vectors.
          The input data.

        positions : array-like, default = [1, 2, ..., n]
          Sets the positions of the violins. The ticks and limits are
          automatically set to match the positions.

        vert : bool, default = True.
          If true, creates a vertical violin plot.
          Otherwise, creates a horizontal violin plot.

        widths : array-like, default = 0.5
          Either a scalar or a vector that sets the maximal width of
          each violin. The default is 0.5, which uses about half of the
          available horizontal space.

        showmeans : bool, default = False
          If `True`, will toggle rendering of the means.

        showextrema : bool, default = True
          If `True`, will toggle rendering of the extrema.

        showmedians : bool, default = False
          If `True`, will toggle rendering of the medians.

        points : scalar, default = 100
          Defines the number of points to evaluate each of the
          gaussian kernel density estimations at.

        bw_method : str, scalar or callable, optional
          The method used to calculate the estimator bandwidth.  This can be
          'scott', 'silverman', a scalar constant or a callable.  If a
          scalar, this will be used directly as `kde.factor`.  If a
          callable, it should take a `GaussianKDE` instance as its only
          parameter and return a scalar. If None (default), 'scott' is used.

        Returns
        -------

        result : dict
          A dictionary mapping each component of the violinplot to a
          list of the corresponding collection instances created. The
          dictionary has the following keys:

            - ``bodies``: A list of the
              :class:`matplotlib.collections.PolyCollection` instances
              containing the filled area of each violin.

            - ``cmeans``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the mean values of each of the
              violin's distribution.

            - ``cmins``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the bottom of each violin's
              distribution.

            - ``cmaxes``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the top of each violin's
              distribution.

            - ``cbars``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the centers of each violin's
              distribution.

            - ``cmedians``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the median values of each of the
              violin's distribution.

        Notes
        -----
        .. [Notes section required for data comment. See #10189.]

        c                s:   t | d | kr$| d |ktS t|  }||S )Nr   )r   allri  rD   rp  ZGaussianKDEZevaluate)r  rG  Zkde)	bw_methodr   r   _kde_method  s    z$Axes.violinplot.<locals>._kde_method)points)r   r}  r|  r  showextremashowmedians)r   Zviolin_statsviolin)r=   r  r   r}  r|  r  r  r  r  r  r  vpstatsr   )r  r   
violinplot  s
    ]
zAxes.violinplotc          	   C   s  g }g }	g }
g }i }t |}d}|dkr8td|d }nt ||krRt|dt|rh|g| }nt ||krt|ddt| | }dt| | }|r| j}| j}| j	}n| j
}| j	}| j}td rd	}d
}n| j  }}g }xt|||D ]\}}}t|d }d| | |  }|||d | | || |ddg7 }||d  |	|d  |
|d  ||d  qW ||d< |r|||||d|d< |r||
|||d|d< ||	|||d|d< |||	|
|d|d< |r|||||d|d< |S )a  Drawing function for violin plots.

        Draw a violin plot for each column of `vpstats`. Each filled area
        extends to represent the entire data range, with optional lines at the
        mean, the median, the minimum, and the maximum.

        Parameters
        ----------

        vpstats : list of dicts
          A list of dictionaries containing stats for each violin plot.
          Required keys are:

          - ``coords``: A list of scalars containing the coordinates that
            the violin's kernel density estimate were evaluated at.

          - ``vals``: A list of scalars containing the values of the
            kernel density estimate at each of the coordinates given
            in *coords*.

          - ``mean``: The mean value for this violin's dataset.

          - ``median``: The median value for this violin's dataset.

          - ``min``: The minimum value for this violin's dataset.

          - ``max``: The maximum value for this violin's dataset.

        positions : array-like, default = [1, 2, ..., n]
          Sets the positions of the violins. The ticks and limits are
          automatically set to match the positions.

        vert : bool, default = True.
          If true, plots the violins veritcally.
          Otherwise, plots the violins horizontally.

        widths : array-like, default = 0.5
          Either a scalar or a vector that sets the maximal width of
          each violin. The default is 0.5, which uses about half of the
          available horizontal space.

        showmeans : bool, default = False
          If true, will toggle rendering of the means.

        showextrema : bool, default = True
          If true, will toggle rendering of the extrema.

        showmedians : bool, default = False
          If true, will toggle rendering of the medians.

        Returns
        -------
        result : dict
          A dictionary mapping each component of the violinplot to a
          list of the corresponding collection instances created. The
          dictionary has the following keys:

            - ``bodies``: A list of the
              :class:`matplotlib.collections.PolyCollection` instances
              containing the filled area of each violin.

            - ``cmeans``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the mean values of each of the
              violin's distribution.

            - ``cmins``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the bottom of each violin's
              distribution.

            - ``cmaxes``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the top of each violin's
              distribution.

            - ``cbars``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the centers of each violin's
              distribution.

            - ``cmedians``: A
              :class:`matplotlib.collections.LineCollection` instance
              created to identify the median values of each of the
              violin's distribution.

        zHList of violinplot statistics and `{0}` values must have the same lengthNr   r   r|  g      пg      ?z_internal.classic_moder   r/  r  g      ?rG  g333333?)rd   rf   r  r   r   Zmedianbodies)r   ZcmeansZcmaxesZcminsZcbarsZcmedians)r   ro   r   r    r   r  rF  r$  r   r   r"  rC   r   r  r   r   r   )r=   r  r   r}  r|  r  r  r  r  r   r   r  r  r  r  ZpminsZpmaxesr  Z
perp_linesZ	par_linesZ	fillcolorre   r  r  rw   r  r  r   r   r   r    st    [

zAxes.violinc             O   s   t j| f||S )N)mtri
tricontour)r=   r"   rH   r   r   r   r    s    zAxes.tricontourc             O   s   t j| f||S )N)r  tricontourf)r=   r"   rH   r   r   r   r    s    zAxes.tricontourfc             O   s   t j| f||S )N)r  	tripcolor)r=   r"   rH   r   r   r   r    s    zAxes.tripcolorc             O   s   t j| f||S )N)r  triplot)r=   r"   rH   r   r   r   r    s    zAxes.triplot)r4   )Nr4   N)NN)NN)N)N)NF)r   r   r   )r   r   r   )r   r   )r   r   )r   r   r   )r   r   r   )r   r   r   NNr   )r   NTF)r  N)r  N)NNNNr<  Fr=  NNTNNr>  FF)NNr   NNNFFFFFr   N)NNNNNNNNNNNNNNNNNNNNNNTFN)NNTFFFTTTNNNNNNFTN)NNNNNNNNNNN)r   NNNNr   r  r  NNNr  r  )r   NFN)r   NNF)NNNNNNNNNNr   r  NNN)NNNNFNr1  r  r   NFNNFN)r   NFNNN)
NNNNNNNNNN)
NNNNNNNNNN)NNNNNN)NNNNN)NNNNN)NNNNNNNNNNNNNNN)r   NNr?  rn  )NTrc   FTFr  N)NTrc   FTF)i__name__
__module____qualname____doc__Zanamer?   rJ   rM   rP   rR   rS   rW   	docstringZdedent_interpdr[   rZ   r_   rg   rz   r|   r   r}   r   __init__r   r   r   r   r   r   r   r   r#   r   r   r   r   r   r   rp  Zdetrend_noner   r
  r1  r2  r4  r:  rV  r(  r  r  r  r   r  r  r  r  r  r  Zquiverkey_docr  r  r  Z
quiver_docr  r  r   r  r  r  r"  r$  r1  staticmethodr9  r:  r4  rL  rP  rM  rN  Z_contour_docrQ  rR  Z
ContourSetrT  re  rf  rq  ry  rz  r~  r  Zwindow_hanningr  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r3   w   s  

?


oCk+
TED7
A I J   U oL7106]D  pF
      \               )        
    2   ;1




    


/  4  4    BC k S D

        j  w  l d O N
=       6  f  0


r3   )_Zcollections.abcr  r  r"  ZloggingrH  Znumbersr   r  Znumpyr   r   Z
matplotlibr   Zmatplotlib.cbookr   Zmatplotlib.collectionsr   Zmatplotlib.colorsr   r   Zmatplotlib.contourrP  rM  Zmatplotlib.categorycategoryrg  Zmatplotlib.datesZdatesZmatplotlib.docstringr  Zmatplotlib.imagerH  r(  Zmatplotlib.legendr[   rT   Zmatplotlib.linesr   r   Zmatplotlib.markersZmarkersr  Zmatplotlib.mlabrp  Zmatplotlib.pathr  r  Zmatplotlib.patchesr-  rl   Zmatplotlib.quiverr  r  Zmatplotlib.stackplotr  r  Zmatplotlib.streamplotr   r  Zmatplotlib.tablerT  rS  Zmatplotlib.textr|   r}   Zmatplotlib.tickerZtickerr  Zmatplotlib.transformsZ
transformsr$   Zmatplotlib.triZtrir  r   r   r   r   r	   Zmatplotlib.containerr
   r   r   Zmatplotlib.axes._baser   r   Z	getLoggerr  r  rC   r   r#   r2   r3   r   r   r   r   <module>   sR   
