rL i1fddlZddlZddlZddlZddlmZmZmZddlZddl Z ddl Z ddl Z ddlmZddlmZddlmZddlmZddlmZddlZ ddlmZddl m!Z"ddl#m$Z%ddl&m'Z(ddl)m*Z+ddl,m-Z-ddl.m/Z0ddl1m2Z3ddl4m5Z6ddl7m8Z9ddl:m;Z<ddl=m>Z?ddl@mAZBddlCmDZEddlFmGZHddlImJZKddlLmMZNddl mOZOmPZPmQZQddlRmSZSmTZTmUZUddlVmWZWddlXmYZYmZZZm[Z[ddlFm\Z\eje^Z_dZ`ePjGd d eSZby) N)IntegralNumberReal)_api _docstring_preprocess_data) _AxesBase_TransformedBoundsLocator_process_plot_format) SecondaryAxis) BarContainerErrorbarContainer StemContainer)_ScaledRotationc.d|j|_|S)a Patch the qualname for functions that are directly added to Axes. Some Axes functionality is defined in functions in other submodules. These are simply added as attributes to Axes. As a result, their ``__qualname__`` is e.g. only "table" and not "Axes.table". This function fixes that. Note that the function itself is patched, so that ``matplotlib.table.table.__qualname__` will also show "Axes.table". However, since these functions are not intended to be standalone, this is bearable. zAxes.)__name__ __qualname__)funcs [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/axes/_axes.py_make_axes_methodr1s  /D KceZdZdZddZddddZddZejdZ d Z dd d d Z ejddd dddddZ dZ ejddddZejddddZejddZej ddZej&j(je_ejddZejddZedZejddddZejddZejddZej:d d!egd"d#$ dd%Zej:d d!egd&d'$ dd(Z ej:d d)egd*+ej dd-Z!ejd.d.dd/d0Z"ejFd1d23ed'd#gd#$ejdd5Z$ejd6Z%ejd7Z&ejd8Z'ed'gd'$d9Z(ej:d d:ed'd#gd#$d.e)jTd.d;fd<Z+d=dd>d?Z,ed@Z-dAZ.eejdddBdCZ/ejddddDdEZ0ddFdGddHdIZ1eejdJZ2eddddddKdLdMZ3ej:d dNegdO+ dd.ddPdQZ4edRZ5ej:d dSegdTd#$ej ddUZ6ej:d dVeejnd1dWdX ddYZ8ej:d dZ dd[Z9ed\Z:ej:d d]egd^d#$ej dddd4d_d`Z;ej:d daegdbd#$ejddcdddddddddddddeeejdgZ?ejeAjj(dhZCdiZDeejdjZEeejdkZFddldmZG ddd4ddndoZHdpZI ddqZJeHjr#eHjjd,d'd#reJ_eejeJgds+ZJ ddtZLeHjr#eHjjdKd#d'reL_eejeLgdu+ZLeejddddddddddd.dvdddw dxZMdydzd{ZNeejdddddddd|d}ZOeejdddddddd4d~dZPeejddddddddZQeejdZReejdZSddZTej:d ded'dgd'$ ddZUeddKdd4ddZVej:d degd+ej ddZWed'dgd'$ejdd4dKd4ddZXej:d ded'g+ej ddZYej:d ded'd#gd#$ej ddZZej:d ded'g+ej ddZ[ej:d ded'g+ej ddZ\ej:d ded'g+ej ddZ]ej:d ded'd#g+ejddde)jTe)jddddf dZ_ej:d ded'g+ej ddZ`ej:d dej ddZadZbej:d dedg+ ddZcej:d d ddZdeeefjZgeeeehjZiegd+eeejjZkeeeljZmeeeljZneeeljZoeeeljZpdZqy)Axesai An Axes object encapsulates all the elements of an individual (sub-)plot in a figure. It contains most of the (sub-)plot elements: `~.axis.Axis`, `~.axis.Tick`, `~.lines.Line2D`, `~.text.Text`, `~.patches.Polygon`, etc., and sets the coordinate system. Like all visible elements in a figure, Axes is an `.Artist` subclass. The `Axes` instance supports callbacks through a callbacks attribute which is a `~.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 `Axes` instance. .. note:: As a user, you do not instantiate Axes directly, but use Axes creation methods instead; e.g. from `.pyplot` or `.Figure`: `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` or `.Figure.add_axes`. centerc|j|j|jd}tj||j }|j 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, default: 'center' Which title to return. Returns ------- str The title text string. leftrrightloc) _left_titletitle _right_titler check_getitemlowerget_text)selfr titlesr"s r get_titlezAxes.get_title]sK&** JJ,,.""6syy{;~~rN)yc |tjd}|tjd}|d}nd|_||d<|j|j|j d}t j||j}tjdtjd d |jd } tjd } tj| d s| | d<|tjd}|jt||j||j| ||j||j||S)a 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 .. admonition:: Discouraged The use of *fontdict* is discouraged. Parameters should be passed as individual keyword arguments or using dictionary-unpacking ``set_title(..., **fontdict)``. A dictionary controlling the appearance of the title text, the default *fontdict* is:: {'fontsize': rcParams['axes.titlesize'], 'fontweight': rcParams['axes.titleweight'], 'color': rcParams['axes.titlecolor'], 'verticalalignment': 'baseline', 'horizontalalignment': loc} loc : {'center', 'left', 'right'}, default: :rc:`axes.titlelocation` Which title to set. y : float, default: :rc:`axes.titley` Vertical Axes location for the title (1.0 is the top). If None (the default) and :rc:`axes.titley` is also None, y is determined automatically to avoid decorators on the Axes. pad : float, default: :rc:`axes.titlepad` The offset of the title from the top of the Axes, in points. Returns ------- `.Text` The matplotlib text instance representing the title Other Parameters ---------------- **kwargs : `~matplotlib.text.Text` properties Other keyword arguments are text properties, see `.Text` for a list of valid text properties. zaxes.titlelocationz axes.titley?Fr*rrzaxes.titlesizezaxes.titleweightbaseline)fontsize fontweightverticalalignmenthorizontalalignmentzaxes.titlecolorautocolorz axes.titlepad)mplrcParams _autotitleposr!r"r#rr$r%cbook_str_lower_equal_set_title_offset_transfloatset_textupdate_internal_update) r'labelfontdictr padr*kwargsr(r"default titlecolors r set_titlezAxes.set_titlevs;j ;,,34C 9 ]+A 9A!&D s ** JJ,,.""6syy{; %56,,'9:!+#&99; 0 \\"34 %%j&9)GG  ;,,/C $$U3Z0 u W   LL " v& rc>tj|g|\}}||fS)z Return handles and labels for legend ``ax.legend()`` is equivalent to :: h, l = ax.get_legend_handles_labels() ax.legend(h, l) )mlegend_get_legend_handles_labels)r'legend_handler_maphandleslabelss rget_legend_handles_labelszAxes.get_legend_handles_labelss*"<< F&(rctj|gg|i|\}}}tj|||fi||_|j|j_|jS)aj Place a legend on the Axes. Call signatures:: legend() legend(handles, labels) legend(handles=handles) legend(labels) The call signatures correspond to the following different ways 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:: ax.plot([1, 2, 3], label='Inline label') ax.legend() or:: line, = ax.plot([1, 2, 3]) line.set_label('Label via method') ax.legend() .. note:: Specific artists can be excluded from the automatic legend element selection by using a label starting with an underscore, "_". A string starting with an underscore is the default label for all artists, so calling `.Axes.legend` without any arguments and without setting the labels manually will result in a ``UserWarning`` and an empty legend being drawn. **2. Explicitly listing the artists and labels 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:: ax.legend([line1, line2, line3], ['label1', 'label2', 'label3']) **3. Explicitly listing the artists in the legend** This is similar to 2, but the labels are taken from the artists' label properties. Example:: line1, = ax.plot([1, 2, 3], label='label1') line2, = ax.plot([1, 2, 3], label='label2') ax.legend(handles=[line1, line2]) **4. Labeling existing plot elements** .. admonition:: Discouraged This call signature is discouraged, because the relation between plot elements and labels is only implicit by their order and can easily be mixed up. To make a legend for all artists on an Axes, call this function with an iterable of strings, one for each legend item. For example:: ax.plot([1, 2, 3]) ax.plot([5, 6, 7]) ax.legend(['First line', 'Second line']) Parameters ---------- handles : list of (`.Artist` or tuple 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. If an entry contains a tuple, then the legend handler for all Artists in the tuple will be placed alongside a single label. labels : list of str, 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. Returns ------- `~matplotlib.legend.Legend` Other Parameters ---------------- %(_legend_kw_axes)s See Also -------- .Figure.legend Notes ----- Some artists are not supported by this function. See :ref:`legend_guide` for details. Examples -------- .. plot:: gallery/text_labels_and_annotations/legend.py )rF_parse_legend_argsLegendlegend__remove_legend_remove_method)r'argsrArIrJs rlegendz Axes.legends]l#*"<" inset_axesF)rootrX) transAxes setdefaultr bounds get_figure _process_projection_requirementsset_axes_locatoradd_child_axes) r'r_rWrXrA inset_locatorfigprojection_classpkwinset_axs rrZzAxes.inset_axesXsj  I'<02&)D tT*11oo5o) D D D Nv N##CFF#F !!-0 H%rnonez0.5?)rW facecolor edgecoloralpharXc |j| |j}|jddtj|f||||||d|} |j | | 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], optional Lower-left corner of rectangle to be marked, and its width and height. If not set, the bounds will be calculated from the data limits of *inset_ax*, which must be supplied. inset_ax : `.Axes`, optional 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 coordinates. Defaults to ``ax.transAxes``, i.e. the units of *rect* are in Axes-relative coordinates. facecolor : :mpltype:`color`, default: 'none' Facecolor of the rectangle. edgecolor : :mpltype:`color`, default: '0.5' Color of the rectangle and color of the connecting lines. alpha : float or None, default: 0.5 Transparency of the rectangle and connector lines. If not ``None``, this overrides any alpha value included in the *facecolor* and *edgecolor* parameters. zorder : float, default: 4.99 Drawing order of the rectangle and connector lines. The default, 4.99, is just below the default level of inset Axes. **kwargs Other keyword arguments are passed on to the `.Rectangle` patch: %(Rectangle:kwdoc)s Returns ------- inset_indicator : `.inset.InsetIndicator` An artist which contains inset_indicator.rectangle : `.Rectangle` The indicator frame. inset_indicator.connectors : 4-tuple of `.patches.ConnectionPatch` The four connector lines connecting to (lower_left, upper_left, lower_right upper_right) corners of *inset_ax*. Two lines are set with visibility to *False*, but the user can set the visibility to True if the automatic choice is not deemed correct. .. versionchanged:: 3.10 Previously the rectangle and connectors tuple were returned. r>_indicate_inset)rhrkrlrmrXrW) apply_aspect transDatar^minsetInsetIndicator add_artist) r'r_rhrWrkrlrmrXrAindicator_patchs rindicate_insetzAxes.indicate_insetsvJ   I'#45 // :%9EY:39: (rc *|jd|fi|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 keyword arguments are passed on to `.Axes.indicate_inset` Returns ------- inset_indicator : `.inset.InsetIndicator` An artist which contains inset_indicator.rectangle : `.Rectangle` The indicator frame. inset_indicator.connectors : 4-tuple of `.patches.ConnectionPatch` The four connector lines connecting to (lower_left, upper_left, lower_right upper_right) corners of *inset_ax*. Two lines are set with visibility to *False*, but the user can set the visibility to True if the automatic choice is not deemed correct. .. versionchanged:: 3.10 Previously the rectangle and connectors tuple were returned. N)rv)r'rhrAs rindicate_inset_zoomzAxes.indicate_inset_zoomsL#t""4>> 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-rF)r0r1rWclip_ontext)rqmtextText get_clip_path set_clip_pathpatch _add_text)r'r|r*sr?rAeffective_kwargsts rrz Axes.text}sD",#)  $/xR     JJq! 8! 8'7 8 ??  $ OODJJ ' qrc "tj||f|||||d|} | jtj|j ddr+| j | j|j|j| | S)N)xytextxycoords textcoords arrowpropsannotation_cliprF) r Annotation set_transform mtransformsIdentityTransformgetrrrr) r'rxyrrrrrrAas rannotatez Axes.annotates   T2 Hfx(2z-< H@F H  5578 ::i 'AOO,=,E OODJJ ' qrrc |j||gddgd|vr td|j\}}|jd|fg|\}||kxs||kD}|j d} t j ||g||gfd| i|} |j| tjj| j_ |r|jd| S)a Add a horizontal line spanning the whole or fraction of the Axes. Note: If you want to set x-limits in data coordinates, use `~.Axes.hlines` instead. Parameters ---------- y : float, default: 0 y position in :ref:`data coordinates `. xmin : float, default: 0 The start x-position in :ref:`axes coordinates `. Should be between 0 and 1, 0 being the far left of the plot, 1 the far right of the plot. xmax : float, default: 1 The end x-position in :ref:`axes coordinates `. Should be between 0 and 1, 0 being the far left of the plot, 1 the far right of the plot. Returns ------- `~matplotlib.lines.Line2D` A `.Line2D` specified via two points ``(xmin, y)``, ``(xmax, y)``. Its transform is set such that *x* is in :ref:`axes coordinates ` and *y* is in :ref:`data coordinates `. This is still a generic line and the horizontal character is only realized through using identical *y* values for both points. Thus, if you want to change the *y* value later, you have to provide two values ``line.set_ydata([3, 3])``. Other Parameters ---------------- **kwargs Valid keyword arguments are `.Line2D` properties, except for 'transform': %(Line2D:kwdoc)s See Also -------- hlines : Add horizontal lines in data coordinates. axhspan : Add a horizontal span (rectangle) across the axis. axline : Add a line with an arbitrary slope. 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) xminxmaxrWzV'transform' is not allowed as a keyword argument; axhline generates its own transform.r*gridwhich)_check_no_unitsr get_ybound_process_unit_infoget_yaxis_transformmlinesLine2Dadd_liner4axisGRIDLINE_INTERPOLATION_STEPSget_path_interpolation_steps_request_autoscale_view) r'r*rrrAyminymaxyyscaleytransls raxhlinez Axes.axhlinesB dD\FF+;< & NO O__& d%%Qxj&9t)+d((v(6 MM4,A J% J6 J a,/HH,Q,Q )   ( ( -rc |j||gddgd|vr td|j\}}|jd|fg|\}||kxs||kD}|j d} t j ||g||gfd| i|} |j| tjj| j_ |r|jd| S)a Add a vertical line spanning the whole or fraction of the Axes. Note: If you want to set y-limits in data coordinates, use `~.Axes.vlines` instead. Parameters ---------- x : float, default: 0 x position in :ref:`data coordinates `. ymin : float, default: 0 The start y-position in :ref:`axes coordinates `. Should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot. ymax : float, default: 1 The end y-position in :ref:`axes coordinates `. Should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot. Returns ------- `~matplotlib.lines.Line2D` A `.Line2D` specified via two points ``(x, ymin)``, ``(x, ymax)``. Its transform is set such that *x* is in :ref:`data coordinates ` and *y* is in :ref:`axes coordinates `. This is still a generic line and the vertical character is only realized through using identical *x* values for both points. Thus, if you want to change the *x* value later, you have to provide two values ``line.set_xdata([3, 3])``. Other Parameters ---------------- **kwargs Valid keyword arguments are `.Line2D` properties, except for 'transform': %(Line2D:kwdoc)s See Also -------- vlines : Add vertical lines in data coordinates. axvspan : Add a vertical span (rectangle) across the axis. axline : Add a line with an arbitrary slope. 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) rrrWzV'transform' is not allowed as a keyword argument; axvline generates its own transform.r|rr)rr get_xboundrget_xaxis_transformrrrr4rrrrr) r'r|rrrArrxxscalexrrs raxvlinez Axes.axvline/sB dD\FF+;< & NO O__& d%%Qxj&9t)+d((v(6 MM1a&4, J% J6 J a,/HH,Q,Q )   ( ( -rcvt||D]*\}}tj|rt|d|y)Nz( must be a single scalar value, but got )zipmunits_is_natively_supportedr)valsnamesvalnames rrzAxes._check_no_unitssLT5) 3IC005 D6*,,/5"233 3r)slopec N|1|jdk7s|jdk7r td||gn||g}d|vrg}tj|||fi|}|j ||j |j|j|js'|jdt|j|jj||jj|_|j!||j#|S)a\ Add an infinitely long straight line. The line can be defined either by two points *xy1* and *xy2*, or by one point *xy1* and a *slope*. This draws a straight line "on the screen", regardless of the x and y scales, and is thus also suitable for drawing exponential decays in semilog plots, power laws in loglog plots, etc. However, *slope* should only be used with linear scales; It has no clear meaning for all other scales, and thus the behavior is undefined. Please specify the line using the points *xy1*, *xy2* for non-linear scales. The *transform* keyword argument only applies to the points *xy1*, *xy2*. The *slope* (if given) is always in data coordinates. This can be used e.g. with ``ax.transAxes`` for drawing grid lines with a fixed slope. Parameters ---------- xy1, xy2 : (float, float) Points for the line to pass through. Either *xy2* or *slope* has to be given. slope : float, optional The slope of the line. Either *xy2* or *slope* has to be given. Returns ------- `.AxLine` Other Parameters ---------------- **kwargs Valid kwargs are `.Line2D` properties %(Line2D:kwdoc)s See Also -------- axhline : for horizontal lines axvline : for vertical lines Examples -------- Draw a thick red line passing through (0, 0) and (1, 1):: >>> axline((0, 0), (1, 1), linewidth=4, color='r') linearz-'slope' cannot be used with non-linear scalesrW_child) get_xscale get_yscale TypeErrorrAxLine_set_artist_propsrrr get_label set_labellen _childrenappendremoverQupdate_datalimr)r'xy1xy2rrAdatalimlines raxlinez Axes.axlinesd  $//"3x"?"&//"3x"?KL L;3%S#J & G}}S#u77 t$     '   tzz *~~ NNVC$7#89 : d#"nn33 G$ $$& rc B|j||gddg|jd||gfg|\\}}tj||f||z ||z fi|}|j |j d|j jj}|j j}|j|||j _||j _ tjj|j_|j!d|S)a Add a horizontal span (rectangle) across the Axes. The rectangle spans from *ymin* to *ymax* vertically, and, by default, the whole x-axis horizontally. The x-span can be set using *xmin* (default: 0) and *xmax* (default: 1) which are in axis units; e.g. ``xmin = 0.5`` always refers to the middle of the x-axis regardless of the limits set by `~.Axes.set_xlim`. Parameters ---------- ymin : float Lower y-coordinate of the span, in data units. ymax : float Upper y-coordinate of the span, in data units. xmin : float, default: 0 Lower x-coordinate of the span, in x-axis (0-1) units. xmax : float, default: 1 Upper x-coordinate of the span, in x-axis (0-1) units. Returns ------- `~matplotlib.patches.Rectangle` Horizontal span (rectangle) from (xmin, ymin) to (xmax, ymax). Other Parameters ---------------- **kwargs : `~matplotlib.patches.Rectangle` properties %(Rectangle:kwdoc)s See Also -------- axvspan : Add a vertical span across the Axes. rrr*rr)rrmpatches RectanglerrdataLim intervalxcopyminposx add_patchr4rrrrr) r'rrrrrApixmxs raxhspanz Axes.axhspansL dD\FF+;<//#d|1D0EvN t   d|TD[$+ P P 00v0>?\\ # # ( ( * \\ ! ! q!# ! ,/HH,Q,Q ) $$S)rc B|j||gddg|jd||gfg|\\}}tj||f||z ||z fi|}|j |j d|j jj}|j j}|j|||j _||j _ tjj|j_|j!d|S)a Add a vertical span (rectangle) across the Axes. The rectangle spans from *xmin* to *xmax* horizontally, and, by default, the whole y-axis vertically. The y-span can be set using *ymin* (default: 0) and *ymax* (default: 1) which are in axis units; e.g. ``ymin = 0.5`` always refers to the middle of the y-axis regardless of the limits set by `~.Axes.set_ylim`. Parameters ---------- xmin : float Lower x-coordinate of the span, in data units. xmax : float Upper x-coordinate of the span, in data units. ymin : float, default: 0 Lower y-coordinate of the span, in y-axis units (0-1). ymax : float, default: 1 Upper y-coordinate of the span, in y-axis units (0-1). Returns ------- `~matplotlib.patches.Rectangle` Vertical span (rectangle) from (xmin, ymin) to (xmax, ymax). Other Parameters ---------------- **kwargs : `~matplotlib.patches.Rectangle` properties %(Rectangle:kwdoc)s 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) rrr|rr)rrrrrrr intervalyrminposyrr4rrrrr) r'rrrrrAriymys raxvspanz Axes.axvspan s\ dD\FF+;<//#d|1D0EvN t   d|TD[$+ P P 00v0>?\\ # # ( ( * \\ ! ! q!# ! ,/HH,Q,Q ) $$S)r3.10r>)r*rrcolorsr*) replace_names label_namerc |jd|fd|fd|fg|\}}}tj|s|g}tj|s|g}tj|s|g}tj|||\}}}tj |}tj |}tj |}tj jt|ddf}||ddddf<||ddddf<||ddddf<||ddddf<tj||||} |j| d | j|t|dkDrdd } d } |jd k(r| j|j} | j!} | j#|j\} } tj$| j&}tj(| j*}tj$| j,}tj(| j.}n`tj$|d }tj(|d }tj$|d }tj(|d }||f||ff}|j1|| | |j3| S)a Plot horizontal lines at each *y* from *xmin* to *xmax*. Parameters ---------- y : float or array-like y-indexes where to plot the lines. xmin, xmax : float or array-like Respective beginning and end of each line. If scalars are provided, all lines will have the same length. colors : :mpltype:`color` or list of color , default: :rc:`lines.color` linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, default: 'solid' label : str, default: '' Returns ------- `~matplotlib.collections.LineCollection` Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs : `~matplotlib.collections.LineCollection` properties. See Also -------- vlines : vertical lines axhline : horizontal line across the Axes r|r*Nrr linestylesr>FautolimT rectilinear.r.rrnpiterabler7_combine_masksravelmaemptyrmcollLineCollectionadd_collectionr=r get_datalimrq get_transformcontains_branch_seperatelynanminrnanmaxrrrrr)r'r*rrrrr>rA masked_vertslinesupdatexupdateyrrminxmaxxminymaxycornerss rhlinesz Axes.hlinesJsnP//4[3+Qx 0&: dA{{1~A{{4 6D{{4 6D,,Qd; 4 HHQKxx~xx~uu{{CFAq>2 $ Q1W ! Q1W $ Q1W ! Q1W$$\&0:%I E51 v& q6A:GGyyM)++DNN;'')#$#?#?#O yy.yy.yy.yy.yyf!56yyf!56yyf!56yyf!56TlT4L0G   ' :  ( ( * r)r|rrrr|c |jd|fd|fd|fg|\}}}tj|s|g}tj|s|g}tj|s|g}tj|||\}}}tj |}tj |}tj |}tj jt|ddf}||ddddf<||ddddf<||ddddf<||ddddf<tj||||} |j| d | j|t|dkDrdd } d } |jd k(r| j|j} | j!} | j#|j\} } tj$| j&}tj(| j*}tj$| j,}tj(| j.}n`tj$|d }tj(|d }tj$|d }tj(|d }||f||ff}|j1|| | |j3| S)a Plot vertical lines at each *x* from *ymin* to *ymax*. Parameters ---------- x : float or array-like x-indexes where to plot the lines. ymin, ymax : float or array-like Respective beginning and end of each line. If scalars are provided, all lines will have the same length. colors : :mpltype:`color` or list of color, default: :rc:`lines.color` linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, default: 'solid' label : str, default: '' Returns ------- `~matplotlib.collections.LineCollection` Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs : `~matplotlib.collections.LineCollection` properties. See Also -------- hlines : horizontal lines axvline : vertical line across the Axes r|r*rNrrrFrTrrrr)r'r|rrrrr>rAr r rrrrrrrrrs rvlinesz Axes.vlinessnP//1XT{S$K 0&: 4{{1~A{{4 6D{{4 6D,,Qd; 4 HHQKxx~xx~uu{{CFAq>2 ! Q1W $ Q1W ! Q1W $ Q1W$$\&0:%I E51 v& q6A:GGyyM)++DNN;'')#$#?#?#O yy.yy.yy.yy.yyf!56yyf!56yyf!56yyf!56TlT4L0G   ' :  ( ( * r orientation) positions lineoffsets linelengths linewidthsrr)r horizontalc |jd|fd|fg| \}}tj|s|g}nKtd|Dr#|D cgc]} tj| }} ntj|g}g} |D]} | |jd| fg| z } | }t j || d}t j || d}t j || d}tj|s|g}tj|s|g}tj|s|g}tj|s|g}tj|s|g}t|dstj|s|g}tj|}tj|}tj|}t|dk(r td t|dk(r td t|dk(r td t|dk(r td t|dk(r td t|dk(rdg} tj|}t|dk(rGt|dk7r9tj|t|}d|d<tj|}t|dk(rtj|t|}t|dk(rtj|t|}t|dk(rt|t|z}t|dk(rt|t|z}t|dk(r|gt|z}t|t|k7r tdt|t|k7r tdt|t|k7r tdt|t|k7r tdt|t|k7r tdt|t|k7r tdg} t!|||||||D]\\} } }}}}}t#j$| || |||||}|j'|d|j)| | j+|^t|dkDr|Dcgc]:}t|dkDr*tj,|tj.|f<}}t|dkDrt!|\}}tj,|}tj.|}||z j-}||zj/}|dk(r ||f||ff}n||f||ff}|j1||j3| Scc} w#t$rYZwxYwcc}w)aw Plot identical parallel lines at the given positions. 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 : array-like or list of array-like A 1D array-like defines the positions of one sequence of events. Multiple groups of events may be passed as a list of array-likes. Each group can be styled independently by passing lists of values to *lineoffsets*, *linelengths*, *linewidths*, *colors* and *linestyles*. Note that *positions* can be a 2D array, but in practice different event groups usually have different counts so that one will use a list of different-length arrays rather than a 2D array. orientation : {'horizontal', 'vertical'}, default: 'horizontal' The direction of the event sequence: - 'horizontal': the events are arranged horizontally. The indicator lines are vertical. - 'vertical': the events are arranged vertically. The indicator lines are horizontal. lineoffsets : float or array-like, default: 1 The offset of the center of the lines from the origin, in the direction orthogonal to *orientation*. If *positions* is 2D, this can be a sequence with length matching the length of *positions*. linelengths : float or array-like, default: 1 The total height of the lines (i.e. the lines stretches from ``lineoffset - linelength/2`` to ``lineoffset + linelength/2``). If *positions* is 2D, this can be a sequence with length matching the length of *positions*. linewidths : float or array-like, default: :rc:`lines.linewidth` The line width(s) of the event lines, in points. If *positions* is 2D, this can be a sequence with length matching the length of *positions*. colors : :mpltype:`color` or list of color, default: :rc:`lines.color` The color(s) of the event lines. If *positions* is 2D, this can be a sequence with length matching the length of *positions*. alpha : float or array-like, default: 1 The alpha blending value(s), between 0 (transparent) and 1 (opaque). If *positions* is 2D, this can be a sequence with length matching the length of *positions*. linestyles : str or tuple or list of such values, default: 'solid' 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. If *positions* is 2D, this can be a sequence with length matching the length of *positions*. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Other keyword arguments are line collection properties. See `.LineCollection` for a list of the valid properties. Returns ------- list of `.EventCollection` The `.EventCollection` that were added. Notes ----- For *linelengths*, *linewidths*, *colors*, *alpha* 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*c3FK|]}tj|ywrU)rr).0positions r z!Axes.eventplot..xsA8X&As!r|r3 linewidth linestyler%rzlineoffsets cannot be emptyzlinelengths cannot be emptyzlinestyles cannot be emptyzlinewidths cannot be emptyzalpha cannot be emptyNrz5lineoffsets and positions are unequal sized sequencesz5linelengths and positions are unequal sized sequencesz4linewidths and positions are unequal sized sequencesz0colors and positions are unequal sized sequencesz/alpha and positions are unequal sized sequencesz4linestyles and positions are unequal sized sequences)r lineoffset linelengthr#r3rmr$Frvertical)rrrany asanyarrayr7_local_over_kwdicthasattrasarrayrrmcolors to_rgba_arraytilecumsumlistrrEventCollectionrr=rminmaxrr)r'rrrrrrrmrrAr!posscollsr%r&r#r3alpha_r$coll_pmin_maxminsmaxesminposmaxposminlinemaxliners r eventplotzAxes.eventplots`$(#:#:{#c;%78&$B [{{9%" I AyA AAJKXx0KIKy12I! GH D++c8_,=vF FD G ))&&'B--j&+N --j&+N {{;'&-K{{;'&-K{{:&$J{{6"XF{{5!GE :w 'r{{:/F$Jjj- jj- ZZ + { q :; ; { q :; ; z?a 9: : z?a 9: : u:?45 5 v;! VF **62F { q S^q%8''+s9~>KKN))K0K { q ''+s9~>K z?a S^4>3D   e  4  ! !& ) LL   y>A :C'Bb'A+r BFF2J/'G'7|a!7m e&499;&499;*,&/'61BBG%w/&'1BBG##G,,,. {L`    v's V0V5 ?W5 WWT)rrdatactj|tj}g|j|g|d|i|}|D]}|j ||r|j d|r|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.DataFrame` 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') - If *x* and/or *y* are 2D arrays, a separate data set will be drawn for every column. If both *x* and *y* are 2D, they must have the same shape. If only one of them is 2D with shape (N, m) the other must have length N and will be used for every data set m. Example: >>> x = [1, 2, 3] >>> y = np.array([[1, 2], [3, 4], [5, 6]]) >>> plot(x, y) is equivalent to: >>> for col in range(y.shape[1]): ... plot(x, y[:, col]) - 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 :rc:`axes.prop_cycle`. Parameters ---------- x, y : array-like or float The horizontal / vertical coordinates of the data points. *x* values are optional and default to ``range(len(y))``. Commonly, these parameters are 1D arrays. They can also be scalars, or two-dimensional (in that case, the columns represent separate data sets). These arguments cannot be passed as keywords. 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. This argument cannot be passed as keyword. 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)``. Returns ------- list of `.Line2D` A list of lines representing the plotted data. Other Parameters ---------------- scalex, scaley : bool, default: True These parameters determine if the view limits are adapted to the data limits. The values are passed on to `~.axes.Axes.autoscale_view`. **kwargs : `~matplotlib.lines.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 specify multiple lines with one plot call, the kwargs apply to all those lines. In case the label object is iterable, each element is used as labels for each set of data. Here is a list of available `.Line2D` properties: %(Line2D:kwdoc)s 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 = '[marker][line][color]' 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. Other combinations such as ``[color][marker][line]`` are also supported, but note that their parsing may be ambiguous. **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 ``'8'`` octagon marker ``'s'`` square marker ``'p'`` pentagon marker ``'P'`` plus (filled) marker ``'*'`` star marker ``'h'`` hexagon1 marker ``'H'`` hexagon2 marker ``'+'`` plus marker ``'x'`` x marker ``'X'`` x (filled) 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 'or' # red circles '-g' # green solid line '--' # dashed line with default color '^k:' # black triangle_up markers connected by a dotted line **Colors** The supported color abbreviations are the single letter codes ============= =============================== character color ============= =============================== ``'b'`` blue ``'g'`` green ``'r'`` red ``'c'`` cyan ``'m'`` magenta ``'y'`` yellow ``'k'`` black ``'w'`` white ============= =============================== and the ``'CN'`` colors that index into the default property cycle. 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'``). rBr|r*)r7normalize_kwargsrr _get_linesrr)r'rrrBrRrAr rs rplotz Axes.plotsh'' >D/$//$CCDCFCD D MM$    ( ( -   ( ( - rz3.9rF) alternativeFc x|r|j||r|j||j|||fi|S)a Plot coercing the axis to treat floats as dates. .. deprecated:: 3.9 This method exists for historic reasons and will be removed in version 3.11. - ``datetime``-like data should directly be plotted using `~.Axes.plot`. - If you need to plot plain numeric data as :ref:`date-format` or need to set a timezone, call ``ax.xaxis.axis_date`` / ``ax.yaxis.axis_date`` before `~.Axes.plot`. See `.Axis.axis_date`. 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*. Note that `.plot` will work with `datetime` and `numpy.datetime64` objects without resorting to this method. 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 `. fmt : str, optional The plot format string. For details, see the corresponding parameter in `.plot`. tz : timezone string or `datetime.tzinfo`, default: :rc:`timezone` The time zone to use in labeling dates. xdate : bool, default: True If *True*, the *x*-axis will be interpreted as Matplotlib dates. ydate : bool, default: False If *True*, the *y*-axis will be interpreted as Matplotlib dates. Returns ------- list of `.Line2D` Objects representing the plotted data. Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Keyword arguments control the `.Line2D` properties: %(Line2D:kwdoc)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). ) xaxis_date yaxis_daterF)r'r|r*fmttzxdateydaterAs r plot_datezAxes.plot_dates=V  OOB   OOB tyyAs-f--rc |jDcic] \}}|dvr||}}}|jdi||jDcic] \}}|dvr||}}}|jdi||j|i|jDcic]\}}|h||vs||c}}Scc}}wcc}}wcc}}w)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 the concepts and parameters of plot can be used here as well. The additional parameters *base*, *subs* and *nonpositive* control the x/y-axis properties. They are just forwarded to `.Axes.set_xscale` and `.Axes.set_yscale`. To use different properties on the x-axis and the y-axis, use e.g. ``ax.set_xscale("log", base=10); ax.set_yscale("log", base=2)``. Parameters ---------- base : float, default: 10 Base of the logarithm. subs : sequence, optional The location of the minor 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. nonpositive : {'mask', 'clip'}, default: 'clip' Non-positive values can be masked as invalid, or clipped to a very small positive number. **kwargs All parameters supported by `.plot`. Returns ------- list of `.Line2D` Objects representing the plotted data. basesubs nonpositivebasexsubsxnonposxrRrSrTbaseysubsynonposylog)items set_xscale set_yscalerF)r'rRrAkvdxdys rloglogz Axes.loglogLsT &||~5tq!44d55 $$%||~5tq!44d55 $$tyy O'-||~Mtq!*B**9LadMO O55 NsB0 B6B<%B<c |jDcic] \}}|dvr||}}}|jdi||j|i|jDcic] \}}||vs ||c}}Scc}}wcc}}w)a 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 the concepts and parameters of plot can be used here as well. The additional parameters *base*, *subs*, and *nonpositive* control the x-axis properties. They are just forwarded to `.Axes.set_xscale`. Parameters ---------- base : float, default: 10 Base of the x logarithm. subs : 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. nonpositive : {'mask', 'clip'}, default: 'clip' Non-positive values in x can be masked as invalid, or clipped to a very small positive number. **kwargs All parameters supported by `.plot`. Returns ------- list of `.Line2D` Objects representing the plotted data. rQr\)r^r_rFr'rRrArarbds rsemilogxz Axes.semilogxN%lln 4da33T 4 4 ##tyy F'-||~Dtq!!adDF F  4 EA3 A9(A9c |jDcic] \}}|dvr||}}}|jdi||j|i|jDcic] \}}||vs ||c}}Scc}}wcc}}w)a 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 the concepts and parameters of plot can be used here as well. The additional parameters *base*, *subs*, and *nonpositive* control the y-axis properties. They are just forwarded to `.Axes.set_yscale`. Parameters ---------- base : float, default: 10 Base of the y logarithm. subs : 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. nonpositive : {'mask', 'clip'}, default: 'clip' Non-positive values in y can be masked as invalid, or clipped to a very small positive number. **kwargs All parameters supported by `.plot`. Returns ------- list of `.Line2D` Objects representing the plotted data. rXr\)r^r`rFrgs rsemilogyz Axes.semilogyrjrkc *|j||fi|S)aK Plot the autocorrelation of *x*. Parameters ---------- x : array-like Not run through Matplotlib's unit conversion, so this should be a unit-less array. detrend : callable, default: `.mlab.detrend_none` (no detrending) A detrending function applied to *x*. It must have the signature :: detrend(x: np.ndarray) -> np.ndarray normed : bool, default: True If ``True``, input vectors are normalised to unit length. usevlines : bool, default: True Determines the plot style. If ``True``, vertical lines are plotted from 0 to the acorr value using `.Axes.vlines`. Additionally, a horizontal line is plotted at y=0 using `.Axes.axhline`. If ``False``, markers are plotted at the acorr values using `.Axes.plot`. maxlags : int, default: 10 Number of lags to show. If ``None``, will return all ``2 * len(x) - 1`` lags. Returns ------- lags : array (length ``2*maxlags+1``) The lag vector. c : array (length ``2*maxlags+1``) The 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 : `~matplotlib.lines.Line2D` or None Horizontal line at 0 if *usevlines* is True None *usevlines* is False. Other Parameters ---------------- linestyle : `~matplotlib.lines.Line2D` property, optional The linestyle for plotting the data points. Only used if *usevlines* is ``False``. marker : str, default: 'o' The marker for plotting the data points. Only used if *usevlines* is ``False``. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Additional parameters are passed to `.Axes.vlines` and `.Axes.axhline` if *usevlines* is ``True``; otherwise they are passed to `.Axes.plot`. Notes ----- The cross correlation is performed with `numpy.correlate` with ``mode = "full"``. )xcorr)r'r|rAs racorrz Axes.acorrsPtzz!Q)&))rnormed c t|}|t|k7r td|tj|}|tj|}tj||d} |rC| tj tj ||tj ||zz } ||dz }||k\s|dkrtd|ztj| |dz} | |dz |z ||z} |r;|j| dg| fi|} |jdd |jdi|} n<|jd d |jd d |j| | fi|\} d} | | | | fS)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, y : array-like of length n Neither *x* nor *y* are run through Matplotlib's unit conversion, so these should be unit-less arrays. detrend : callable, default: `.mlab.detrend_none` (no detrending) A detrending function applied to *x* and *y*. It must have the signature :: detrend(x: np.ndarray) -> np.ndarray normed : bool, default: True If ``True``, input vectors are normalised to unit length. usevlines : bool, default: True Determines the plot style. If ``True``, vertical lines are plotted from 0 to the xcorr value using `.Axes.vlines`. Additionally, a horizontal line is plotted at y=0 using `.Axes.axhline`. If ``False``, markers are plotted at the xcorr values using `.Axes.plot`. maxlags : int, default: 10 Number of lags to show. If None, will return all ``2 * len(x) - 1`` lags. Returns ------- lags : array (length ``2*maxlags+1``) The lag vector. c : array (length ``2*maxlags+1``) The 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 : `~matplotlib.lines.Line2D` or None Horizontal line at 0 if *usevlines* is True None *usevlines* is False. Other Parameters ---------------- linestyle : `~matplotlib.lines.Line2D` property, optional The linestyle for plotting the data points. Only used if *usevlines* is ``False``. marker : str, default: 'o' The marker for plotting the data points. Only used if *usevlines* is ``False``. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Additional parameters are passed to `.Axes.vlines` and `.Axes.axhline` if *usevlines* is ``True``; otherwise they are passed to `.Axes.plot`. Notes ----- The cross correlation is performed with `numpy.correlate` with ``mode = "full"``. zx and y must be equal lengthfull)modeNrz.maxlags must be None or strictly positive < %drr>markeror$Noner\) rrrr, correlatesqrtdotarangerpoprr^rF) r'r|r*rqdetrend usevlinesmaxlagsrANxcorrelslagsrbs rroz Axes.xcorr)s|\V Q<;< < BJJqM " BJJqM ",,q!&1 q! rvva|(C DDG ?1fG b=GaK-/123 3yy'7Q;/"q&7*2<8  D1#w9&9A JJw # &v&A   h ,   k6 243F3BAAWa""rpre)whererBcrtjd|d|z|d<|j||g|d|i|S)a6 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. .. note:: This method uses a standard plot with a step drawstyle: The *x* values are the reference positions and steps extend left/right/both directions depending on *where*. For the common case where you know the values and edges of the steps, use `~.Axes.stairs` instead. Parameters ---------- x : array-like 1D sequence of x positions. It is assumed, but not checked, that it is uniformly increasing. y : array-like 1D 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. where : {'pre', 'post', 'mid'}, 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. data : indexable object, optional An object with labelled data. If given, provide the label names to plot in *x* and *y*. **kwargs Additional parameters are the same as those for `.plot`. Returns ------- list of `.Line2D` Objects representing the plotted data. )rpostmid)rzsteps- drawstylerB)r check_in_listrF)r'r|r*rrBrRrAs rstepz Axes.stepsG@ 1?&.{tyyA::4:6::rct|tjusJ|jdk(r||S t j |} t j |}d}tj|s|g}d}|Dcgc]}|||z|z }}|r|d}|S#t ttf$rYlwxYw#t ttf$r|}YrwxYwcc}w#tt tf$r ||}Y|SwxYw)aI Small helper to do logic of width conversion flexibly. *dx* and *x0* have units, but *xconv* has already been converted to unitless (and is an ndarray). This allows the *dx* to have units that are different from *x0*, but are still accepted by the ``__add__`` operator of *x0*. rFT) typerndarraysizer7_safe_first_finiter IndexErrorKeyErrorrrAttributeError)rcx0xconvconvertr|delistddxs r _convert_dxzAxes._convert_dxsE{bjj((( ::?2;   --b1 ,,U3F;;r?T356C'"s(#a'6B6U  'z84   z84  7I~6 B  sYB" B<" CC C"B96C8B99C<CCCCC=<C=c|jdd}|jd|}|jdd}||n|jj} tj|}||fS#t $r}t d|d}~wwxYw)a8 Helper function to process color-related arguments of `.Axes.bar`. Argument precedence for facecolors: - kwargs['facecolor'] - kwargs['color'] - 'Result of ``self._get_patches_for_fill.get_next_color`` Argument precedence for edgecolors: - kwargs['edgecolor'] - None Parameters ---------- self : Axes kwargs : dict Additional kwargs. If these keys exist, we pop and process them: 'facecolor', 'edgecolor', 'color' Note: The dict is modified by this function. Returns ------- facecolor The facecolor. One or more colors as (N, 4) rgba array. edgecolor The edgecolor. Not normalized; may be any valid color spec or None. r3NrkrlzL'facecolor' or 'color' argument must be a valid color or sequence of colors.)r~_get_patches_for_fillget_next_colorr-r.r)r'rAr3rkrlerrs r_parse_bar_color_argszAxes._parse_bar_color_args s@ 7D)JJ{E2 JJ{D1 "+"7Y44CCE  --i8I)##  &  sA// B 8 BB alignc <tj|tj}|j |\}}|j dd} |j dd} |j dd} |j dd} |j dd} | in| j } | j dd}||jdd}||dz }| jd||j d d }|j d tjd }| jd || jd ||j d d}tjddg||j dd}|j dd}|j dd}|}|dk(r|d}n|d}|dk(r3|jd|fd|fd|fg|d|rF|jddn2|jd|fd|fd|fg|d|r|jdd|j d|}t#j$|j'|}|j)||||j&}| |j)| |||j&} |j*d|}t#j$|j-|}|j)||||j,}| |j)| |||j,} t#j.t#j0||||| | \}}}}} } |dk(r|j }|}n|j*}|}t3|t4st#j6|rd}|}n|}dgt9|z}t9|t9|k7r$t;dt9|dt9|dt=j>t#j0| } t=j>t#j0| } t=j@t=j>|t=jBd }|t=jBd}nOt=j@t=j>tEjF|t=jBd }tjd!d"g|#|d!k(r|dk(r ||d$z z }|}n ||d$z z }|}n|}|}g}tM||||||| | | }|D]\ } }!}"}#}$}}%}&}'tjN| |!f|"|#|$||%|'|&*}(|(jQ|d+|(jS_*|dk(r&|(jVjXj[|!n%|(jVj\j[| |j_|(|j[|(| | |dk(rFtM||D "cgc] \} }"| d,|"zz})} }"tM||D!#cgc] \}!}#|!|#z }*}!}#nEtM||D "cgc] \} }"| |"z })} }"tM||D!#cgc] \}!}#|!d,|#zz}*}!}#| jdd|j`|)|*f| | d d-| }+nd}+|jc|dk(r|},n|},te||+|,||.}-|jg|-|At#jh|t9|}|jk||jm||-S#tH$r,}tId%|jJd&|jJd'|d}~wwxYw#tH$r,}tId(|jJd)|jJd'|d}~wwxYwcc}"} wcc}#}!wcc}"} wcc}#}!w)/al Make a bar plot. The bars are positioned at *x* with the given *align*\ment. Their dimensions are given by *height* and *width*. The vertical baseline is *bottom* (default 0). Many parameters can take either a single value applying to all bars or a sequence of values, one for each bar. Parameters ---------- x : float or array-like The x coordinates of the bars. See also *align* for the alignment of the bars to the coordinates. Bars are often used for categorical data, i.e. string labels below the bars. You can provide a list of strings directly to *x*. ``bar(['A', 'B', 'C'], [1, 2, 3])`` is often a shorter and more convenient notation compared to ``bar(range(3), [1, 2, 3], tick_label=['A', 'B', 'C'])``. They are equivalent as long as the names are unique. The explicit *tick_label* notation draws the names in the sequence given. However, when having duplicate values in categorical *x* data, these values map to the same numerical x coordinate, and hence the corresponding bars are drawn on top of each other. height : float or array-like The height(s) of the bars. Note that if *bottom* has units (e.g. datetime), *height* should be in units that are a difference from the value of *bottom* (e.g. timedelta). width : float or array-like, default: 0.8 The width(s) of the bars. Note that if *x* has units (e.g. datetime), then *width* should be in units that are a difference (e.g. timedelta) around the *x* values. bottom : float or array-like, default: 0 The y coordinate(s) of the bottom side(s) of the bars. Note that if *bottom* has units, then the y-axis will get a Locator and Formatter appropriate for the units (e.g. dates, or categorical). align : {'center', 'edge'}, 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 ------- `.BarContainer` Container with all the bars and optionally errorbars. Other Parameters ---------------- color : :mpltype:`color` or list of :mpltype:`color`, optional The colors of the bar faces. This is an alias for *facecolor*. If both are given, *facecolor* takes precedence. facecolor : :mpltype:`color` or list of :mpltype:`color`, optional The colors of the bar faces. If both *color* and *facecolor are given, *facecolor* takes precedence. edgecolor : :mpltype:`color` or list of :mpltype:`color`, optional The colors of the bar edges. linewidth : float or array-like, optional Width of the bar edge(s). If 0, don't draw edges. tick_label : str or list of str, optional The tick labels of the bars. Default: None (Use default numeric labels.) label : str or list of str, optional A single label is attached to the resulting `.BarContainer` as a label for the whole dataset. If a list is provided, it must be the same length as *x* and labels the individual bars. Repeated labels are not de-duplicated and will cause repeated label entries, so this is best used when bars also differ in style (e.g., by passing a list to *color*.) xerr, yerr : float 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 : :mpltype:`color` or list of :mpltype:`color`, default: 'black' The line color of the errorbars. capsize : float, default: :rc:`errorbar.capsize` The length of the error bar caps in points. error_kw : dict, optional Dictionary of keyword arguments to be passed to the `~.Axes.errorbar` method. Values of *ecolor* or *capsize* defined here take precedence over the independent keyword arguments. log : bool, default: False If *True*, set the y-axis to be log scale. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs : `.Rectangle` properties %(Rectangle:kwdoc)s See Also -------- barh : Plot a horizontal bar plot. Notes ----- Stacked bars can be achieved by passing individual *bottom* values per bar. See :doc:`/gallery/lines_bars_and_markers/bar_stacked`. r#Nhatchxerryerrerror_kwrX{Gz?ecolorracapsizeerrorbar.capsizerr'rrr]Fr>rv tick_labelrr|r*rcliprT _nolegend_znumber of labels (z!) does not match number of bars (z).riredgerrzthe dtypes of parameters x (z ) and width (z) are incompatiblezthe dtypes of parameters y (z) and height ()rwidthheightrkrlr#r>rdrj)rrrK) datavaluesrr>)7r7rDrPatchrr~rrr^r4r5rrrr`r_xaxisrr,convert_xunitsryaxisconvert_yunitsbroadcast_arrays atleast_1dr~strrrr itertoolscyclechainrepeatr-r.rdtyperrr=rr sticky_edgesr*rr|rerrorbarrr add_container broadcast_to set_ticksset_ticklabels).r'r|rrr{rrArkrlr#rrrrezorderrrrr]r> tick_labelsr*ry0tick_label_axistick_label_positionbar_container_label patch_labelsrepatchesrRrrwhclwhtchlblrexeyrr bar_containers. rbarzAxes.barF sN''?#99&A 9JJ{D1  7D)zz&$'zz&$'::j$/!)2x}},,x. ?jj40G"4Hg.Hc***Y 5G(HIHf-Iw/ jj ;  J 5;Ojj& 7B'jjt4  * $yy * $  # #qC8c6]3VU $ L6:  # #qC<#q2FE $ K6: :: !B 4..q12A$$UB43F3FGE''b!T5H5HI :: !B 4..q12A%%fb!T5H5HIF''b!T5H5HI020C0C MM! feQ 51B-65!Y * $"jjO"# "jjO"# %%"++e*<".  L"' (>CF2L | A &1#l2C1DE??B1vhbJK KOOBMM)$<=  e 45OOIOOI$>$-$4$4V$<>   !((.I! 5 5i @A  (*I Hf-U; H j(@uqy=D @!^F DF4 9i,(/3  +Aq!Q1b$""q61 A   v &03AJJL -j(  ''*  ''* NN1  NN1 ! $  t/j(.1$.>?daa#'k??(+FF(;<1a!e<<),D%(891a!e99.1&&.ABdaa#'kBB    6$t}}R1$Tv1'/1HH $$& * $JJ$Wh:1<+>@  =)  "//+s7|DK  % %&9 :  * *; 7S!@#&B177)L227++?7%89>?@@!@#&B177)L339<<.A7%89>?@@B@<:BsH\)]-^^ 3^^ ] ']]  ^']>>^)rrBc \|jdd|jd||||||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). Many parameters can take either a single value applying to all bars or a sequence of values, one for each bar. Parameters ---------- y : float or array-like The y coordinates of the bars. See also *align* for the alignment of the bars to the coordinates. Bars are often used for categorical data, i.e. string labels below the bars. You can provide a list of strings directly to *y*. ``barh(['A', 'B', 'C'], [1, 2, 3])`` is often a shorter and more convenient notation compared to ``barh(range(3), [1, 2, 3], tick_label=['A', 'B', 'C'])``. They are equivalent as long as the names are unique. The explicit *tick_label* notation draws the names in the sequence given. However, when having duplicate values in categorical *y* data, these values map to the same numerical y coordinate, and hence the corresponding bars are drawn on top of each other. width : float or array-like The width(s) of the bars. Note that if *left* has units (e.g. datetime), *width* should be in units that are a difference from the value of *left* (e.g. timedelta). height : float or array-like, default: 0.8 The heights of the bars. Note that if *y* has units (e.g. datetime), then *height* should be in units that are a difference (e.g. timedelta) around the *y* values. left : float or array-like, default: 0 The x coordinates of the left side(s) of the bars. Note that if *left* has units, then the x-axis will get a Locator and Formatter appropriate for the units (e.g. dates, or categorical). align : {'center', 'edge'}, 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 ------- `.BarContainer` Container with all the bars and optionally errorbars. Other Parameters ---------------- color : :mpltype:`color` or list of :mpltype:`color`, optional The colors of the bar faces. edgecolor : :mpltype:`color` or list of :mpltype:`color`, optional The colors of the bar edges. linewidth : float or array-like, optional Width of the bar edge(s). If 0, don't draw edges. tick_label : str or list of str, optional The tick labels of the bars. Default: None (Use default numeric labels.) label : str or list of str, optional A single label is attached to the resulting `.BarContainer` as a label for the whole dataset. If a list is provided, it must be the same length as *y* and labels the individual bars. Repeated labels are not de-duplicated and will cause repeated label entries, so this is best used when bars also differ in style (e.g., by passing a list to *color*.) xerr, yerr : float 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 : :mpltype:`color` or list of :mpltype:`color`, default: 'black' The line color of the errorbars. capsize : float, default: :rc:`errorbar.capsize` The length of the error bar caps in points. error_kw : dict, optional Dictionary of keyword arguments to be passed to the `~.Axes.errorbar` method. Values of *ecolor* or *capsize* defined here take precedence over the independent keyword arguments. log : bool, default: False If ``True``, set the x-axis to be log scale. data : indexable object, optional If given, all parameters also accept a string ``s``, which is interpreted as ``data[s]`` if ``s`` is a key in ``data``. **kwargs : `.Rectangle` properties %(Rectangle:kwdoc)s See Also -------- bar : Plot a vertical bar plot. Notes ----- Stacked bars can be achieved by passing individual *left* values per bar. See :doc:`/gallery/lines_bars_and_markers/horizontal_barchart_distribution`. rr)r|rrr{rrBr\)r^r) r'r*rrrrrBrArs rbarhz Axes.barh sDH -6$((=T&a!&T=5;=rz%gr)rK label_typepaddingc dD]}||vstd|d|jj\}} || kD} |jj\} } | | kD} d}t j ddg||j }|j}|j}|j}|r'|j}|d}|d }|j}ng}|g}g}tj||||D]O\}}}}|jj\\}}\}}||zdz ||zdz }!} |d k(r,|d k\r t!||n t#||}"t%||z }#n+|d k\r t!||n t#||}"t%||z }#|t'j(|d k(r|"}$nl|d k(r4|d k\r|d d d fj!n|d d d fj#}$n3|d k\r|d d d fj!n|d d d fj#}$|dk(r |||#z}%n|"}%|dk(r d }&|fd|d<n|d k(r| |$f}&n|$|!f}&|d k(r| rdnd }'d |'||z|zf}(n| rdnd })|)||z|zd f}(|dk(rd\}*}+n4|d k(rd}*| r |d kDrdnd}+n!|d krdnd}+n| r |d kDrdnd}*n |d krdnd}*d}+t'j*|rd}|Ft-|t.rt1j2||%}nt5|r ||%}n t7d|j8||&|(fd|*|+d|},|j;|,R|S)a Label a bar plot. Adds labels to bars in the given `.BarContainer`. You may need to adjust the axis limits to fit the labels. Parameters ---------- container : `.BarContainer` Container with all the bars and optionally errorbars, likely returned from `.bar` or `.barh`. labels : array-like, optional A list of label texts, that should be displayed. If not given, the label texts will be the data values formatted with *fmt*. fmt : str or callable, default: '%g' An unnamed %-style or {}-style format string for the label or a function to call with the value as the first argument. When *fmt* is a string and can be interpreted in both formats, %-style takes precedence over {}-style. .. versionadded:: 3.7 Support for {}-style format string and callables. label_type : {'edge', 'center'}, default: 'edge' The label type. Possible values: - 'edge': label placed at the end-point of the bar segment, and the value displayed will be the position of that end-point. - 'center': label placed in the center of the bar segment, and the value displayed will be the length of that segment. (useful for stacked bars, i.e., :doc:`/gallery/lines_bars_and_markers/bar_label_demo`) padding : float, default: 0 Distance of label from the end of the bar, in points. **kwargs Any remaining keyword arguments are passed through to `.Axes.annotate`. The alignment parameters ( *horizontalalignment* / *ha*, *verticalalignment* / *va*) are not supported because the labels are automatically aligned to the bars. Returns ------- list of `.Annotation` A list of `.Annotation` instances for the labels. )r1har0vazPassing z! to bar_label() is not supported.c|dk\rdSdS)Nrrr\)r|s rsignzAxes.bar_label..signV sQ1 &B &rrr)rrrNr'r)rjrjctjj|j||j xstjj SrU)rBbox intersectionget_window_extent get_clip_boxnull)rrs rz Axes.bar_label.. sI#((55//2ANN4D5(--224rrr)rrrzr{rrrvzfmt must be a str or callablez offset points)rrr)rrget_view_intervalrrrrrrrr  get_segmentsr zip_longestget_bbox get_pointsr4r3absrrisnanr~rr7_auto_format_strcallablerrr)-r' containerrJrKrrrAkeyrr y_invertedrrh x_invertedrbarsrrrr  barlinecols barlinecolerrs annotationsrrdatrrrx1y1xcycextremalengthendptvaluer y_directionr x_directionrr annotations- r bar_labelzAxes.bar_label shL ICf} sg%FGII I zz++-1U zz++-1U  ' FH-*E  %%)) ++ NNE(K$QJ**,DD >F "+"7"7dJ# K + Cc3"%!:!:!< HRhr22g]R"WMBj(),#b"+s2r{R"W),#b"+s2r{R"W{bggcla/ *+.!8AqD QT+.!8AqD QTX%S F*X% #5z"*,UBBj($.bA K$s)3g==$.bA $tCy07:A=X%+B*,!B!&)AgU8&)AgU8!(+aWV(+aWV!Bxx}{c3'00eM*,?7=?J   z *WK +Zrc Rt|rtj|nd}t|rtj|nd}|jd|fd|fg|dg}|\}}|j |||zf\}} |D]>} | \} } |j| | | zf\} } |j| |f| | f| | f| |fg@tjtj|fi|}|j|d|j|S#t $r t ddwxYw) 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*. Parameters ---------- xranges : sequence of tuples (*xmin*, *xwidth*) The x-positions and extents of the rectangles. For each tuple (*xmin*, *xwidth*) a rectangle is drawn from *xmin* to *xmin* + *xwidth*. yrange : (*ymin*, *yheight*) The y-position and extent for all the rectangles. Returns ------- `~.collections.PolyCollection` Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs : `.PolyCollection` 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: %(PolyCollection:kwdoc)s Nr|r*Frz_each range in xrange must be a sequence with two elements (i.e. xrange must be an (N, 2) array)Tr)rr7rrr ExceptionrrrrPolyCollectionrarrayrr)r'xrangesyrangerAxdataydataverticesrrdrxrrrcrcols r broken_barhzAxes.broken_barh s[X69\((1t47K((0T 5\C< (&%  AB$$b"r']3B FB PB (("b2g7FB OOb"XBx"bB8D E F""288H#5@@ C. $$&  P EFKOP Ps DD&r')linefmt markerfmtbasefmtr{r>rc*dt|cxkrdks"ntjddt|tjddg|t|dk(r%|\}t j t|} d}n;t |dtr#|^}}t j t|} n|^} }}|dk(r|jd | fd |fg\} }n|jd |fd | fg\}} tj|}tj| } |t|d kDr|d nd }t|\} } } |d }|dk(rd}t|\} }}|d }| d} || }|tjdrdnd}t|\}}}| tjd} |dk(r |jn |j}|| ||| | d}|dk(r3|}| }||g}t j | t j"| g}n2| }|}t j | t j"| g}||g}|j%|||| |d\}|j%|||||d\}t'|||f|}|j)||S)aV Create a stem plot. A stem plot draws lines perpendicular to a baseline at each location *locs* from the baseline to *heads*, and places a marker there. For vertical stem plots (the default), the *locs* are *x* positions, and the *heads* are *y* values. For horizontal stem plots, the *locs* are *y* positions, and the *heads* are *x* values. Call signature:: stem([locs,] heads, linefmt=None, markerfmt=None, basefmt=None) The *locs*-positions are optional. *linefmt* may be provided as positional, but all other formats must be provided as keyword arguments. Parameters ---------- locs : array-like, default: (0, 1, ..., len(heads) - 1) For vertical stem plots, the x-positions of the stems. For horizontal stem plots, the y-positions of the stems. heads : array-like For vertical stem plots, the y-values of the stem heads. For horizontal stem plots, the x-values of the stem heads. linefmt : str, optional A string defining the color and/or linestyle of the vertical lines: ========= ============= 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: Markers specified through this parameter (e.g. 'x') will be silently ignored. Instead, markers should be specified using *markerfmt*. markerfmt : str, optional A string defining the color and/or shape of the markers at the stem heads. If the marker is not given, use the marker 'o', i.e. filled circles. If the color is not given, use the color from *linefmt*. basefmt : str, default: 'C3-' ('C2-' in classic mode) A format string defining the properties of the baseline. orientation : {'vertical', 'horizontal'}, default: 'vertical' The orientation of the stems. bottom : float, default: 0 The y/x-position of the baseline (depending on *orientation*). label : str, optional The label to use for the stems in legends. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER Returns ------- `.StemContainer` The container may be treated like a tuple (*markerline*, *stemlines*, *baseline*) Notes ----- .. seealso:: The MATLAB function `stem `_ which inspired this method. rstemz1-3rr'rr\r|r*rzC0-rxrv ry_internal.classic_modezC2-zC3-zlines.linestylerr)r3r$rwr>)r>)rr nargs_errorrrr}r~rrr7 _check_1dr r4r5rrr3r4rFrr)r'rrrr{r>rrRheadslocsr$ linemarker linecolor markerstyle markermarker markercolor basestyle basemarker basecolorxlines stemlinesmarker_xmarker_y baseline_x baseline_y markerliner-stem_containers rrz Axes.stem sdCI""""65#d)< < L*5;O t9>FE99SZ(DD Q %LED99SZ(D!% D%$ * $11C;e 2MNKD%11C<#t2MNKE4&t$ ?!$TQd1gEG+?+H( :y  I ?I  + / \;  L   K  #K ? # -E Fu +?+H( :y   %67I +z 9t{{ &%,H  , &HH &)J&&,t 5JHH&&,t 5J &)Jii(&1['3< I IIj*$-%/|E ' Ix'H-24 >*rexplode)r|r6rJr) normalizerc  )|jdtj|tj}|jdkDr t dtj |dkr t d|j}|r||z }n|dkDr t d|dgt|z}|dgt|z}t|t|k7rt dt|t|t|k7rt d t|||jj}ntj|))fd }tjtj|}tjt | | | dkrt d | | d z }| i} | i} g}g}g}t#|||D]\}}}|\}}| r||zn||z }dtj$zdz||zz}||t'j(|zz }||t'j*|zz }t-j.||f| dt1||zdt3||z|t5|d|} | j6d)i| |j9| |j;| |rLdddd}!t=|t>r|!jA||j;t-jB| fi|!|||| zt'j(|zz}"||| zt'j*|zz}#|"dkDrdnd}$d}%d}&|r(|#dkDrdnd}%tjD||"dkDrdndz}&|jG|"|#|d|$|%|&tHjJd}'|'j6d)i| |j9|'|||| zt'j(|zz}"||| zt'j*|zz}#t=|tLr |d|zz}(n"tO|r |d|z}(n tQd tIjR| jUd!d"rtWjXd#d$|(}(|jG|"|#|(ddd%}'|'j6d)i| |j9|'|}|r|j[n2|j7dggd&|dzd'|dzfd&|dzd'|dzf(|||fS|||fS)*a Plot a pie chart. Make a pie chart of array *x*. The fractional area of each wedge is given by ``x/sum(x)``. The wedges are plotted counterclockwise, by default starting from the x-axis. Parameters ---------- x : 1D array-like The wedge sizes. explode : array-like, 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, default: None A sequence of strings providing the labels for each wedge colors : :mpltype:`color` or list of :mpltype:`color`, default: None A sequence of colors through which the pie chart will cycle. If *None*, will use the colors in the currently active cycle. hatch : str or list, default: None Hatching pattern applied to all pie wedges or sequence of patterns through which the chart will cycle. For a list of valid patterns, see :doc:`/gallery/shapes_and_collections/hatch_style_reference`. .. versionadded:: 3.7 autopct : None or str or callable, default: None If not *None*, *autopct* is a string or function used to label the wedges with their numeric value. The label will be placed inside the wedge. If *autopct* is a format string, the label will be ``fmt % pct``. If *autopct* is a function, then it will be called. pctdistance : float, default: 0.6 The relative distance along the radius at which the text generated by *autopct* is drawn. To draw the text outside the pie, set *pctdistance* > 1. This parameter is ignored if *autopct* is ``None``. labeldistance : float or None, default: 1.1 The relative distance along the radius at which the labels are drawn. To draw the labels inside the pie, set *labeldistance* < 1. If set to ``None``, labels are not drawn but are still stored for use in `.legend`. shadow : bool or dict, default: False If bool, whether to draw a shadow beneath the pie. If dict, draw a shadow passing the properties in the dict to `.Shadow`. .. versionadded:: 3.8 *shadow* can be a dict. startangle : float, default: 0 degrees The angle by which the start of the pie is rotated, counterclockwise from the x-axis. radius : float, default: 1 The radius of the pie. counterclock : bool, default: True Specify fractions direction, clockwise or counterclockwise. wedgeprops : dict, default: None Dict of arguments passed to each `.patches.Wedge` of the pie. For example, ``wedgeprops = {'linewidth': 3}`` sets the width of the wedge border lines equal to 3. By default, ``clip_on=False``. When there is a conflict between these properties and other keywords, properties passed to *wedgeprops* take precedence. textprops : dict, default: None Dict of arguments to pass to the text objects. center : (float, float), default: (0, 0) The coordinates of the center of the chart. frame : bool, default: False Plot Axes frame with the chart if true. rotatelabels : bool, default: False Rotate each label to the angle of the corresponding slice if true. normalize : bool, default: True When *True*, always make a full pie by normalizing x so that ``sum(x) == 1``. *False* makes a partial pie if ``sum(x) <= 1`` and raises a `ValueError` for ``sum(x) > 1``. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER Returns ------- patches : list A sequence of `matplotlib.patches.Wedge` instances texts : list A list of the label `.Text` instances. autotexts : list A list of `.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`. equalrz x must be 1Drz+Wedge sizes 'x' must be non negative valuesz/Cannot plot an unnormalized pie with sum(x) > 1rvz$'labels' must be of length 'x', not z%'explode' must be of length 'x', not ctSrU)next) color_cyclesrrz Axes.pie..get_next_color8 sK((r)radius startanglez('radius' must be a positive number, not ihrrjgv@F)rkrrr>g{Gzr)oxoyr>rrrrr{rzzxtick.labelsize)rr1r0rotationrgY@z+autopct must be callable or a format stringusetexz text.usetexz([^\\])%z\1\\%)rr1r0gg?)frame_onxticksyticksxlimylimr\). set_aspectrr,float32ndimrr(sumrrrrrrrcheck_isinstancerrpimathcossinrWedger3r4r;setrrr~dictr<Shadowrad2degrr4r5rrr _val_or_rcrresubr)*r'r|r6rJrautopct pctdistanceshadow labeldistancer>r= counterclock wedgeprops textpropsrframe rotatelabelsr7rsxr hatch_cycletheta1textsslices autotextsfracr>explr*theta2thetamr shadow_dictxtytlabel_alignment_hlabel_alignment_vlabel_rotationrrr<s* @rpiezAxes.pie sp   JJq"** % 66A:^, , 66!a%=JK K UUW BA !VNO O >TCF]F ?cCFlG q6S[ CCK=QR R q6S\ !DS\NST T >!77FFN#//&1K ) oobmmE&:;  d6jI Q;GxPQ Qc!  J  I !$Q!8@  D%DAq(4ftm6D=FY_8F (( (A (( (A1vvtc&&6I/I#c&&&99)7)9%)+%6',%* ,A AEE J  MM!  NN1 &+%,O fd+&&v.xq@K@A(/$((62BBB/$((62BBB.01fF'!$,!!-46F%&(jj&8.01f#'?NIIb"e&+2C0A'5#&<<0A#B D " " Q"v-0@@@v-0@@@gs+4$;/Ag&t ,A#EGG>>)--"9=I{Ha8AIIb"a&+2:08:" "  #FA@ D   ( ( * HHeBr 6!9,dVAY.>? 6!9,dVAY.>?  A ?5= 5)+ +rc2t|trd|f}t|trWt|dk(r:t|dtr't|dtrt |dd|d}n[t d|dt|trn;t|t stj|r ||nt d|dtjt|t}d ||<|S#t tf$r}t d|d|d}~wwxYw) z Normalize `errorbar`'s *errorevery* to be a boolean mask for data *x*. This function is split out to be usable both by 2D and 3D errorbars. rrrNz errorevery=z! is a not a tuple of two integerszE is iterable but not a valid NumPy fancy index to match 'xerr'/'yerr'z is not a recognized valueT) r~rtuplerslicerrrrrzerosbool)r| erroreveryr everymasks r_errorevery_to_maskzAxes._errorevery_to_mask s j( +ZJ j% (J1$z!}h7z!}h7":a=$ 1 F  "zo%FGII  E * J,Z1H =*  .HIJ JHHSVT* $ * + = "zo&3349<= =s3C22DDDr)r|r*rrc tj|tj}|j Dcic] \}}| || }}}|j ddt |tjstj|t}t |tjstj|t}d}|"t |tjs||}|"t |tjs||}tj||\}}t|t|k7r td|j||}|jdd}d|d<|j j#||d k(r||fn|||f|d \\}}| r|j%|dd z n|j%|dd z|j'd k7r|j)|n+d}|jdd|vr|jd|d<d|vrd|d<||d}dD]}|j|di|d|i}|||d<n d|vr|d|d<dD]}||vs||||<i|dd i}|t*j,d}|dkDrd|z|d<|||d<dD]}||vs||||<||d<g}ggd}d}d||| | ||j.dtj0tj2f d||| | ||j4d tj6tj8f fD]\ }}} } } }!}"}#}$}%| tj:| t|j=t>} tj:| t|j=t>} tj:| dt|f| jBtjBtur'tjD| dk(rtd!|d&tjD| | | k(x}&|& krtd!|d'|tjFd(| z d(| z g| zz\}'}(|jI|"||!|'|(g|i||jJd)k(r(|dk(r#|D]})|)jMD] }*d|*_'  | | z}+|+jEre|dkDr`||!|'|(g|+|z\},}-}.|-|.fD]F}/tj|,|,fd*|#i|}0|0jPd/i|d+|/i||jI|0HtS| |(f| |'fgD]\}1\}2}3|2jEs|jT|jW|1z r|%n|$}4||||3g|2|z\}5}6}7tj|5|6fd*|4i|}0|0jPd/i|d+|7i||jI|0|dkDs||jItj|5|6fd*|#i||jJd)k(r|jX}8|D]}9||9D]}:t[|:j]|:j_D]\};}|j)tj|;g|i|n"|D]}9||9D]}:|j)|:|jo|d|dz}tq|ts|ts|f|du|du|.}?|ju|?|?Scc}}w#t$r@td!|d"tj@| d#|d$tj@|d% dwxYw)0a 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 as the errorbars. Use fmt='none' to draw errorbars without any data markers. .. versionadded:: 3.7 Caps and error lines are drawn in polar coordinates on polar plots. Parameters ---------- x, y : float or array-like The data positions. xerr, yerr : float 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. All values must be >= 0. See :doc:`/gallery/statistics/errorbar_features` for an example on the usage of ``xerr`` and ``yerr``. fmt : str, 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 : :mpltype:`color`, default: None The color of the errorbar lines. If None, use the color of the line connecting the markers. elinewidth : float, default: None The linewidth of the errorbar lines. If None, the linewidth of the current style is used. capsize : float, default: :rc:`errorbar.capsize` The length of the error bar caps in points. capthick : float, 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, default: False If True, will plot the errorbars above the plot symbols. Default is below. lolims, uplims, xlolims, xuplims : bool or array-like, default: False 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 scalars, or array-likes of the same length as *xerr* and *yerr*. To use limits with inverted axes, `~.Axes.set_xlim` or `~.Axes.set_ylim` must be called before :meth:`errorbar`. Note the tricky parameter names: setting e.g. *lolims* to True means that the y-value is a *lower* limit of the True value, so, only an *upward*-pointing arrow will be drawn! errorevery : int or (int, int), default: 1 draws error bars on a subset of the data. *errorevery* =N draws error bars on the points (x[::N], y[::N]). *errorevery* =(start, N) draws error bars on the points (x[start::N], y[start::N]). e.g. errorevery=(6, 3) adds error bars to the data at (x[6], x[9], x[12], x[15], ...). Used to avoid overlapping error bars when two series share x-axis values. Returns ------- `.ErrorbarContainer` The container contains: - data_line : A `~matplotlib.lines.Line2D` instance of x, y plot markers and/or line. - caplines : A tuple of `~matplotlib.lines.Line2D` instances of the error bar caps. - barlinecols : A tuple of `.LineCollection` with the horizontal and vertical error ranges. Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs All other keyword arguments are passed on to the `~.Axes.plot` call drawing 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: - *dashes* - *dash_capstyle* - *dash_joinstyle* - *drawstyle* - *fillstyle* - *linestyle* - *marker* - *markeredgecolor* - *markeredgewidth* - *markerfacecolor* - *markerfacecoloralt* - *markersize* - *markevery* - *solid_capstyle* - *solid_joinstyle* Refer to the corresponding `.Line2D` property for more details: %(Line2D:kwdoc)s NrXrrc~tj|rt|dkDrtt j |tj rStt j |}|tj urtj|tS||Stj|tS)a% Safely handle tuple of containers that carry units. This function covers the case where the input to the xerr/yerr is a length 2 tuple of equal length ndarray-subclasses that carry the unit information in the container. If we have a tuple of nested numpy array (subclasses), we defer coercing the units to be consistent to the underlying unit library (and implicitly the broadcasting). Otherwise, fallback to casting to an object array. rr}) rrrr~r7rrrr,object)ratypes r _upcast_errz"Axes.errorbar.._upcast_errSs"KK$HqL u77rrvT) return_kwargs皙?rir3C0)rw markersizemarkerfacecolormarkerfacecoloraltmarkeredgewidthmarkeredgecolor markeveryr$ fillstyler dash_capstyledash_joinstylesolid_capstylesolid_joinstyledashesr#)rWrmrX rasterizedr$rr@rr)rrWrmrXrr)r|r*c2|Dcgc]}|| c}Scc}wrUr\)arraysmaskrs r apply_maskz!Axes.errorbar..apply_masks-34EE$K4 44s r||r*_'z err' (shape: zE) must be a scalar or a 1D or (2, n) array-like whose shape matches 'z ' (shape: )z@err' must not contain None. Use NaN if you want to skip a value.z%err' must not contain negative valuesrpolarrwrB)theta trans_shift)rwrW)has_xerrhas_yerrr>r\);r7rDrrr^r^r~rrr,rrrrr{r~rE _plot_args set_zorderr%rr4r5rCARETRIGHTBASE CARETLEFTBASEr CARETUPBASE CARETDOWNBASErastyperxshaperr(vstackrr get_pathsrrS enumerate _axis_map get_inverted transShiftr get_xdata get_ydatarrAffine2DrotaterNmmarkers MarkerStylerrrur)@r'r|r*rrrKr elinewidthr barsabovelolimsuplimsxlolimsxuplimsrycapthickrArarbrrzr> data_line base_stylereb_lines_style eb_cap_stylebarcolscaplinesrdep_axisdeprindep lines_funcrwlomarkerhimarkerchecklowhighrrnolims indep_masked lo_masked hi_masked lh_maskedridxlimshlhlmarkerx_maskedy_masked hl_maskedrrrrrrBmserrorbar_containers@ rrz Axes.errorbar sZ'' >#)<<>C41aQ]!Q$CC(A&!RZZ( 1F+A!RZZ( 1F+A% 1N  JtRZZ$@t$D  JtRZZ$@t$D}}Q"1 q6SV BC C,,Q ;  7D)&w $(??#=#= C2I1a&Aq#;d$>$T J   !1B!6 7  !1B!6 7 99;& MM) $I NN7 #& &,jj&9 7# * $"&Jw  >(F &C NN3 %  &9J88  !*4N; ' F "*0*=N; 'A 2Cf}&,Sks# 2 ;*:k6: ?ll#56G Q;)+gL &  .6L* +, 0Cf}$*3K S! 0+1 &'"% 5 awDKKf++V-A-ACavvq$++f((&*>*>@- G L )XsC Xx {__VSX6==dCF__VSX6==dCF HaS]3 yyBHHV,,t 1D z";;<<vvC3J/uE69: z!FGII bii1v:F (CDsJJIC NN:UC. :N>LN OyyG#C 3A[[]312.33'Fzz|! 5?C&(:6<2 i"+Y!74I"==|H06H:FHDDHH>8*D 19=>X&--d34$-vtnvsm-L#M LZdBxxz~~h/<<>D!1;2Jy 012-(I}}XxF,4F8DF:xj-y9:"))$/Q;X&--fmm (/K39/K=I/KL LoG LP 99 //K E!$ EA$' q{{}$EEq#2K#X3;$ (<(<(>(E(Ebeeai(PPH%11 zBHHSM?!=>DHH Hs ^^/!^A _notchrJrc|tjd}| tjd} tj||| ||}|tjd}| tjd} | tjd} |tjd}|tjd}|tjd }|tjd }|i}|i}|i}|i}|i}|i}| rd |d <d |vr|j d |d<|=|dk(rt ddd}d}n't |\}} }!| | |d<|!|!|d <|!|d<|!|d<| uttj| t|k7s$tj| dt|k7r tdt|| D] \}"}#|# |#|"d<| mt| t|k7r tdt|| D]<\}"}$|$ t|$dk7r td|$d|$d|"d<|$d5|$d|"d<>|j||||| ||||||||| ||||||||}%|%S) a& Draw a box and whisker plot. The box extends from the first quartile (Q1) to the third quartile (Q3) of the data, with a line at the median. The whiskers extend from the box to the farthest data point lying within 1.5x the inter-quartile range (IQR) from the box. Flier points are those past the end of the whiskers. See https://en.wikipedia.org/wiki/Box_plot for reference. .. code-block:: none Q1-1.5IQR Q1 median Q3 Q3+1.5IQR |-----:-----| o |--------| : |--------| o o |-----:-----| flier <-----------> fliers IQR Parameters ---------- x : Array or a sequence of vectors. The input data. If a 2D array, a boxplot is drawn for each column in *x*. If a sequence of 1D arrays, a boxplot is drawn for each array in *x*. notch : bool, default: :rc:`boxplot.notch` Whether to draw a notched boxplot (`True`), or a rectangular boxplot (`False`). The notches represent the confidence interval (CI) around the median. The documentation for *bootstrap* describes how the locations of the notches are computed by default, but their locations may also be overridden by setting the *conf_intervals* parameter. .. 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. An empty string ('') hides the fliers. If `None`, then the fliers default to 'b+'. More control is provided by the *flierprops* parameter. vert : bool, optional .. deprecated:: 3.11 Use *orientation* instead. This is a pending deprecation for 3.10, with full deprecation in 3.11 and removal in 3.13. If this is given during the deprecation period, it overrides the *orientation* parameter. If True, plots the boxes vertically. If False, plots the boxes horizontally. orientation : {'vertical', 'horizontal'}, default: 'vertical' If 'horizontal', plots the boxes horizontally. Otherwise, plots the boxes vertically. .. versionadded:: 3.10 whis : float or (float, float), default: 1.5 The position of the whiskers. If a float, the lower whisker is at the lowest datum above ``Q1 - whis*(Q3-Q1)``, and the upper whisker at the highest datum below ``Q3 + whis*(Q3-Q1)``, where Q1 and Q3 are the first and third quartiles. The default value of ``whis = 1.5`` corresponds to Tukey's original definition of boxplots. If a pair of floats, they indicate the percentiles at which to draw the whiskers (e.g., (5, 95)). In particular, setting this to (0, 100) results in whiskers covering the whole range of the data. In the edge case where ``Q1 == Q3``, *whis* is automatically set to (0, 100) (cover the whole range of the data) if *autorange* is True. Beyond the whiskers, data are considered outliers and are plotted as individual points. 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 : 1D array-like, optional A 1D array-like of length ``len(x)``. Each entry that is not `None` forces the value of the median for the corresponding dataset. For entries that are `None`, the medians are computed by Matplotlib as normal. conf_intervals : array-like, optional A 2D array-like of shape ``(len(x), 2)``. Each entry that is not None forces the location of the corresponding notch (which is only drawn if *notch* is `True`). For entries that are `None`, the notches are computed by the method specified by the other parameters (e.g., *bootstrap*). positions : array-like, optional 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 : float or array-like The widths of the boxes. The default is 0.5, or ``0.15*(distance between extreme positions)``, if that is smaller. patch_artist : bool, default: :rc:`boxplot.patchartist` If `False` produces boxes with the Line2D artist. Otherwise, boxes are drawn with Patch artists. tick_labels : list of str, optional The tick labels of each boxplot. Ticks are always placed at the box *positions*. If *tick_labels* is given, the ticks are labelled accordingly. Otherwise, they keep their numeric values. .. versionchanged:: 3.9 Renamed from *labels*, which is deprecated since 3.9 and will be removed in 3.11. manage_ticks : bool, default: True If True, the tick locations and labels will be adjusted to match the boxplot positions. autorange : bool, default: False When `True` and the data are distributed such that the 25th and 75th percentiles are equal, *whis* is set to (0, 100) such that the whisker ends are at the minimum and maximum of the data. meanline : bool, default: :rc:`boxplot.meanline` 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 : float, default: ``Line2D.zorder = 2`` The zorder of the boxplot. Returns ------- dict A dictionary mapping each component of the boxplot to a list of the `.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. Other Parameters ---------------- showcaps : bool, default: :rc:`boxplot.showcaps` Show the caps on the ends of whiskers. showbox : bool, default: :rc:`boxplot.showbox` Show the central box. showfliers : bool, default: :rc:`boxplot.showfliers` Show the outliers beyond the caps. showmeans : bool, default: :rc:`boxplot.showmeans` Show the arithmetic means. capprops : dict, default: None The style of the caps. capwidths : float or array, default: None The widths of the caps. boxprops : dict, default: None The style of the box. whiskerprops : dict, default: None The style of the whiskers. flierprops : dict, default: None The style of the fliers. medianprops : dict, default: None The style of the median. meanprops : dict, default: None The style of the mean. label : str or list of str, optional Legend labels. Use a single string when all boxes have the same style and you only want a single legend entry for them. Use a list of strings to label all boxes individually. To be distinguishable, the boxes should be styled individually, which is currently only possible by modifying the returned artists, see e.g. :doc:`/gallery/statistics/boxplot_demo`. In the case of a single string, the legend entry will technically be associated with the first box only. By default, the legend will show the median line (``result["medians"]``); if *patch_artist* is True, the legend will show the box `.Patch` artists (``result["boxes"]``) instead. .. versionadded:: 3.9 data : indexable object, optional DATA_PARAMETER_PLACEHOLDER See Also -------- .Axes.bxp : Draw a boxplot from pre-computed statistics. violinplot : Draw an estimate of the probability density function. zboxplot.whiskerszboxplot.bootstrap)whis bootstraprJ autorangez boxplot.notchzboxplot.patchartistzboxplot.meanlinezboxplot.showmeanszboxplot.showcapszboxplot.showboxzboxplot.showflierssolidr$r3rlrvri)r$rwr3Frwrrrz,'usermedians' and 'x' have different lengthsmedz/'conf_intervals' and 'x' have different lengthsrz-each confidence interval must have two valuescilorcihi)rwidthsvert patch_artist shownotches showmeansshowcapsshowboxboxprops flierprops medianprops meanpropsmeanline showflierscapprops whiskerprops manage_ticksrX capwidthsr>r)r4r5r7 boxplot_statsr~rTr rrrrrrbxp)&r'r|rsymrrrrrrr usermediansconf_intervalsrrrrrrrrrrrrrrrXrr>bxpstatsrrwr3statsrciartistss& rboxplotz Axes.boxplot8sZ <<< 23D   %89I&&qty.9YP =LL1E  <<(=>L  ||$67H   %89I  ||$67H ?ll#45G  &:;J  H  L  H  K  I  J $+H[ !("(0 W(=% ?by!F2VL " $8#< 65%+1Jx($+0Jw'49J0149J01  "BHH[)*c(m;HH[)!,H = BDD#&h "<+JE3'*e +  %>"c(m3 EGG"%X~!> 6IE2~r7a<",.?#@@ "!u0021f !!u0021f  6((8y $<', $,g$,'2i$,$,<(4V%.e'2 4rrc pLddd|xsi}ddd|xsi}g}g}g}g}g}g}g}tjjd}dBfd }|rtjdtjd tjd tjd rd ntjd dt j | tjn |d| d} |d| d}!|d|d}"|d|}#|d||d}$|d||}%|rdnd}&||&|vrd|%|&<|tjd}ntjdddd|durd}tjdd g|!tjdstjd"dd#$|d k(r tdn tddd%LLfd&}'Lfd'}(t|})d(}*|ttd)|)d)z}n(t||)k7rt!|*j#d*t%j&|}t|dkDrt)d+|Ds t+d,|2t%j,d-t%j.|zd-d.g|)z}nDt%j0|r|g|)z}n(t||)k7rt!|*j#d/|d.t%j&|z}nDt%j0|r|g|)z}n(t||)k7rt!|*j#d0t3||||D]\}+},}-}.|j5|-j7d1|+|+|+g}/|-d2|-d3g}0|-d4|-d5g}1|+|.d.zz }2|+|.d.zz}3|2|3g}4t%j8d6|-d3}5t%j8d6|-d5}6|+|,d.zz }7|+|,d.zz}8|-d7|-d7g}9|rP|+|,d8zz }:|+|,d8zz};|7|8|8|;|8|8|7|7|:|7|7g }<|-d2|-d2|-d9|-d7|-d:|-d4|-d4|-d:|-d7|-d9|-d2g }=|:|;g}>n!|7|8|8|7|7g}<|-d2|-d2|-d4|-d4|-d2g}=|7|8g}>| r1|r|(n|'}?|j5|?|<|=fi| |$j;d1d;|!j;d1d;|j5|'|/|0fi|!|j5|'|/|1fi|!| rD|"j;d1d;|j5|'|4|5fi|"|j5|'|4|6fi|"|j5|'|>|9fi|$|rD|r$|j5|'|7|8g|-d|-dgfi|%n|j5|'|+g|-dgfi|%| s5|#j;d1d;t%j8t|-d<|+t$j<=}@|-d<}A|j5|'|@|Afi|#|r| r|r|n|}Bt j>|rBdjA|nVtBt|k7rt!|*j#d1t3B|D]\}C}D|CjA|D|r|d k(rd>nd?}EtCjDd@|E}FjF|E}G|GjI|}tK|FdtK|d.z tM|Fd)tM|d.zf|Fddt3||D]2\}H}ItC|HjNEjQ|Id.z |Id.zg4GjS}JtU|GjStVjXs&tWjXg}JGj[|Jt%j&gJj\||J_.Gj_}KtU|Gj_tVj`s&tWj`g}KGjc|KgKjd||K_2jgti||||||AS)Ca Draw a box and whisker plot from pre-computed statistics. The box extends from the first quartile *q1* to the third quartile *q3* of the data, with a line at the median (*med*). The whiskers extend from *whislow* to *whishi*. Flier points are markers past the end of the whiskers. See https://en.wikipedia.org/wiki/Box_plot for reference. .. code-block:: none whislow q1 med q3 whishi |-----:-----| o |--------| : |--------| o o |-----:-----| flier fliers .. note:: This is a low-level drawing function for when you already have the statistical parameters. If you want a boxplot based on a dataset, use `~.Axes.boxplot` instead. Parameters ---------- bxpstats : list of dicts A list of dictionaries containing stats for each boxplot. Required keys are: - ``med``: Median (float). - ``q1``, ``q3``: First & third quartiles (float). - ``whislo``, ``whishi``: Lower & upper whisker positions (float). Optional keys are: - ``mean``: Mean (float). Needed if ``showmeans=True``. - ``fliers``: Data beyond the whiskers (array-like). Needed if ``showfliers=True``. - ``cilo``, ``cihi``: Lower & upper confidence intervals about the median. Needed if ``shownotches=True``. - ``label``: Name of the dataset (str). If available, this will be used a tick label for the boxplot positions : array-like, default: [1, 2, ..., n] The positions of the boxes. The ticks and limits are automatically set to match the positions. widths : float or array-like, default: None The widths of the boxes. The default is ``clip(0.15*(distance between extreme positions), 0.15, 0.5)``. capwidths : float or array-like, default: None Either a scalar or a vector and sets the width of each cap. The default is ``0.5*(width of the box)``, see *widths*. vert : bool, optional .. deprecated:: 3.11 Use *orientation* instead. This is a pending deprecation for 3.10, with full deprecation in 3.11 and removal in 3.13. If this is given during the deprecation period, it overrides the *orientation* parameter. If True, plots the boxes vertically. If False, plots the boxes horizontally. orientation : {'vertical', 'horizontal'}, default: 'vertical' If 'horizontal', plots the boxes horizontally. Otherwise, plots the boxes vertically. .. versionadded:: 3.10 patch_artist : bool, default: False If `False` produces boxes with the `.Line2D` artist. If `True` produces boxes with the `~matplotlib.patches.Patch` artist. shownotches, showmeans, showcaps, showbox, showfliers : bool Whether to draw the CI notches, the mean value (both default to False), the caps, the box, and the fliers (all three default to True). boxprops, whiskerprops, capprops, flierprops, medianprops, meanprops : dict, optional Artist properties for the boxes, whiskers, caps, fliers, medians, and 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_ticks : bool, default: True If True, the tick locations and labels will be adjusted to match the boxplot positions. label : str or list of str, optional Legend labels. Use a single string when all boxes have the same style and you only want a single legend entry for them. Use a list of strings to label all boxes individually. To be distinguishable, the boxes should be styled individually, which is currently only possible by modifying the returned artists, see e.g. :doc:`/gallery/statistics/boxplot_demo`. In the case of a single string, the legend entry will technically be associated with the first box only. By default, the legend will show the median line (``result["medians"]``); if *patch_artist* is True, the legend will show the box `.Patch` artists (``result["boxes"]``) instead. .. versionadded:: 3.9 zorder : float, default: ``Line2D.zorder = 2`` The zorder of the resulting boxplot. Returns ------- dict A dictionary mapping each component of the boxplot to a list of the `.Line2D` instances created. That dictionary has the following keys (assuming vertical boxplots): - ``boxes``: main bodies of the boxplot showing the quartiles, and the median's confidence intervals if enabled. - ``medians``: horizontal lines at the median of each box. - ``whiskers``: vertical lines up to the last non-outlier data. - ``caps``: horizontal lines at the ends of the whiskers. - ``fliers``: points representing data beyond the whiskers (fliers). - ``means``: points or lines representing the means. See Also -------- boxplot : Draw a boxplot from data instead of pre-computed statistics. butt)rrNrrTc HtjjDcic]/\}}|jd|dr|j dd|1}}}|z|d<|sd|d<|j t j|tj|Scc}}w)Nzboxplot.props.rrXrvrw) r4r5r^ startswithsplitr<r7rDrr)subkeyexplicitzdelta usemarkerrarbrhrXs r merge_kw_rczAxes.bxp..merge_kw_rc>s141C1C1E<ALL8F85!9:b!1$.do_plotss'499r2hz2=f=a@ @rctjjtj||g}t j |fi|}j||SrU)mpathPath_create_closedr column_stackr PathPatchrt)rrrApathrrr's rdo_patchzAxes.bxp..do_patchvsR::,,R 457D&&t6v6E OOE "LrzEList of boxplot statistics and `{0}` values must have same the lengthrrc3<K|]}t|tywrU)r~r)r rs rr"zAxes.bxp..s)Q!*Q*=)Qsz*positions should be an iterable of numbersg333333?rjrrr>q1whisloq3whishirr?rrrfliersr}r|r*interval)whiskerscapsboxesmediansr*means)rT)5rrrXr4r5r7rDrr!rwarn_deprecatedrrvrr1rangerformatrrallrrptpisscalarrrrrtr^float64is_scalar_or_stringrgetattrrr convert_unitsr3r4rextendget_major_locatorr~mticker FixedLocatorset_major_locatorr%get_major_formatterFixedFormatterset_major_formatterseqrrT)Mr'rrrrrrrrrrrrrrrrrrrrXrr>r,r-r.r/r0r* datalabelsrrbox_kw whisker_kwcap_kwflier_kw median_kwmean_kw removed_proprr#Ndatashape_messageposrrcapwidthwhis_xwhislo_ywhishi_ycap_left cap_rightcap_xcap_locap_hibox_left box_rightmed_y notch_left notch_rightbox_xbox_ymed_xdo_boxflier_xflier_y box_or_medartistr axis_namer+rr r!locator formatterrsM` ` @rrzAxes.bxps\%#  b %# B   >]]))F "&BC&BC&>?%(\\2J%K'"||,=>  $$Xx/A/AB  +5(eL !LEJ UH>w 3+vO fi8#+x   I =$&GL ! <<< 23D  !E   5=&K L*5;O||./  ')  %0:$=U4[5tUWCX  A  M@  U1a!e_-I ^q .55kBC CHHY' y>A c)Qy)Q&QHI I >ggdRVVI%66cBCaGF [[ X\F [A .55h?@ @  bhhv..I [[ #" aI ^q .55kBC C+.y&(/8,:D E 'Cx   eii5 63ZFd U8_5Hd U8_5HX^+Hhn,Iy)EWWQh0FWWQh0FUS[(Heck)I5\5<0E 54</ !EDL0 !9i"Ix:!8-teDk5=uuV}eDkteFmU5\vd 5$[1"9i8LteDk5;d t&!9-%1w VE5;F;<$$Wl;  ! !'< 8 OOGFHC C D OOGFHC C D!!'<8 GE6LL!9-f uV}/M"!" LL#v!K7!KL##G\:''#eHo"62::N/ ggwC(CDID EN ")lJ((/1 ''.z?c%j0$%6%=%=g%FGG#&z5#9*KFC$$S)* *j8cIt||x {-CDH>>),D**95Ix{C NR,?@x{C NR,?@BHQK$'$; 4 ++Y7>>]HrM24 4,,.Gd446%224!..r2&&w/88$?gll$?Y$?@GL002Id668%446#2226 ((39imm9j9IM  ( ( *XD#F%A Arc*|jdd}|jd|}|jd|}|jdd}| | td| tj|||}||}|&tj dstj d }||t jd |du}| ||ntj drd n|}t|txsJtj|xr3t|d kDxr#ttj|t} d } d} d} |s|| s tj|t }|j"dk(s|j"dk(rd} |j$|k7rKd} nH|j$|k(r|j'}d} n&|j"dvrt jdd} | s8 tj|} t| d d|fvr| t| |d} || |fS#t$r}td|d}~wwxYw#t$rYiwxYw#t(tf$r8}dt|vr| s| |j$||td||d}~wwxYw)a  Helper function to process color related arguments of `.Axes.scatter`. Argument precedence for facecolors: - c (if not None) - kwargs['facecolor'] - kwargs['facecolors'] - kwargs['color'] (==kwcolor) - 'b' if in classic mode else the result of ``get_next_color_func()`` Argument precedence for edgecolors: - kwargs['edgecolor'] - edgecolors (is an explicit kw argument in scatter()) - kwargs['color'] (==kwcolor) - 'face' if not in classic mode else None Parameters ---------- c : :mpltype:`color` or array-like or list of :mpltype:`color` or None See argument description of `.Axes.scatter`. edgecolors : :mpltype:`color` or sequence of color or {'face', 'none'} or None See argument description of `.Axes.scatter`. kwargs : dict Additional kwargs. If these keys exist, we pop and process them: 'facecolors', 'facecolor', 'edgecolor', 'color' Note: The dict is modified by this function. xsize : int The size of the x and y arrays passed to `.Axes.scatter`. get_next_color_func : callable A callable that returns a color. This color is used as facecolor if no other color is provided. Note, that this is a function rather than a fixed color value to support conditional evaluation of the next color. As of the current implementation obtaining the next color from the property cycle advances the cycle. This must only happen if we actually use the color, which will only be decided within this method. Returns ------- c The input *c* if it was not *None*, else a color derived from the other inputs or defaults. colors : array(N, 4) or None The facecolors as RGBA values, or *None* if a colormap is used. edgecolors The edgecolor. facecolorsNrkrlr3zeSupply a 'c' argument or a 'color' kwarg but not both; they differ but their functionalities overlap.z'color' kwarg must be a color or sequence of color specs. For a sequence of values to be color-mapped, use the 'c' argument instead.r!zscatter.edgecolorszYou passed both c and facecolor/facecolors for the markers. c has precedence over facecolor/facecolors. This behavior may change in the future.rrc&td|d|dS)Nz'c' argument has z< elements, which is inconsistent with 'x' and 'y' with size r)r)csizexsizes rinvalid_shape_exceptionz?Axes._parse_scatter_color_args..invalid_shape_exceptionts'#E7+..3WA78 8rFTr})r)rr))r)rna<*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 the *color* keyword-argument or provide a 2D array with a single row if you intend to specify the same RGB or RGBA value for all points.rz&RGBA values should be within 0-1 rangezR'c' argument must be a color, a sequence of colors, or a sequence of numbers, not )r~rr-r.r4r5r warn_externalr~rrrrr7rr)r:rrrr)r edgecolorsrArlget_next_color_funcrikwcolorr c_was_nonec_is_string_or_stringsrm c_is_mapped valid_shapers r_parse_scatter_color_argszAxes._parse_scatter_color_argssnZZ d3 ZZ Z8 ZZ Z8 **Wd+  1=?@ @   :%%g. !$ !$  cll3K&L&:;J =Z3   :  $Y 9)5 \\*BCc)+  q#  B AA3q6A:Au77:C@   8   go6L (MM!51 77f$6(9"'Kvv&+ VVu_ A"&Kww,.**IJ#(K F ..q1v;q!Um32#f+uEEF&*$$o : 017:: :R  8z* I;s3xG&5affeD#M%99:?@EHI IsBH H<!I  H9( H44H9< II J3J  Jrw) r|r*rrrprrkrir3)rp colorizer plotnonfinitec  | |jd| i| |jd| itj|tj}|j dd} |j dd} |j d|fd|fg|\}}tjj|}tjj|}|j|jk7r td|+tjd rd ntjd d z}tjj|}t|d |jfvs\tj|j tj"s9tj|j tj$s td| }| |j'dd}|j)|| ||j|j*j,\}}} |rA|?tjj/|}tj0|||| | \}}}} } n#tj0|||||| | \}}}}}} } |jdvrJtjj3| r+tjj3|s | j4} |}|tjd}t7|t8j:r|}nt9j:|}|j=j?|jA}|jCs|tEjFd|d|d|jIdk(r|} d}nd} | tjd} n9tjJ| r$| Dcgc]}||ntjd} }tjjM||g}tjN|f||| | ||j d|jP| }|jStUjV|`| r|jY| |||| n"|j[||j]||j_||ja||| nh|||| d}|jcDcgc] \}}| | }}}te|r1djgd|D}tEjFd|d|ji|tjd r^|jjdkr |jd kDr|jmd|jndkr |jd kDr|jqd|js||ju|Scc}wcc}}w)!a A scatter plot of *y* vs. *x* with varying marker size and/or color. Parameters ---------- x, y : float or array-like, shape (n, ) The data positions. s : float or array-like, shape (n, ), optional The marker size in points**2 (typographic points are 1/72 in.). Default is ``rcParams['lines.markersize'] ** 2``. The linewidth and edgecolor can visually interact with the marker size, and can lead to artifacts if the marker size is smaller than the linewidth. If the linewidth is greater than 0 and the edgecolor is anything but *'none'*, then the effective size of the marker will be increased by half the linewidth because the stroke will be centered on the edge of the shape. To eliminate the marker edge either set *linewidth=0* or *edgecolor='none'*. c : array-like or list of :mpltype:`color` or :mpltype:`color`, optional The marker colors. Possible values: - A scalar or sequence of n numbers to be mapped to colors using *cmap* and *norm*. - A 2D array in which the rows are RGB or RGBA. - A sequence of colors of length n. - A single color format string. 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 2D array with a single row. Otherwise, value-matching will have precedence in case of a size matching with *x* and *y*. If you wish to specify a single color for all points prefer the *color* keyword argument. 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 : `~.markers.MarkerStyle`, default: :rc:`scatter.marker` The marker style. *marker* can be either an instance of the class or the text shorthand for a particular marker. See :mod:`matplotlib.markers` for more information about marker styles. %(cmap_doc)s This parameter is ignored if *c* is RGB(A). %(norm_doc)s This parameter is ignored if *c* is RGB(A). %(vmin_vmax_doc)s This parameter is ignored if *c* is RGB(A). alpha : float, default: None The alpha blending value, between 0 (transparent) and 1 (opaque). linewidths : float or array-like, default: :rc:`lines.linewidth` The linewidth of the marker edges. Note: The default *edgecolors* is 'face'. You may want to change this as well. edgecolors : {'face', 'none', *None*} or :mpltype:`color` or list of :mpltype:`color`, default: :rc:`scatter.edgecolors` 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 color or sequence of colors. For non-filled markers, *edgecolors* is ignored. Instead, the color is determined like with 'face', i.e. from *c*, *colors*, or *facecolors*. %(colorizer_doc)s This parameter is ignored if *c* is RGB(A). plotnonfinite : bool, default: False Whether to plot points with nonfinite *c* (i.e. ``inf``, ``-inf`` or ``nan``). If ``True`` the points are drawn with the *bad* colormap color (see `.Colormap.set_bad`). Returns ------- `~matplotlib.collections.PathCollection` Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs : `~matplotlib.collections.PathCollection` properties %(PathCollection:kwdoc)s 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 1D arrays; *x*, *y*, *s*, and *c* may be input as N-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*. Nrprr#rlr|r*zx and y must be the same sizer!zlines.markersizerrzEs must be a scalar, or float array-like with the same size as x and y)rq)rrnzscatter.markerz#You passed a edgecolor/edgecolors (z) for an unfilled marker (zl). Matplotlib is ignoring the edgecolor in favor of the facecolor. This behavior may change in the future.rifacezlines.linewidthrW)rirproffsetsoffset_transformrmcmapnormvminvmaxz, c3(K|] }d|d yw)rNr\)r ras rr"zAxes.scatter..s$B!q1X$Bsz6No data for colormapping provided via 'c'. Parameters z will be ignored皙?r);r<r7rDr Collectionr~rrrrrrr4r5r issubdtyperfloatingintegerrrwrrmasked_invalidr is_maskedrBr~rrr transformedr is_filledrro get_fillstylerr PathCollectionrqrrr_set_colorizer_check_keywordsset_cmapset_norm set_array _scale_normr^r(joinr=_xmargin set_xmargin_ymargin set_ymarginrr)r'r|r*rrrwrrrrrmrrprxryrAorig_edgecolorrscales marker_objr"rr} collection extra_kwargsrarb extra_keyskeys_strs rscatterz Axes.scattersWR  ! MM<4 5  ! MM<4 5''0@0@AZZ T2 ZZ T2 &&a3(';VD1 EEKKN EEKKN 66QVV <= = 9||$<=01S8  EEKKN F1aff+ %]]177BKK8]]177BJJ7DE E $  #ZZ T:N  * *:vqvv$($>$>$M$M + O 6: V^$$Q'A$$Q1j*E ,Aq!Z$$q!Q J@ 7Aq!Q J FFf EEOOJ/7#J >\\"23F fh22 3J!--f5J""$00  $ $ &(##%)""9.9KL//5j999"'')V3#  $ ! \\*;< Z()*.Bcll;L.MM* *%%$$aV,)) GV!!#ZZ T^^D    !>!>!@A >88>B>B9D##D)##D)   #  " "4t 4!$dL)5(:(:(<N1 !NJN:99$Bz$BB""""*+;=> ##F+ <<0 1}}t#   &}}t#   & J' $$&i*<Os5W WWgridsize)r|r*Crrr|c $|jd|fd|fg|dtj|||\}}}tj|r|\}}n#|}t |t jdz }tj|t}tj|t}|}|}|dk(r8tj|dkr tdtj|}|dk(r8tj|dkr td tj|}|'|\}}}}||kDr td ||kDrtd t|r |j|jfnd \}}t|r |j|jfnd \}}t!j"||d\}}t!j"||d\}}|dz}|dz}|}|} ||z|| zz}!d||z z}"||"z}||"z }||z |z }#||z |z }$||z |#z }%||z |$z }&tj$|%j't }'tj$|&j't }(tj(|%j't })tj(|&j't }*tj*d|'k|'|kzd|(kz|(|kz|'|z|(zdzd}+tj*d|)k|)|kzd|*kz|*| kz|)| z|*zdzd},|%|'z dzd|&|(z dzzz}-|%|)z dz dzd|&|*z dz dzzz}.|-|.k}/|tj,|+|/d||zzdd }0tj,|,|/d|| zzdd }1tj.|0|1gj't}2|tj0|2|2|k<tj2t|}nt5d||zzD3cgc]}3g}4}3t5d|| zzD3cgc]}3g}5}3t5t|D]<}6|/|6r|4|+|6j7||6#|5|,|6j7||6>|d}tj8|4|5fD78cgc]2}7|7dd D](}8t|8|k\r||8ntj0*4c}8}7t}2tj:|2}9tj<|!dft}:tj>tj@|||:d ||zdf<tjBtj@|||:d ||zdf<tj>tj@|dz| |:||zd df<tjBtj@| |dz|:||zd df<|:d d dfxx|#zcc<|:d d dfxx|$zcc<|:d d dfxx|z cc<|:d d dfxx|z cc<|:|9d d f}:|2|9}2|#|$dz gtj8ddgddgddgddgddgddggz};|tDjFdg}|dk(s|dk(rtjH|;d}<|dk(r4d||dz}|>|?|>z tj@|z|z z}tj`|}|jc|2}2|r|=je|| | | | n"|=jg| |=ji| |=jk|2|=jm| |=jo||=jq| | | | F|=jrjt0|=jrjv|=jrjy||f||ff}@|j{|@|j}d !|j|=d"|s|=Sg}Ad|||||fd||||d|zffD]\}B}C}D}E}F}G|Fdk(rtjDEGdz}HntjDEGdz}HtjGd#df}IHd d$x|Id d ddf<|Id d ddf<|Hdd x|Id d ddf<|Id d ddf<dx|Id d ddf<|Id d ddf<d%x|Id d ddf<|Id d ddf<Bdk(rId d d d d d d$f}ItjbHCdz }JtjG}Kt5|GD]3}6|J|6k(}Lt|LdkDr|Lntj0K|6<5tj:K}MI|M}I|K|M}Kt|d&Bd'd()}NtOjP|I|Nd*+}O|Ojk|K|Ojg| |Oji| |Ojm| |Ojo|Aj7|j|Od"A\|=_D|=_Ed,}P|=jjd-|P|=Scc}3wcc}3wcc}8}7w).aP Make a 2D hexagonal binning plot of points *x*, *y*. If *C* is *None*, the value of the hexagon is determined by the number of points in the hexagon. Otherwise, *C* specifies values at the coordinate (x[i], y[i]). For each hexagon, these values are reduced using *reduce_C_function*. Parameters ---------- x, y : array-like The data positions. *x* and *y* must be of the same length. C : array-like, optional If given, these values are accumulated in the bins. Otherwise, every point has a value of 1. Must be of the same length as *x* and *y*. gridsize : int or (int, int), default: 100 If a single int, the number of hexagons in the *x*-direction. The number of hexagons in the *y*-direction is chosen such that the hexagons are approximately regular. Alternatively, if a tuple (*nx*, *ny*), the number of hexagons in the *x*-direction and the *y*-direction. In the *y*-direction, counting is done along vertically aligned hexagons, not along the zig-zag chains of hexagons; see the following illustration. .. plot:: import numpy import matplotlib.pyplot as plt np.random.seed(19680801) n= 300 x = np.random.standard_normal(n) y = np.random.standard_normal(n) fig, ax = plt.subplots(figsize=(4, 4)) h = ax.hexbin(x, y, gridsize=(5, 3)) hx, hy = h.get_offsets().T ax.plot(hx[24::3], hy[24::3], 'ro-') ax.plot(hx[-3:], hy[-3:], 'ro-') ax.set_title('gridsize=(5, 3)') ax.axis('off') To get approximately regular hexagons, choose :math:`n_x = \sqrt{3}\,n_y`. bins : 'log' or int or sequence, default: None Discretization of the hexagon values. - 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 colormap. Internally, :math:`log_{10}(i+1)` is used to determine the hexagon color. This is equivalent to ``norm=LogNorm()``. - 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'}, default: 'linear' Use a linear or log10 scale on the horizontal axis. yscale : {'linear', 'log'}, default: 'linear' Use a linear or log10 scale on the vertical axis. mincnt : int >= 0, default: *None* If not *None*, only display cells with at least *mincnt* number of points in the cell. marginals : bool, default: *False* If marginals is *True*, plot the marginal density as colormapped rectangles along the bottom of the x-axis and left of the y-axis. extent : 4-tuple of float, default: *None* The limits of the bins (xmin, xmax, ymin, ymax). 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). Returns ------- `~matplotlib.collections.PolyCollection` A `.PolyCollection` defining the hexagonal bins. - `.PolyCollection.get_offsets` contains a Mx2 array containing the x, y positions of the M hexagon centers in data coordinates. - `.PolyCollection.get_array` contains the values of the M hexagons. If *marginals* is *True*, horizontal bar and vertical bar (both PolyCollections) will be attached to the return collection as attributes *hbar* and *vbar*. Other Parameters ---------------- %(cmap_doc)s %(norm_doc)s %(vmin_vmax_doc)s alpha : float between 0 and 1, optional The alpha blending value, between 0 (transparent) and 1 (opaque). linewidths : float, default: *None* If *None*, defaults to :rc:`patch.linewidth`. edgecolors : {'face', 'none', *None*} or color, default: 'face' The color of the hexagon edges. Possible values are: - 'face': Draw the edges in the same color as the fill color. - 'none': No edges are drawn. This can sometimes lead to unsightly unpainted pixels between the hexagons. - *None*: Draw outlines in the default color. - An explicit color. reduce_C_function : callable, default: `numpy.mean` The function to aggregate *C* within the bins. It is ignored if *C* is not given. This must have the signature:: def reduce_C_function(C: array) -> float Commonly used functions are: - `numpy.mean`: average of the points - `numpy.sum`: integral of the point values - `numpy.amax`: value taken from the largest point By default will only reduce cells with at least 1 point because some reduction functions (such as `numpy.amax`) will error/warn with empty input. Changing *mincnt* will adjust the cutoff, and if set to 0 will pass empty input to the reduction function. %(colorizer_doc)s data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs : `~matplotlib.collections.PolyCollection` properties All other keyword arguments are passed on to `.PolyCollection`: %(PolyCollection:kwdoc)s See Also -------- hist2d : 2D histogram rectangular bins r|r*Frrr]z7x contains non-positive values, so cannot be log-scaledz7y contains non-positive values, so cannot be log-scaledNz)In extent, xmax must be greater than xminz)In extent, ymax must be greater than yminrrr)expanderrg& .>rrg@rj) minlengthr,gzpatch.linewidth$@)rprr}r~zGOnly one of 'bins' and 'norm' arguments can be supplied, ignoring bins=rrrTtightrrnrrget_axis_transformrrr|)rWrpcL|jj|j|jj|j|jj |j |jj |j yrU)hbarrget_cmapvbarset_climget_clim)rs r on_changedzAxes.hexbin..on_changed[sn OO $ $Z%8%8%: ; OO $ $Z%8%8%: ; OO $ $Z%8%8%: ; OO $ $Z%8%8%: ;rchanged)Hrr7delete_masked_pointsrrintrOr{r,r:r(rlog10rr3r4r nonsingularroundrfloorrbincount concatenatenanonesr2rrrrwrr}r/r4r5 expand_dimsr_r`rrAffineDeltaTransformrq _str_equalrror-LogNormsort searchsortedrrrr set_alphar=rrrr autoscalerrr geomspacelinspacerr9rr callbacksconnect)Qr'r|r*rrbinsxscaleyscaleextentrrrrrmrrpreduce_C_functionmincnt marginalsrxrAnxnytxtyrrrrnx1ny1nx2ny2nrrcsyrrix1iy1ix2iy2i1i2d1d2bdistcounts1counts2accumrCs_at_i1Cs_at_i2iCs_at_iacc good_idxsr}polygonpolygonsrminimummaximumrrznamezzminzmaxzscalenbins bin_edgesvertsbin_idxsvaluesrrrrrsQ rhexbinz Axes.hexbins J #qC8 4feL,,Q151a ;;x FBBR$))A,&'B JJq%  JJq%   U?vva3h MOO"B U?vva3h MOO"B  %+ "D$dd{ !LMMd{ !LMM14Q"&&(BFFH-VJD$14Q"&&(BFFH-VJD$%00tcJJD$$00tcJJD$1f1f #Ic !4$;'  TkR TkR 4i2 4i2 hhrl!!#&hhrl!!#&hhrl!!#&hhrl!!#& XXqCxC#I.!s(;sSyICi#o)1. XXqCxC#I.!s(;sSyICi#o)1.3h1_sb3h1_4 43hn "SBHsNq+@%@ @b 9kk"U)q39}EabIGkk"eV*C#I FqrJGNNGW#56==eDE!(*efn%AA%*!cCi-$89q9H9$)!cCi-$89q9H93q6] 18RUO**1Q40RUO**1Q40  1 ~HH!)8 4)#ABK),/s8v+="3'266I)I) E XXe_$ ((Aq65)!#299S>3!? s A !#3!= s A !#299S>C+?!Ec A !#3!=!Cc A 1  1  1  1  )Q,'i rAv,#YR2r(S"ISzB9 M"OO  ,,'89:J U?fo~~gq1H$(HQ1W,=$=Aq!t|t|'$(HQ1W,=$=Aq!t|t|'yH)) !!(==dnnM     D% (""$F@Dw$HIDt<""tD  ;;t$#&u:s5z 'G"3ryy!F!MM774=D%%e,E   4 4YT:>T:> 5 @    %    %U#U###F+tT40  ##+ 0D0D0L))+$<$. G$ $$4$0 J6 atVR0atVQV44 ' A /E1dD&% LLtUQY? KKdEAI> HHeQ]+E.7n ?fME&&6;C MM& ! LL  LL  MM%   ( KK++C+? @O' AR,0(  < $$Y ;y:9)s* n n7n c |j|}|j|}|j|}|j|}tj||||fi|}|j ||j |S)a [*Discouraged*] Add an arrow to the Axes. This draws an arrow from ``(x, y)`` to ``(x+dx, y+dy)``. .. admonition:: Discouraged The use of this method is discouraged because it is not guaranteed that the arrow renders reasonably. For example, the resulting arrow is affected by the Axes aspect ratio and limits, which may distort the arrow. Consider using `~.Axes.annotate` without a text instead, e.g. :: ax.annotate("", xytext=(0, 0), xy=(0.5, 0.5), arrowprops=dict(arrowstyle="->")) Parameters ---------- %(FancyArrow)s Returns ------- `.FancyArrow` The created `.FancyArrow` object. )rrr FancyArrowrr)r'r|r*rcrdrArs rarrowz Axes.arrowes|<    "    "   $   $   1b" 7 7 q $$&rc \tj|||||fi|}|j||SrU)mquiver QuiverKeyrt)r'QXYUr>rAqks r quiverkeyzAxes.quiverkeys0   q!Q5 ;F ;  rc|t|dkDr-|dd\}}|jd|fd|fg|\}}||f|ddzS|S)Nrrrr|r*)rr)r'rRrAr|r*s r _quiver_unitszAxes._quiver_unitssY t9q=!9DAq**S!HsAh+?HDAqq6DH$ $ rc|j||}tj|g|i|}|j|d|j |S)z%(quiver_doc)sTr)r rQuiverrr)r'rRrAqs rquiverz Axes.quiversR !!$/ NN4 1$ 1& 1 At, $$&rc|j||}tj|g|i|}|j|d|j |S)z %(barbs_doc)sTr)r rBarbsrr)r'rRrArs rbarbsz Axes.barbssR !!$/ MM$ 0 0 0 At, $$&r)rBctj|tj}g|j|g|d|i|}|D]}|j ||j |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 data : indexable object, optional An object with labelled data. If given, provide the label names to plot in *x* and *y*, e.g.:: ax.fill("time", "signal", data={"time": [0, 1, 2], "signal": [0, 1, 0]}) Returns ------- list of `~matplotlib.patches.Polygon` Other Parameters ---------------- **kwargs : `~matplotlib.patches.Polygon` properties Notes ----- Use :meth:`fill_between` if you would like to fill the region between two curves. rB)r7rDrrrrr)r'rBrRrArpolys rfillz Axes.fillsnX'' >Q.D..tPdPPPQ !D NN4  ! $$&rr interpolaterc tjj|} tjdsUt j tjtfddDs|jjd<|j|| |||fi\}}}tj||||f|||d} |j| |j| S)a Fill the area between two {dir} curves. The curves are defined by the points (*{ind}*, *{dep}1*) and (*{ind}*, *{dep}2*). This creates one or multiple polygons describing the filled area. You may exclude some {dir} 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 *{ind}*. Parameters ---------- {ind} : array-like The {ind} coordinates of the nodes defining the curves. {dep}1 : array-like or float The {dep} coordinates of the nodes defining the first curve. {dep}2 : array-like or float, default: 0 The {dep} coordinates of the nodes defining the second curve. where : array-like of bool, optional Define *where* to exclude some {dir} regions from being filled. The filled regions are defined by the coordinates ``{ind}[where]``. More precisely, fill between ``{ind}[i]`` and ``{ind}[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, default: False This option is only relevant if *where* is used and the two curves are crossing each other. Semantically, *where* is often used for *{dep}1* > *{dep}2* or similar. By default, the nodes of the polygon defining the filled region will only be placed at the positions in the *{ind}* array. Such a polygon cannot describe the above semantics close to the intersection. The {ind}-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 *{ind}*. The value determines where the step will occur: - 'pre': The {dep} value is continued constantly to the left from every *{ind}* position, i.e. the interval ``({ind}[i-1], {ind}[i]]`` has the value ``{dep}[i]``. - 'post': The y value is continued constantly to the right from every *{ind}* position, i.e. the interval ``[{ind}[i], {ind}[i+1])`` has the value ``{dep}[i]``. - 'mid': Steps occur half-way between the *{ind}* positions. Returns ------- `.FillBetweenPolyCollection` A `.FillBetweenPolyCollection` containing the plotted polygons. Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs All other keyword arguments are passed on to `.FillBetweenPolyCollection`. They control the `.Polygon` properties: %(FillBetweenPolyCollection:kwdoc)s See Also -------- fill_between : Fill between two sets of y-values. fill_betweenx : Fill between two sets of x-values. r!c3&K|]}|v ywrUr\)r rrAs rr"z,Axes._fill_between_x_or_y..EsCqqF{Cs)r3rkrkr)rFillBetweenPolyCollection _f_dir_from_tr4r5r7rDrr(rr_fill_between_process_unitsrr) r'ind_dirinddep1dep2rrrrAdep_dirrs ` r_fill_between_x_or_yzAxes._fill_between_x_or_ysp11??H||45++FE4D4DEFC,BCC&*&@&@&O&O&Q{#:$:: Wc49179T444 S$G[tG?EG  J' $$&rc |ttjj|j ||f||f||fg|S)z"Handle united data, such as dates.)maprrrr)r'rr#r r!r"rAs rrz Axes._fill_between_process_unitsSsC255'')@)@s^gt_wo >*HI Irc 6|jd|||f|||d|S)Nr|rr$)r'r|ry2rrrrAs r fill_betweenzAxes.fill_betweenX8(t(( BG[tG?EG Gr)dirr r)r|rr)rc 6|jd|||f|||d|S)Nr*rr()r'r*rx2rrrrAs r fill_betweenxzAxes.fill_betweenxfr+r)r*rr.rg@) aspect interpolationrmrrrxoriginrinterpolation_stage filternorm filterradresampleurlc  ttj|f||| || | | ||| d |}|L|jr)|jj |j rt jd}||j||j||j||j|j|j|j| |||j||||j!||j#|j%|j'||S)a% Display data as an image, i.e., on a 2D regular raster. The input may either be actual RGB(A) data, or 2D scalar data, which will be rendered as a pseudocolor image. For displaying a grayscale image, set up the colormapping using the parameters ``cmap='gray', vmin=0, vmax=255``. The number of pixels used to render an image is set by the Axes size and the figure *dpi*. This can lead to aliasing artifacts when the image is resampled, because the displayed image size will usually not match the size of *X* (see :doc:`/gallery/images_contours_and_fields/image_antialiasing`). The resampling can be controlled via the *interpolation* parameter and/or :rc:`image.interpolation`. Parameters ---------- X : array-like or PIL image The image data. Supported array shapes are: - (M, N): an image with scalar data. The values are mapped to colors using normalization and a colormap. See parameters *norm*, *cmap*, *vmin*, *vmax*. - (M, N, 3): an image with RGB values (0-1 float or 0-255 int). - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), i.e. including transparency. The first two dimensions (M, N) define the rows and columns of the image. Out-of-range RGB(A) values are clipped. %(cmap_doc)s This parameter is ignored if *X* is RGB(A). %(norm_doc)s This parameter is ignored if *X* is RGB(A). %(vmin_vmax_doc)s This parameter is ignored if *X* is RGB(A). %(colorizer_doc)s This parameter is ignored if *X* is RGB(A). aspect : {'equal', 'auto'} or float or None, default: None The aspect ratio of the Axes. This parameter is particularly relevant for images since it determines whether data pixels are 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. Normally, None (the default) means to use :rc:`image.aspect`. However, if the image uses a transform that does not contain the axes data transform, then None means to not modify the axes aspect at all (in that case, directly call `.Axes.set_aspect` if desired). interpolation : str, default: :rc:`image.interpolation` The interpolation method used. Supported values are 'none', 'auto', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'blackman'. The data *X* is resampled to the pixel size of the image on the figure canvas, using the interpolation method to either up- or downsample the data. If *interpolation* is 'none', then for the ps, pdf, and svg backends no down- or upsampling occurs, and the image data is passed to the backend as a native image. Note that different ps, pdf, and svg viewers may display these raw pixels differently. On other backends, 'none' is the same as 'nearest'. If *interpolation* is the default 'auto', then 'nearest' interpolation is used if the image is upsampled by more than a factor of three (i.e. the number of display pixels is at least three times the size of the data array). If the upsampling rate is smaller than 3, or the image is downsampled, then 'hanning' interpolation is used to act as an anti-aliasing filter, unless the image happens to be upsampled by exactly a factor of two or one. See :doc:`/gallery/images_contours_and_fields/interpolation_methods` for an overview of the supported interpolation methods, and :doc:`/gallery/images_contours_and_fields/image_antialiasing` for a discussion of image antialiasing. 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*. interpolation_stage : {'auto', 'data', 'rgba'}, default: 'auto' Supported values: - 'data': Interpolation is carried out on the data provided by the user This is useful if interpolating between pixels during upsampling. - 'rgba': The interpolation is carried out in RGBA-space after the color-mapping has been applied. This is useful if downsampling and combining pixels visually. - 'auto': Select a suitable interpolation stage automatically. This uses 'rgba' when downsampling, or upsampling at a rate less than 3, and 'data' when upsampling at a higher rate. See :doc:`/gallery/images_contours_and_fields/image_antialiasing` for a discussion of image antialiasing. alpha : float or array-like, optional The alpha blending value, between 0 (transparent) and 1 (opaque). If *alpha* is an array, the alpha blending values are applied pixel by pixel, and *alpha* must have the same shape as *X*. origin : {'upper', 'lower'}, default: :rc:`image.origin` Place the [0, 0] index of the array in the upper left or lower left corner of the Axes. The convention (the default) 'upper' is typically used for matrices and images. Note that the vertical axis points upward for 'lower' but downward for 'upper'. See the :ref:`imshow_extent` tutorial for examples and a more detailed description. extent : floats (left, right, bottom, top), optional The bounding box in data coordinates that the image will fill. These values may be unitful and match the units of the Axes. 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 :ref:`imshow_extent` tutorial for examples and a more detailed description. filternorm : bool, 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, 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, default: :rc:`image.resample` 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 ------- `~matplotlib.image.AxesImage` Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **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. ) rrrxr1r2rr4r5r6r3z image.aspectr)mimage AxesImageis_transform_setrcontains_branchrqr4r5rIset_datarrrr_check_exclusionary_keywordsrset_url set_extent get_extent add_image)r'rrrr0r1rmrrrxr2rr3r4r5r6r7rAims rimshowz Axes.imshowvst  d(DI,9&%+ (1H2E ( !' ( >##%((*::4>>J\\.1F   OOF # A U    %   TZZ ( '' 4'H tT4( 3 bmmo& r rr2shadingc \gd} tj||t |dk(rt j |d}|jdd \}}|d vrAt jt j|t j|\} } n!t jt j|dzt j|dz\} } d }nt |d k(rt j |d }|dd \} } |jd | fd| fg|\} } d| | fD\} } dk(rIt jj| st jj| r td|jdd \}}n!tjdt || jd} | jd} | jd k7s| jddk(r%| jd| } | j!| d} | jd k7s| jddk(r%| j| d}|j!| d} | j| jk7rt#ddd|dk(r|| k(r|| k(rd}nd }|d k(r1| | f|dz|dzfk7rt#d|jd| d| dd | | f||fk7rt#d|j| | fz|dk(r^d#fd }|| k(r|| d !} || } || k(r:|| j$j$} || j$d !j$} d }t'j(|d "}| | ||fS#t$r"tjd|d|dd}YwxYw)$N)gouraudnearestflatr2rEzshading value 'z' not in list of valid values z. Setting shading='auto'.r2rrr)rHrIrJrr|r*c3JK|]}tj|dyw)TrN)r7safe_masked_invalid)r rs rr"z#Axes._pcolorargs..s LE--ad;;Ls!# pcolormeshzsx and y arguments to pcolormesh cannot have non-finite values or be of type numpy.ma.MaskedArray with masked values1 or 3)takesgivenrrzIncompatible X, Y inputs to z ; see help(rrIzDimensions of C z should be one smaller than X(z) and Y(z&) while using shading='flat' see help(zKDimensions of C %s are incompatible with X (%d) and/or Y (%d); see help(%s)cLtj|ddkDrtj|ddz}|rLtj|dk\s4tj|dkst j dddtj j|rtj jntj}||dddgf|dddgfz |ddddf|z|dddgf|dddgfzf}|Stj||f}|S) NrrRrjrzThe input coordinates to z are interpreted as cell centers, but are not monotonically increasing or decreasing. This may lead to incorrectly calculated cell edges, in which case, please supply explicit cell edges to rr) rrdiffr4rrorisMAhstack)rrequire_monotonicitydXrVfuncnames r _interp_gridz&Axes._pcolorargs.._interp_grids xx{1~)WWQQ/#50%'VVB!G_rQw ..";H:F: ;C1 !FG24ABII"Aa!fI1qc6 $:$%a"fIN$%a"gJAtG$<$>?HIIq!f-HrT)rWrL)F)rrrrorrr)rmeshgridr}rrrr"rKreshaperrTr7rM)r'rYrFrRrA_valid_shadingrnrowsncolsrrrNyr|r*rZs ` r _pcolorargszAxes._pcolorargsns@    ~w ? t9> d1g&A772A;LE500{{299U#3RYYu5EF1{{299UQY#75199MN1  Y!^ d1g&A8DAq**S!HsAh+?HDAqLaVLDAq<'55??1%);$BCC772A;LE5""883t9M M WWR[ WWQZ 66Q;!''!*/ !R A!$A 66Q;!''!*/ "a A!$A 77agg :8*E((0z45 5 f {u{#  f BxEAIuqy11"2177)<::<XbTJ--5Ja!9:: BxE5>)!F$%GGRXI?!?@@)#6B;$QTBA$QAB;$QSS)++A$QSStDFFA   % %ad 3!QK     ://=.>?1 1 2G  sN'N+*N+)rFrmrrrrrxc (|tjd}|j}|jdg||| d\} } } }d} d| vr| j d| d<| j d| d| vr| j d| d <| j d d }d | vr| j d | d <d | vrt j|d rd | d <| j dd tjj| stjj| rytjj}tjj| } tjj| } | j}| j}ntj}| }| }|| | gd}tj|f| ||||d| }|j!||||j#||||j$}t'|t(j*s't-|dr|j/|j0}|rt3|j5|j6r^||j6z }tj8||gj:j=t>}|jA|}|d}|d}|jC|d tjD|}tjF|}tjD|}tjF|}||g|jHjJdd||g|jHjLdd||f||ff}|jO||jQ|S)u 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. The arguments *X*, *Y*, *C* are positional-only. .. hint:: ``pcolor()`` can be very slow for large arrays. In most cases you should use the similar but much faster `~.Axes.pcolormesh` instead. See :ref:`Differences between pcolor() and pcolormesh() ` for a discussion of the differences. Parameters ---------- C : 2D array-like The color-mapped values. Color-mapping is controlled by *cmap*, *norm*, *vmin*, and *vmax*. X, Y : array-like, optional The coordinates of the corners of quadrilaterals of a pcolormesh:: (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1]) ●╶───╴● │ │ ●╶───╴● (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 ` section below. If ``shading='flat'`` the dimensions of *X* and *Y* should be one greater than those of *C*, and the quadrilateral is colored due to the value at ``C[i, j]``. If *X*, *Y* and *C* have equal dimensions, a warning will be raised and the last row and column of *C* will be ignored. If ``shading='nearest'``, the dimensions of *X* and *Y* should be the same as those of *C* (if not, a ValueError will be raised). The color ``C[i, j]`` will be centered on ``(X[i, j], Y[i, j])``. If *X* and/or *Y* are 1-D arrays or column vectors they will be expanded as needed into the appropriate 2D arrays, making a rectangular grid. shading : {'flat', 'nearest', 'auto'}, default: :rc:`pcolor.shading` The fill style for the quadrilateral. 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]``. The dimensions of *X* and *Y* should be one greater than those of *C*; if they are the same as *C*, then a deprecation warning is raised, and the last row and column of *C* are dropped. - 'nearest': Each grid point will have a color centered on it, extending halfway between the adjacent grid centers. The dimensions of *X* and *Y* must be the same as *C*. - 'auto': Choose 'flat' if dimensions of *X* and *Y* are one larger than *C*. Choose 'nearest' if dimensions are the same. See :doc:`/gallery/images_contours_and_fields/pcolormesh_grids` for more description. %(cmap_doc)s %(norm_doc)s %(vmin_vmax_doc)s %(colorizer_doc)s 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. - A color or sequence of colors will set the edge color. The singular form *edgecolor* works as an alias. alpha : float, 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, default: False Whether to snap the mesh to pixel boundaries. Returns ------- `matplotlib.collections.PolyQuadMesh` Other Parameters ---------------- antialiaseds : bool, 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`. Stroking the edges may be preferred if *alpha* is 1, but will cause artifacts otherwise. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Additionally, the following arguments are allowed. They are passed along to the `~matplotlib.collections.PolyQuadMesh` constructor: %(PolyCollection:kwdoc)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*. Npcolor.shadingpcolorrFrA)r)r#rrlrpri antialiaseds antialiasedFsnaprrR)rrrrxrmr_as_mpl_transformrrr))r4r5r%rbr~r^r7r8rr isMaskedArraystackr, compressedr PolyQuadMeshr>r _transformr~r Transformr+rjaxesr(r rqrr]rr:rWrr3r4rr|r*rr)r'rFrmrrrrrxrRrArrrrecrlr|r*coordsrr trans_to_dataptstransformed_ptsrrrrrs rrez Axes.pcolors6n ?ll#34G--/+4++H;t;W39;1a & #)::k#:F< , 3 & #)::k#:F<   |V 4 V #$*JJ~$>F= !  &5+A+A"f+M$)F= !&%( 55  q !RUU%8%8%;EEKKE a A a A A AHHEAA1vB''' #$TY#!#  // 4/PtT40  ! !1k334./##DII.A Q11$..AB.M))QF#%%,,U3C+55c:O'A'A J6vvayvvayvvayvvay(,d| !!!$(,d| !!!$,t , G$ $$&r)rmrrrrrxrFrhc D|tjd}|j}| jdd|jdg| || d\} } } }t j | | gd}| jd tjd tj|f||| ||||d | }|j||| |j||||jdd }|j}t|tjs't!|dr|j#|j$}|rDt'|j)|j*r ||j*z }|j-|}|j/|dt j0|d\}}t j2|d\}}||g|j4j6dd||g|j4j8dd||f||ff}|j;||j=|S)u Create a pseudocolor plot with a non-regular rectangular grid. Call signature:: pcolormesh([X, Y,] C, /, **kwargs) *X* and *Y* can be used to specify the corners of the quadrilaterals. The arguments *X*, *Y*, *C* are positional-only. .. hint:: `~.Axes.pcolormesh` is similar to `~.Axes.pcolor`. It is much faster and preferred in most cases. For a detailed discussion on the differences see :ref:`Differences between pcolor() and pcolormesh() `. Parameters ---------- C : array-like The mesh data. Supported array shapes are: - (M, N) or M*N: a mesh with scalar data. The values are mapped to colors using normalization and a colormap. See parameters *norm*, *cmap*, *vmin*, *vmax*. - (M, N, 3): an image with RGB values (0-1 float or 0-255 int). - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), i.e. including transparency. The first two dimensions (M, N) define the rows and columns of the mesh data. X, Y : array-like, optional The coordinates of the corners of quadrilaterals of a pcolormesh:: (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1]) ●╶───╴● │ │ ●╶───╴● (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 ` section below. If ``shading='flat'`` the dimensions of *X* and *Y* should be one greater than those of *C*, and the quadrilateral is colored due to the value at ``C[i, j]``. If *X*, *Y* and *C* have equal dimensions, a warning will be raised and the last row and column of *C* will be ignored. If ``shading='nearest'`` or ``'gouraud'``, the dimensions of *X* and *Y* should be the same as those of *C* (if not, a ValueError will be raised). For ``'nearest'`` the color ``C[i, j]`` is centered on ``(X[i, j], Y[i, j])``. For ``'gouraud'``, a smooth interpolation is carried out between the quadrilateral corners. If *X* and/or *Y* are 1-D arrays or column vectors they will be expanded as needed into the appropriate 2D arrays, making a rectangular grid. %(cmap_doc)s %(norm_doc)s %(vmin_vmax_doc)s %(colorizer_doc)s 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. - A color or sequence of colors will set the edge color. The singular form *edgecolor* works as an alias. alpha : float, default: None The alpha blending value, between 0 (transparent) and 1 (opaque). shading : {'flat', 'nearest', 'gouraud', 'auto'}, optional The fill style for the quadrilateral; defaults to :rc:`pcolor.shading`. 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]``. The dimensions of *X* and *Y* should be one greater than those of *C*; if they are the same as *C*, then a deprecation warning is raised, and the last row and column of *C* are dropped. - 'nearest': Each grid point will have a color centered on it, extending halfway between the adjacent grid centers. The dimensions of *X* and *Y* must be the same as *C*. - '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. The dimensions of *X* and *Y* must be the same as *C*. When Gouraud shading is used, *edgecolors* is ignored. - 'auto': Choose 'flat' if dimensions of *X* and *Y* are one larger than *C*. Choose 'nearest' if dimensions are the same. See :doc:`/gallery/images_contours_and_fields/pcolormesh_grids` for more description. snap : bool, default: False Whether to snap the mesh to pixel boundaries. rasterized : bool, optional Rasterize the pcolormesh when drawing vector graphics. This can speed up rendering and produce smaller files for large data sets. See also :doc:`/gallery/misc/rasterization_demo`. Returns ------- `matplotlib.collections.QuadMesh` Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Additionally, the following arguments are allowed. They are passed along to the `~matplotlib.collections.QuadMesh` constructor: %(QuadMesh:kwdoc)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() `. 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 2D array using quadrilaterals. The main difference lies in the created object and internal data handling: While `~.Axes.pcolor` returns a `.PolyQuadMesh`, `~.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 PolyQuadMesh. `~.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 PolyQuadMesh. Because PolyQuadMesh draws each individual polygon, it also supports applying hatches and linestyles to the collection. Another difference is the support of Gouraud shading in `~.Axes.pcolormesh`, which is not available with `~.Axes.pcolor`. NrdrprirNrfrrRrizpcolormesh.snap)rhrFrrrrxrmrrrjFrr)r4r5r%r^rbrrlrQuadMeshr>rr\ror~rrpr+rjrqr(r rqrWrr3r4rr|r*rr)r'rmrrrrrxrFrhrRrArrrrsrrrtrrrrrs rrNzAxes.pcolormeshs~ ?ll#34G--/,/+4++LL4L4;FL1a1a&r*&#,,/@"AB^^ W +W$TYeWOUW  // 4/PtT40A&  ! !1k334./##DII.A Q11$..AB.M",,V4F J6VVF+ dVVF+ d(,d| !!!$(,d| !!!$,t , G$ $$&r)rmrrrrrxc X|d} tj| dd\} } t|dk(r d} d| g} d| g}nt|dk(r|dd\} }tj| } tj|}| jdk(r"|jdk(r| j dk(r|j dk(rd} nW| j | dzk7rt d| j d | d |j | dzk7rt d |j d | d tj| }tj|}tj|d t|jzkr5tj|d t|jzkrd} njd} ng| jdk(r|jdk(rd} nFtd| jd|jdtjddt|tjj!|||| dk(rtj"| |gd}tj| dvr t dt%j&|| ||||dd}|j)|d| j+| j-|j+|j-f\}}}}|}nu| d| d|d|dfx}\}}}}| dk(r t/j0|f|||| ||ddd|}n$| dk(rt/j2|| || f|||||d |}|j5|}tj| dk(r|j7||||j9|j;|j<||g|j>j@dd||g|j>jBdd|jEtjF||g||gg|jId!"|S)#a" Create a pseudocolor plot with a non-regular rectangular grid. Call signature:: ax.pcolorfast([X, Y], C, /, **kwargs) The arguments *X*, *Y*, *C* are positional-only. 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 pyplot wrapper. Parameters ---------- C : array-like The image data. Supported array shapes are: - (M, N): an image with scalar data. Color-mapping is controlled by *cmap*, *norm*, *vmin*, and *vmax*. - (M, N, 3): an image with RGB values (0-1 float or 0-255 int). - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), i.e. including transparency. The first two dimensions (M, N) define the rows and columns of the image. This parameter can only be passed positionally. X, Y : tuple or array-like, default: ``(0, N)``, ``(0, M)`` *X* and *Y* are used to specify the coordinates of the quadrilaterals. There are different ways to do this: - Use tuples ``X=(xmin, xmax)`` and ``Y=(ymin, ymax)`` to define a *uniform rectangular 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 + 1, N + 1), specifying the x and y coordinates of the corners of the colored quadrilaterals. 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. These arguments can only be passed positionally. %(cmap_doc)s This parameter is ignored if *C* is RGB(A). %(norm_doc)s This parameter is ignored if *C* is RGB(A). %(vmin_vmax_doc)s This parameter is ignored if *C* is RGB(A). %(colorizer_doc)s This parameter is ignored if *C* is RGB(A). alpha : float, default: None The alpha blending value, between 0 (transparent) and 1 (opaque). snap : bool, default: False Whether to snap the mesh to pixel boundaries. Returns ------- `.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. Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Supported additional parameters depend on the type of grid. See return types of *image* for further description. rNrrimagerrz Length of X (z6) must be one larger than the number of columns in C (rz Length of Y (z3) must be one larger than the number of rows in C (r pcolorimagequadmeshz{When 3 positional parameters are passed to pcolorfast, the first two (X and Y) must be both 1D or both 2D; the given X was zD and the given Y was D pcolorfastrOrrR>rrzC must be 2D or 3DFri)rrmrrrxrhrprrIr%)rrrxrBrmrr1r2)rrrxrmrTr)%rrrr,rKrrrTr5rrrrr" mcolorizerColorizingArtistr>rlrrxrr3r4r9r: PcolorImagerBrrrrrr|r*rrr)r'rmrrrrrxrRrArnrncstyler|r*rcrdrsrxlrybroretrrCs rr~zAxes.pcolorfastsl H!RaB t9>EBABA Y!^8DAq 1 A 1 Avv{qvv{66Q;166Q;#Evva'(+AFF84779d!=>>vva'(+AFF844464q:BBr TC N%::FF2JBGGI)>> ' -11"Qvvh4QVVHA?@@ ""<3t9E E##@@QUFJ A L J XXq!f2.Fwwqz' !566a$TY!f6J    E  :UUWaeegquuw?NBBC'(dAbE1Q42&> >F^RR%%#$)%"+G  -'''!Q-DIU!-&,- NN2 C 771:? OOD$ -     &   djj )!#R1!#R1 BHHr2hR%9:; $$4$0 rcbd|d<tj|g|i|}|j|S)z Plot contour lines. Call signature:: contour([X, Y,] Z, /, [levels], **kwargs) The arguments *X*, *Y*, *Z* are positional-only. %(contour_doc)s FfilledmcontourQuadContourSetrr'rRrAcontourss rcontourz Axes.contourms9!x**4A$A&A $$&rcbd|d<tj|g|i|}|j|S)z Plot filled contours. Call signature:: contourf([X, Y,] Z, /, [levels], **kwargs) The arguments *X*, *Y*, *Z* are positional-only. %(contour_doc)s Trrrs rcontourfz Axes.contourfs9 x**4A$A&A $$&rc (|j|fi|S)a Label a contour plot. Adds labels to line contours in given `.ContourSet`. Parameters ---------- CS : `.ContourSet` instance Line contours to label. levels : array-like, optional A list of level values, that should be labeled. The list must be a subset of ``CS.levels``. If not given, all levels are labeled. **kwargs All other parameters are documented in `~.ContourLabeler.clabel`. )clabel)r'CSlevelsrAs rrz Axes.clabels$ryy*6**rr2weightsc |}ddlm}tj|tj }t j|r|g}|tjd}tjgd|tjgd| tjd d g| |d k(r|sd }tj|d}t|}| d k(r6|j}g|jd|dfg|t!||dd}n5|j"}g|jd|dfg|t!||dd}|||}tj$|s||}|tj|d}ndg|z}t||k7r t'dd }t)||D]0\}}t|}|t||k7r t'd|s/d}2| .||Dcgc]}|j*j-}}n>t/j0| }t||k7rt'd|dt|dt3}|{t j4}t j4 }|D]L}t|st7|t j8|}t;|t j<|}N||kr||f}|sTt|dkDrF|t j>|}nd}t j@t j>||||}n||d<tC|}|r|s||d<g}||D]5}t jD|||fd||i|\} }|jG| 7t jH|tJ}t jH|tJ}|r@|jMd}|r,|t jN|z |djQz }|rtSd}!tU|tVr|dkr tSddd}!|r7|t jN|zdd|!fjMddd|!f}n |dd|!fjMddd|!f}g}"|jYdryt jN|}#| t jZ| dd}$n(t|dkDr|rtjdrd}$nd}$|dk(r|s|$|#z|z }%|%}&d|$z|#zdd|z z z}'n|d k(s|r |$|#z}%d \}'}&| d!k(r 'd"|#zz }'n | d#k(r'|#z }'| d k(r|j\}(d$})n|j^}(d%})t)||D]`\}*} |t j`t|*}|r|*|z }+n|*}+|(|dd'z|+%fd&| | d'|)|i},|"jG|,|r|*}|'&z }'b|"ddD];},|,D]4}-gx|-jbjddd|-jbjfdd6=ng|jYd(rUt j`d)t|zd*z }t j`d)t|zd*z }.||ddc|dd+t|zdz d+<|dd+t|zdz d+<|dd+t|zdz ddd|d+t|zdz d|d}|x|.dd+t|zdz d+<|.d+d+t|zd+<|.dd+t|zdz ddd|.d+t|zdz d| r,| d k(r|jid,d-.n|jkd,d-.| d$k(r|d"|d|dz zz}n| d#k(r|d"|d|dz zz }|d/k(}/gg}1}0|D]}*|r,|.dd+t|zdz ddd|.d+t|zdz d|*|zx|.dd+t|zdz d+<|.d+d+t|zd+<|.d|.d<| d k(r?|0jG|.jm|1jG|jm|0jG|jm|1jG|.jm|/rdn d+t|z}2totqt)|0|1|D][\}}.} |"jG|js|d|2|.d|2|/rd nd| |/rdn| |/r|/nd|/rdnttjvjx0]|"D]_}3|3D]X}-| d k(r&|-jbjfjGd.| d k(s4|-jbjdjGdZa|"j{|gn,t j|t j~|t}4|d(k(r|jd1|}5n|jd1d}5|5tj|5d2rtj|5}6n(tjt/j0|5}6|jd3|}7tj|7d2rtj|7}8n(tjt/j0|7}8tjt j||jd4d}9tjt j||jd5d}:d6|vr,tjtuj|d6};ntjd};tj|"|4D]\}-}<|-s |-d}=|jt|9t|:t|;t|6t|8d7|=j||<|=j|<|-ddD]$}=|=j||=jd8&|dk(r |d||"dfS|jYdrd9nd:}>||tj|>|"fScc}w);aj# Compute and plot a histogram. This method uses `numpy.histogram` to bin the data in *x* and count the number of values in each bin, then draws the distribution either as a `.BarContainer` or `.Polygon`. The *bins*, *range*, *density*, and *weights* parameters are forwarded to `numpy.histogram`. If the data has already been binned and counted, use `~.bar` or `~.stairs` to plot the distribution:: counts, bins = np.histogram(x) plt.stairs(counts, bins) Alternatively, plot pre-computed bins and counts using ``hist()`` by treating each bin as a single point with a weight equal to its count:: plt.hist(bins[:-1], bins, weights=counts) The data input *x* can be a singular array, a list of datasets of potentially different lengths ([*x0*, *x1*, ...]), or a 2D ndarray in which each column is a dataset. Note that the ndarray form is transposed relative to the list form. If the input is an array, then the return value is a tuple (*n*, *bins*, *patches*); if the input is a sequence of arrays, then the return value is a tuple ([*n0*, *n1*, ...], *bins*, [*patches0*, *patches1*, ...]). Masked arrays are not supported. 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, default: :rc:`hist.bins` If *bins* is an integer, it defines the number of equal-width bins in the range. If *bins* is a sequence, it defines the bin edges, including the left edge of the first bin and the right edge of the last bin; in this case, bins may be unequally spaced. 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. If *bins* is a string, it is one of the binning strategies supported by `numpy.histogram_bin_edges`: 'auto', 'fd', 'doane', 'scott', 'stone', 'rice', 'sturges', or 'sqrt'. range : tuple or None, default: None 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. density : bool, default: False If ``True``, draw and return a probability density: each bin will display the bin's raw count divided by the total number of counts *and the bin width* (``density = counts / (sum(counts) * np.diff(bins))``), so that the area under the histogram integrates to 1 (``np.sum(density * np.diff(bins)) == 1``). If *stacked* is also ``True``, the sum of the histograms is normalized to 1. weights : (n,) array-like or None, default: None 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 *density* is ``True``, the weights are normalized, so that the integral of the density over the range remains 1. cumulative : bool or -1, default: False 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 *density* is also ``True`` then the histogram is normalized such that the last bin equals 1. If *cumulative* is a number less than 0 (e.g., -1), the direction of accumulation is reversed. In this case, if *density* is also ``True``, then the histogram is normalized such that the first bin equals 1. bottom : array-like or float, default: 0 Location of the bottom of each bin, i.e. bins are drawn from ``bottom`` to ``bottom + hist(x, bins)`` If a scalar, the bottom of 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. histtype : {'bar', 'barstacked', 'step', 'stepfilled'}, default: 'bar' 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. align : {'left', 'mid', 'right'}, default: 'mid' The horizontal alignment of the histogram bars. - '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. orientation : {'vertical', 'horizontal'}, default: 'vertical' If 'horizontal', `~.Axes.barh` will be used for bar-type histograms and the *bottom* kwarg will be the left edges. rwidth : float or None, default: None 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'. log : bool, default: False If ``True``, the histogram axis will be set to a log scale. color : :mpltype:`color` or list of :mpltype:`color` or None, default: None Color or sequence of colors, one per dataset. Default (``None``) uses the standard line color sequence. label : str or list of str, 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 `~.Axes.legend` will work as expected. stacked : bool, default: False 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' Returns ------- n : array or list of arrays The values of the histogram bins. See *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. The dtype of the array *n* (or of its element arrays) will always be float even if no weighting or normalization is used. 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 : `.BarContainer` or list of a single `.Polygon` or list of such objects Container of individual artists used to create the histogram or list of such containers if there are multiple input datasets. Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs `~matplotlib.patches.Patch` properties. The following properties additionally accept a sequence of values corresponding to the datasets in *x*: *edgecolor*, *facecolor*, *linewidth*, *linestyle*, *hatch*. .. versionadded:: 3.10 Allowing sequences of values in above listed Patch properties. See Also -------- hist2d : 2D histogram with rectangular bins hexbin : 2D histogram with hexagonal bins stairs : Plot a pre-computed histogram bar : Plot a pre-computed histogram Notes ----- For large numbers of bins (>1000), plotting can be significantly accelerated by using `~.Axes.stairs` to plot a pre-computed histogram (``plt.stairs(*np.histogram(data))``), or by setting *histtype* to 'step' or 'stepfilled' rather than 'bar' or 'barstacked'. r)r2Nz hist.bins)r barstackedr stepfilled)histtype)rrrrrr'rrTr|rr*rz'weights should have the same shape as xFzBThe 'color' keyword argument must have one color per dataset, but z datasets and z colors were providedr2densityrRrrr!皙?r,r)rrrrjrrr{r)rr]r3rrnrrr]rrr)closedrkrlrrXrlrirkrr#r$)rr#r$rlrkrr z list[Polygon])Mbuiltinsr2r7rDrrrr6r4r5rr _reshape_2Drrrr&rr8rrrErr-r.rTinfr3r r4r rhistogram_bin_edgesrx histogramrrr:r0rTrLrvr~rrrrrrwrr|r*r_r`rreversedr1rrrrXreverserr,rrr8rrr_get_dash_patternsrr<r;r=r silent_list)?r'r|rr2rr cumulativer{rrrrwidthr]r3r>stackedrA bin_rangerr:r input_emptyxiwilen_xirr hist_kwargsrr_wtopsmslcrtotwidthdrrdwboffset_barfunc bottom_kwargrzrrrr*rxvalsyvalsr patch_listrJrrrpfcrihatchesrrrr patch_types? rhistz Axes.histsU R "''? ;;q>A <<< ,D F$, . 35A L*5;O | #GG   a % V * $ //M-$))C1;-@-mQqrU+-A!//M-$))C1;-@-mQqrU+-A  %i0I((. &D  !!'95A A q6R<FG G !Qi $FBWF~#b'V"3 !JKK#  $ =@Eb J1doo446JFJ**51F6{b  $;;=$n$'K=0E"GHHf  66DFF7D 4r7tRYYr]3DtRYYr]3D  4 t|!4L s1vz"^^A&))q!4B8D$-K w- 7%,K "r All1Q4KqtK{KGAt KKN   xxe$xxe$ ;;A;&Drwwt},R > +C*f-*q.D$+rwwt},af5<)'!8#l*99% 88' !$/  U>XXc#h/F 6\F FSb ' 165G&.C&+G0 >Aa#d) A a 1QqT{1_#5 !!Ac$iKM 24R4 8AaD k!mn ,.OOEvO>OOEvO>S$q'$q'/**'!S$q'$q'/** ,Dr5E +()!Ac$iKM(:4R4(@AaD k!mn%)>r)BCJ ZZ V ,  ! !"f -"))"-J")>)>r)BCJ//"-- 7D0I"JK__R]]6::k43P%QR & ")B)B6+CV)WXJ"))$/J#//@ *JE3aA MMg!*-!*-!*-!*-     v & C 12Y *""6* L) * *$ 77D'!*, ,,4,?,?,F.. u00WEE EiKs+!p;)rr-rc d|vr|jd}n|jj}|r%|jdd|jd|n|jd||!t j t |dz}|jd|fd|fd|fg|\}}}tj||f|||d |}|j|||rtjd |d |d ||d k(rc|jjjt j ||j#|dt j |fgnb|jj$jt j ||j#t j ||dfg|j'|S)a Draw a stepwise constant function as a line or a filled plot. *edges* define the x-axis positions of the steps. *values* the function values between these steps. Depending on *fill*, the function is drawn either as a continuous line with vertical segments at the edges, or as a filled area. Parameters ---------- values : array-like The step heights. edges : array-like The step positions, with ``len(edges) == len(vals) + 1``, between which the curve takes on vals values. orientation : {'vertical', 'horizontal'}, default: 'vertical' The direction of the steps. Vertical means that *values* are along the y-axis, and edges are along the x-axis. baseline : float, array-like or None, default: 0 The bottom value of the bounding edges or when ``fill=True``, position of lower edge. If *fill* is True or an array is passed to *baseline*, a closed path is drawn. If None, then drawn as an unclosed Path. fill : bool, default: False Whether the area under the step curve should be filled. Passing both ``fill=True` and ``baseline=None`` will likely result in undesired filling: the first and last points will be connected with a straight line and the fill will be between this line and the stairs. Returns ------- StepPatch : `~matplotlib.patches.StepPatch` Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs `~matplotlib.patches.StepPatch` properties r3r#rrkrlrr|r*)r-rrzBoth baseline=z and fill=a[ have been passed. baseline=None is only intended for unfilled stair plots. Because baseline is None, the Path used to draw the stairs will not be closed, thus because fill is True the polygon will be closed by drawing an (unstroked) edge from the first to last point. It is very likely that the resulting fill patterns is not the desired result.r')r~rErr^rr}rrr StepPatchrrrorr*rr3rr|r) r'redgesrr-rrA_colorrs rstairsz Axes.stairssj f ZZ(F__335F    k1 -   k6 2   k6 2 =IIc&kAo.E"&"9"95\C=3/ :F#Dvx""6#(-,4/:(, - &, - u     !{+w/   j(""$$++BFF8,<=##eAhx0@%A$BC""$$++BFF8,<=##bffX&6a%A$BC $$& r)r|r*rc  tj||||||\} } } |d| | |k<|d| | |kD<|j| | | jfi| } |j | d| d|j | d| d| | | | fS)a 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 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. density : bool, default: False Normalize histogram. See the documentation for the *density* parameter of `~.Axes.hist` for more details. weights : array-like, shape (n, ), optional An array of values w_i weighing each sample (x_i, y_i). cmin, cmax : float, default: None All bins that has count less than *cmin* or more than *cmax* will not be displayed (set to NaN before passing to `~.Axes.pcolormesh`) 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_doc)s %(norm_doc)s %(vmin_vmax_doc)s %(colorizer_doc)s alpha : ``0 <= scalar <= 1`` or ``None``, optional The alpha blending value. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Additional parameters are passed along to the `~.Axes.pcolormesh` method and `~matplotlib.collections.QuadMesh` constructor. See Also -------- hist : 1D histogram plotting hexbin : 2D histogram with hexagonal bins Notes ----- - Currently ``hist2d`` calculates its 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`. )rr2rrNrr)r histogram2drNr]set_xlimset_ylim)r'r|r*rr2rrcmincmaxrArxedgesyedgespcs rhist2dz Axes.hist2ds@NN1ad%3:GM66  Aa$hK  Aa$hK T__VVQSS ;F ; fQi, fQi,&&"$$r) complementaryrcompressc dtjddg|d|vsd|vr tdtjj |j r tdtj|}tj|j r tdtj|}||}|.d tjt|zt|z }nAtj||}tj|tj|z }|r,d g|d d |d d k7j!d d z} || }|| }|dk(rf|s"|j"|d g|d g|fdd i|\} n%|j"g||d d gd |z fddi|\} d d g| j$j&d d | S|s"|j"d g||d g|fddi|\} n%|j"d gd |z g||d fdd i|\} d d g| j$j(d d | S)aB Compute and plot the empirical cumulative distribution function of *x*. .. versionadded:: 3.8 Parameters ---------- x : 1d array-like The input data. Infinite entries are kept (and move the relevant end of the ecdf from 0/1), but NaNs and masked values are errors. weights : 1d array-like or None, default: None The weights of the entries; must have the same shape as *x*. Weights corresponding to NaN data points are dropped, and then the remaining weights are normalized to sum to 1. If unset, all entries have the same weight. complementary : bool, default: False Whether to plot a cumulative distribution function, which increases from 0 to 1 (the default), or a complementary cumulative distribution function, which decreases from 1 to 0. orientation : {"vertical", "horizontal"}, default: "vertical" Whether the entries are plotted along the x-axis ("vertical", the default) or the y-axis ("horizontal"). This parameter takes the same values as in `~.Axes.hist`. compress : bool, default: False Whether multiple entries with the same values are grouped together (with a summed weight) before plotting. This is mainly useful if *x* contains many identical data points, to decrease the rendering complexity of the plot. If *x* contains no duplicate points, this has no effect and just uses some time and memory. Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs Keyword arguments control the `.Line2D` properties: %(Line2D:kwdoc)s Returns ------- `.Line2D` Notes ----- The ecdf plot can be thought of as a cumulative histogram with one bin per data entry; i.e. it reports on the entire dataset without any arbitrary binning. If *x* contains NaNs or masked entries, either remove them first from the array (if they should not taken into account), or replace them by -inf or +inf (if they should be sorted at the beginning or the end of the array). rr'rrdsz)Cannot pass 'drawstyle' or 'ds' to ecdf()z&ecdf() does not support masked entrieszecdf() does not support NaNsNrrrz steps-postz steps-pre)rrrrrgetmaskr(rr,rargsortr}rtaker0rLnonzerorFrr*r|) r'r|rrrrrAr cum_weights compress_idxsrs recdfz Axes.ecdfqs}~ L*5;O & DFNGH H 55==    !EF F JJqM 88A;?? ;< <**Q- gJ ?ryyQ00CF:Kgggw/G))GbffWo$=>K D!CR&AabE/!:!:!| | dk(s| d k(rdtj|z}n'dtj|z}ntd|tj |}| ;||z |z dz }tj ||z tj||zf} | \}}||z }|||d|df}d|vrtjdd|j||f|||dd|}|jd||||fS)aS Plot a spectrogram. 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. 'magnitude' returns the magnitude spectrum. 'angle' returns the phase spectrum without unwrapping. 'phase' returns the phase spectrum with unwrapping. noverlap : int, default: 128 The number of points of overlap between blocks. 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, default: 0 The center frequency of *x*, 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 : `.Colormap`, default: :rc:`image.cmap` 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. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER vmin, vmax : float, optional vmin and vmax define the data range that the colormap covers. By default, the colormap covers the complete value range of the data. **kwargs Additional keyword arguments are passed on to `~.axes.Axes.imshow` which makes the specgram image. The origin keyword argument is not supported. Returns ------- spectrum : 2D 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 : `.AxesImage` The image created by imshow containing the spectrogram. See Also -------- 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. magnitude_spectrum A single spectrum, similar to having a single segment when *mode* is 'magnitude'. Plots a line instead of a colormap. angle_spectrum A single spectrum, similar to having a single segment when *mode* is 'angle'. Plots a line instead of a colormap. 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'. rrrcomplexzCannot plot a complex specgramrB)anglephaserrz,Cannot use dB scale with angle or phase mode) r|rrrrrrrrrurrrzUnknown scale rr2specgramupper)rrrr2r2) rrr rrflipudr3r4r kwarg_errorrDr)r'r|rrrrrrrxextentrrrrurrrrArrrr pad_xextentrrrrCs rr z Axes.specgramsT <D :B  H :B 9 => > =EY.))  ' 'ETMKL L"/6v08-25B,0 2eQ H A d]|ty0DEM"((4.("((4.(~eY78 8 IIaL ?=B.2KffQi+-rvvay;/FFG d  tU1XuRy0 v "":x8 8 T[[D3d '3+13 &UAr!!r precisionc ,||t|drd}tjddg|||tj|}tj ||kD}d|vrt jddgd |d<d |vrtjd d d |vrt j|d <|j|fd||d|} nst|dro|j} |dk(r| j} | j} ntj | j|kD} | j| } | j| } nEtj|}tj ||kD} tj| \} } |d}|d}d|vrtjd dt!j"| | fd||d|} |j%| |j&\}}|j)d|dz |dk(r|j+|dz dn|j+d|dz |j-||j.j1d|dk(r|j2j5n|j2j7|j2j9d|j2j;t=j>dgdd|j@j;t=j>dgdd| 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 keyword arguments are passed to this method. **Marker style** If *Z* is a `scipy.sparse.spmatrix` or *marker* or *markersize* are *None*, a `.Line2D` object will be returned with the value of marker determining the marker type, and any remaining keyword arguments passed to `~.Axes.plot`. Parameters ---------- Z : (M, N) array-like The array to be plotted. precision : float or 'present', default: 0 If *precision* is 0, any non-zero value will be plotted. Otherwise, values of :math:`|Z| > precision` will be plotted. For `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. aspect : {'equal', 'auto', None} or float, default: 'equal' The aspect ratio of the Axes. This parameter is particularly relevant for images since it determines whether data pixels are 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`. origin : {'upper', 'lower'}, default: :rc:`image.origin` 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. Returns ------- `~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:kwdoc)s tocoorrr%)r2rrrabinary)rr1spyrrI)r1r0r2presentrrr$ry)r$rwrrrj?both rrrVrrTrstepsr)!r+rrrr,rr-ListedColormaprNoNormrDrrowrrBrrrrrrrrIr"set_yrtick_top tick_bottomset_ticks_positionr?r= MaxNLocatorr)r'rrrwrr0r2rArrrr*r|rrrs rrzAxes.spyt s` >j0WQ5HF GW-f= >j0 1 A66!9y(DV#!(!7!7c =E"Gv&(&&uo>>V#!(!1v$++d()%+F( &(Cq'"GGI )AA ffQVVny8GgAgAJJqM&&)i/zz'*1~! f$&&uk::--1 &v*C MM# WWFB MM$S )  b3h- dBH- OOF #  W  JJ   ! JJ " " $ %%f- $$   a}d K M $$   a}d K M rc tj|}dddd|}|j|fi|}|jj d|j j |j jd|j jtjdgdd |jjtjdgdd |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 : (M, N) array-like The matrix to be displayed. Returns ------- `~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 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. rrIr9)r2r1r0rrrrTr) rr)rDr"r"rr#r%r?r=r&r)r'rrAkwrCs rmatshowz Axes.matshow!sH MM! (T[[ !b !   %%f- $$   a}d K M $$   a}d K M rrdatasetc t fd} tj|| | | }|j|||||||||  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, the maximum, and user-specified quantiles. Parameters ---------- dataset : Array or a sequence of vectors. The input data. positions : array-like, default: [1, 2, ..., n] The positions of the violins; i.e. coordinates on the x-axis for vertical violins (or y-axis for horizontal violins). vert : bool, optional .. deprecated:: 3.10 Use *orientation* instead. If this is given during the deprecation period, it overrides the *orientation* parameter. If True, plots the violins vertically. If False, plots the violins horizontally. orientation : {'vertical', 'horizontal'}, default: 'vertical' If 'horizontal', plots the violins horizontally. Otherwise, plots the violins vertically. .. versionadded:: 3.10 widths : float or array-like, default: 0.5 The maximum width of each violin in units of the *positions* axis. The default is 0.5, which is half the available space when using default *positions*. showmeans : bool, default: False Whether to show the mean with a line. showextrema : bool, default: True Whether to show extrema with a line. showmedians : bool, default: False Whether to show the median with a line. quantiles : array-like, default: None If not None, set a list of floats in interval [0, 1] for each violin, which stands for the quantiles that will be rendered for that violin. points : int, default: 100 The number of points to evaluate each of the gaussian kernel density estimations at. bw_method : {'scott', 'silverman'} or float or callable, default: 'scott' The method used to calculate the estimator bandwidth. If a float, this will be used directly as `kde.factor`. If a callable, it should take a `matplotlib.mlab.GaussianKDE` instance as its only parameter and return a float. side : {'both', 'low', 'high'}, default: 'both' 'both' plots standard violins. 'low'/'high' only plots the side below/above the positions value. data : indexable object, optional DATA_PARAMETER_PLACEHOLDER Returns ------- 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 `~.collections.PolyCollection` instances containing the filled area of each violin. - ``cmeans``: A `~.collections.LineCollection` instance that marks the mean values of each of the violin's distribution. - ``cmins``: A `~.collections.LineCollection` instance that marks the bottom of each violin's distribution. - ``cmaxes``: A `~.collections.LineCollection` instance that marks the top of each violin's distribution. - ``cbars``: A `~.collections.LineCollection` instance that marks the centers of each violin's distribution. - ``cmedians``: A `~.collections.LineCollection` instance that marks the median values of each of the violin's distribution. - ``cquantiles``: A `~.collections.LineCollection` instance created to identify the quantile values of each of the violin's distribution. See Also -------- .Axes.violin : Draw a violin from pre-computed statistics. boxplot : Draw a box and whisker plot. ctj|}tj|d|k(r|d|k(j t St j|}|j|Sr) r7_unpack_to_numpyrr4rr:r GaussianKDEevaluate)rrskde bw_methods r _kde_methodz$Axes.violinplot.._kde_method!sa&&q)Avvadai !..u55""1i0C<<' 'r)points quantiles)rrrrr showextrema showmediansside)r7 violin_statsviolin)r'r*rrrrrr5r6r4r3r1r7r2vpstatss ` r violinplotzAxes.violinplot3!sO\ ($$Wk&/8:{{7id'26%.K'2? ?rc g} g} g} g} g}g}i}t|}d}|tjdddd|rdnd}tjddg| |t d |d z}n(t||k7rt |j d tj|r|g|z}n(t||k7rt |j d tjgd | | dvrdndg| dvrdndggtj|z|z}tjdrd}d}n|jjx}}|dk(r|j}| dvrEtj |j"|d}tj |j$|d}ntj |j"|}tj |j$|}n|j&}| dvrEtj |j$|d}tj |j"|d}nBtj |j$|}tj |j"|}g}t)|||D]\}}}tj|d}d|z|z|j+z }|||d| dvr| |zn|| dvr||zn||dgz }| j-|d | j-|d!| j-|d"| j-|d#|j/d$}|g}|j1||j-t|||d%<|r || g||d&<|r%|| g||d'<|| g||d(<||| | |d)<|r || g||d*<|r"||gtj2||d +|d,<|S)-a Draw a violin plot from pre-computed statistics. 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, the maximum, and the quantiles values. 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. Optional keys are: - ``quantiles``: A list of scalars containing the quantile values for this violin's dataset. positions : array-like, default: [1, 2, ..., n] The positions of the violins; i.e. coordinates on the x-axis for vertical violins (or y-axis for horizontal violins). vert : bool, optional .. deprecated:: 3.10 Use *orientation* instead. If this is given during the deprecation period, it overrides the *orientation* parameter. If True, plots the violins vertically. If False, plots the violins horizontally. orientation : {'vertical', 'horizontal'}, default: 'vertical' If 'horizontal', plots the violins horizontally. Otherwise, plots the violins vertically. .. versionadded:: 3.10 widths : float or array-like, default: 0.5 The maximum width of each violin in units of the *positions* axis. The default is 0.5, which is half available space when using default *positions*. showmeans : bool, default: False Whether to show the mean with a line. showextrema : bool, default: True Whether to show extrema with a line. showmedians : bool, default: False Whether to show the median with a line. side : {'both', 'low', 'high'}, default: 'both' 'both' plots standard violins. 'low'/'high' only plots the side below/above the positions value. Returns ------- 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 `~.collections.PolyCollection` instances containing the filled area of each violin. - ``cmeans``: A `~.collections.LineCollection` instance that marks the mean values of each of the violin's distribution. - ``cmins``: A `~.collections.LineCollection` instance that marks the bottom of each violin's distribution. - ``cmaxes``: A `~.collections.LineCollection` instance that marks the top of each violin's distribution. - ``cbars``: A `~.collections.LineCollection` instance that marks the centers of each violin's distribution. - ``cmedians``: A `~.collections.LineCollection` instance that marks the median values of each of the violin's distribution. - ``cquantiles``: A `~.collections.LineCollection` instance created to identify the quantiles values of each of the violin's distribution. See Also -------- violinplot : Draw a violin plot from data instead of pre-computed statistics. zHList of violinplot statistics and `{0}` values must have the same lengthrrrTrr'rrrrr)rrr)r7)rrgпr)rrr)r!r*r)rr projecting)rcapstyle)rrrjrsg333333?)rkrmrr3r4r r4bodiescmeanscmaxescminscbarscmediansrR cquantiles)rrr1rr2rr3rr6rr4r5rErr/ functoolspartialrrr*rr4rrr;r)r'r:rrrrrr5r6r7r0r;r<r/r4qlensrrLrM line_ends fillcolorr'r perp_lines par_linesr?rrNrrrs rr9z Axes.violin!s+^  L@    !E   )-*,K L*5;O  aQI ^q .55kBC C ;;v X\F [A .55h?@ @ 2> $6eA>"&66dA>@HHV,-/89 <<0 1II$(OO$B$B$D DI  * $%%D&&..t{{99EG %--dkk)9EG '..t{{9M %--dkk)L $$D&&..t{{99EG %--dkk)9EG '..t{{9M %--dkk)L !$Wi!@ ! E388E&M*D;% 2D tE(O+/?+BTECK*.2B*BD3J&/s<= =F LLv ' KKe % LLu & NN5? + +&Ay   Q  LLQ ! !"#  *5 =9 =GH   *5 =9 =GH )$;;GG (D%@GG  ",W"Ay"AGJ  $.%AIIiQ?%AGL !r)r|r*urb start_pointsc|jj}|j|z\}}||z \}}|||jzz S)zx Convenience method to calculate the aspect ratio of the Axes in the display coordinate system. )r`get_size_inches get_positionget_data_ratio)r' figure_sizellurrrs r_get_aspect_ratiozAxes._get_aspect_ratio"sV oo'779 ""${2BR v!4!4!6677r)r)NNNrU)NN)NrBNNN)rrrr)Nrrv)rrrNNNr)rxNTF)rN)NNNNg333333?Fg?rrTNN)rrFF) NNrvNNNFFFFFrN)NNNr'NNNNNNNNNNNNNNNNNNNTFNNN)NNNr'FFFTTTNNNNNNFTNNN) NNNNNNNNN)r)rNFN)rNNF)NNFNFNrrr'NFNNF)rrNFNNN) NNNNNNNNNN)NNNNNN)NNNNN)NNNNNNNNNNNNNNN)rNNr9r) NNr'rjFTFNrNr)NNr'rjFTFr)rr __module__r__doc__r)rDrKrinterpdrSrPrZrvrxrrrrrr__init__rr staticmethodrrrrrmake_keyword_onlyrrrrArF deprecatedrOrerirmrpr detrend_nonerorrrrrr rrrsr{rrename_parameterrrrwrrrrrrrrr r rrrr$rr*r3r/rDrbrerNr~rrrrrrrrrrrrwindow_hanningrr rr)r;r9rmtabletablemstack stackplotmstream streamplotmtri tricontour tricontourf tripcolortriplotrVr\rrrrCs%0 2TtTl xxt/31FPPd!'5"PPd&=P3T33j)T))VLL\JN26  ''0088HPPdPPd33GTGGR44l<<|TFG,$C"%'IJEI$o>3 oj!%d{{zT__U/S#JC@L.A0L.^2O2Oj+F+F\+F+FZSEs;G*<G*RTFH-S#JC@!%t/@/@bl#A.l#b',$B;H11f0$dBhBBJ FXFFPeteN@@D"&$QZ__BTFI.$HI7;GJ154:&+ t,;?d t,J/t,l>TFH-$>"%'-1?C7158<8BDIEI9=7;6:"& xA.xAt [%[%zTFH-%<#&'IM=A[4u[ '. [zTFJ/OE!Cdxt$Tdv!# OF0Ob %%NZ__W&&//01  $2j,-hEhTI AFG ##3;;BB#3 C $ <(02L04-2G ## 4 < < C C!D! % =)02M t!ttD#'DC$ ttl4:o b$(4dttYYv&*DtdccJ&*DtFFP  +,TFG,S)$4#FDHBG6;-2wFG-wFr^%^^@TFG,$9:GK#i%;-i%VS)$4#FbU#ebGbHTFF+SE*:>/38<k$+,k$ZTFF+S#JC@=A/38<b$A,b$HTFD)SE*=A:>R!+*R!hTFD)SE*9=*.A%+*A%FTFD)SE*9=*.A%+*A%FTFF+S#J/ #a9J9J))Add<0,<|TFF+SE*?C'+=A6:!% ]"+,]"~TFK0:>#*H1HT1fTFF+YK07;AFBF4:z?1,z?xTFF+37=B9?[,[~ fll +E# "#4V5E5E#FGI@!>@',,-/J#4??3J#D$4$45K!$..1I -G8rr)crFrloggingrOnumbersrrrrXnumpyr matplotlibr4matplotlib.categorymatplotlib.cbookr7matplotlib.collections collectionsrmatplotlib.colorizerrxrmatplotlib.colorsrr-matplotlib.contourrrmatplotlib.datesmatplotlib.imagerzr9matplotlib.insetinsetrrmatplotlib.legendrSrFmatplotlib.linesr rmatplotlib.markersmarkersrmatplotlib.mlabrmatplotlib.patchesrrmatplotlib.pathr"rmatplotlib.quiverrrmatplotlib.stackplotrdrcmatplotlib.streamplotrfrematplotlib.tablerbramatplotlib.textrrmatplotlib.tickertickerr=matplotlib.transforms transformsrmatplotlib.tritrirgmatplotlib.unitsunitsrrrrmatplotlib.axes._baser r r matplotlib.axes._secondary_axesr matplotlib.containerr rrr getLoggerr_logrrYrr\rrrs **  &)#%!!#!%%#%'!#+!99@@9OO1w"$ cI89cI8cI8r