rL i$dZddlZddlZddlmZddlmZmZmZddl m Z ddl m ZddlmZddlmZddlmZdej,j.zZej,j3eGdd e j4Zd d d Zd ZGddej<Zdej,j.zZ ej,j3e Gddej<Z!y)a Support for plotting vector fields. Presently this contains Quiver and Barb. Quiver plots an arrow in the direction of the vector, with the size of the arrow related to the magnitude of the vector. Barbs are like quiver in that they point along a vector, but the magnitude of the vector is given schematically by the presence of barbs or flags on the barb. This will also become a home for things such as standard deviation ellipses, which can and will be derived very easily from the Quiver code. N)ma)_apicbook _docstring) CirclePolygonu% Plot a 2D field of arrows. Call signature:: quiver([X, Y], U, V, [C], /, **kwargs) *X*, *Y* define the arrow locations, *U*, *V* define the arrow directions, and *C* optionally sets the color. The arguments *X*, *Y*, *U*, *V*, *C* are positional-only. **Arrow length** The default settings auto-scales the length of the arrows to a reasonable size. To change this behavior see the *scale* and *scale_units* parameters. **Arrow shape** The arrow shape is determined by *width*, *headwidth*, *headlength* and *headaxislength*. See the notes below. **Arrow styling** Each arrow is internally represented by a filled polygon with a default edge linewidth of 0. As a result, an arrow is rather a filled area, not a line with a head, and `.PolyCollection` properties like *linewidth*, *edgecolor*, *facecolor*, etc. act accordingly. Parameters ---------- X, Y : 1D or 2D array-like, optional The x and y coordinates of the arrow locations. If not given, they will be generated as a uniform integer meshgrid based on the dimensions of *U* and *V*. If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)`` must match the column and row dimensions of *U* and *V*. U, V : 1D or 2D array-like The x and y direction components of the arrow vectors. The interpretation of these components (in data or in screen space) depends on *angles*. *U* and *V* must have the same number of elements, matching the number of arrow locations in *X*, *Y*. *U* and *V* may be masked. Locations masked in any of *U*, *V*, and *C* will not be drawn. C : 1D or 2D array-like, optional Numeric data that defines the arrow colors by colormapping via *norm* and *cmap*. This does not support explicit colors. If you want to set colors directly, use *color* instead. The size of *C* must match the number of arrow locations. angles : {'uv', 'xy'} or array-like, default: 'uv' Method for determining the angle of the arrows. - 'uv': Arrow directions are based on :ref:`display coordinates `; i.e. a 45° angle will always show up as diagonal on the screen, irrespective of figure or Axes aspect ratio or Axes data ranges. This is useful when the arrows represent a quantity whose direction is not tied to the x and y data coordinates. If *U* == *V* the orientation of the arrow on the plot is 45 degrees counter-clockwise from the horizontal axis (positive to the right). - 'xy': Arrow direction in data coordinates, i.e. the arrows point from (x, y) to (x+u, y+v). This is ideal for vector fields or gradient plots where the arrows should directly represent movements or gradients in the x and y directions. - Arbitrary angles may be specified explicitly as an array of values in degrees, counter-clockwise from the horizontal axis. In this case *U*, *V* is only used to determine the length of the arrows. For example, ``angles=[30, 60, 90]`` will orient the arrows at 30, 60, and 90 degrees respectively, regardless of the *U* and *V* components. Note: inverting a data axis will correspondingly invert the arrows only with ``angles='xy'``. pivot : {'tail', 'mid', 'middle', 'tip'}, default: 'tail' The part of the arrow that is anchored to the *X*, *Y* grid. The arrow rotates about this point. 'mid' is a synonym for 'middle'. scale : float, optional Scales the length of the arrow inversely. Number of data values represented by one unit of arrow length on the plot. For example, if the data represents velocity in meters per second (m/s), the scale parameter determines how many meters per second correspond to one unit of arrow length relative to the width of the plot. Smaller scale parameter makes the arrow longer. By default, an autoscaling algorithm is used to scale the arrow length to a reasonable size, which is based on the average vector length and the number of vectors. The arrow length unit is given by the *scale_units* parameter. scale_units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, default: 'width' The physical image unit, which is used for rendering the scaled arrow data *U*, *V*. The rendered arrow length is given by length in x direction = $\frac{u}{\mathrm{scale}} \mathrm{scale_unit}$ length in y direction = $\frac{v}{\mathrm{scale}} \mathrm{scale_unit}$ For example, ``(u, v) = (0.5, 0)`` with ``scale=10, scale_units="width"`` results in a horizontal arrow with a length of *0.5 / 10 * "width"*, i.e. 0.05 times the Axes width. Supported values are: - 'width' or 'height': The arrow length is scaled relative to the width or height of the Axes. For example, ``scale_units='width', scale=1.0``, will result in an arrow length of width of the Axes. - 'dots': The arrow length of the arrows is in measured in display dots (pixels). - 'inches': Arrow lengths are scaled based on the DPI (dots per inch) of the figure. This ensures that the arrows have a consistent physical size on the figure, in inches, regardless of data values or plot scaling. For example, ``(u, v) = (1, 0)`` with ``scale_units='inches', scale=2`` results in a 0.5 inch-long arrow. - 'x' or 'y': The arrow length is scaled relative to the x or y axis units. For example, ``(u, v) = (0, 1)`` with ``scale_units='x', scale=1`` results in a vertical arrow with the length of 1 x-axis unit. - 'xy': Arrow length will be same as 'x' or 'y' units. This is useful for creating vectors in the x-y plane where u and v have the same units as x and y. To plot vectors in the x-y plane with u and v having the same units as x and y, use ``angles='xy', scale_units='xy', scale=1``. Note: Setting *scale_units* without setting scale does not have any effect because the scale units only differ by a constant factor and that is rescaled through autoscaling. units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, default: 'width' Affects the arrow size (except for the length). In particular, the shaft *width* is measured in multiples of this unit. Supported values are: - 'width', 'height': The width or height of the Axes. - 'dots', 'inches': Pixels or inches based on the figure dpi. - 'x', 'y', 'xy': *X*, *Y* or :math:`\sqrt{X^2 + Y^2}` in data units. The following table summarizes how these values affect the visible arrow size under zooming and figure size changes: ================= ================= ================== units zoom figure size change ================= ================= ================== 'x', 'y', 'xy' arrow size scales — 'width', 'height' — arrow size scales 'dots', 'inches' — — ================= ================= ================== width : float, optional Shaft width in arrow units. All head parameters are relative to *width*. The default depends on choice of *units* above, and number of vectors; a typical starting value is about 0.005 times the width of the plot. headwidth : float, default: 3 Head width as multiple of shaft *width*. See the notes below. headlength : float, default: 5 Head length as multiple of shaft *width*. See the notes below. headaxislength : float, default: 4.5 Head length at shaft intersection as multiple of shaft *width*. See the notes below. minshaft : float, default: 1 Length below which arrow scales, in units of head length. Do not set this to less than 1, or small arrows will look terrible! minlength : float, default: 1 Minimum length as a multiple of shaft width; if an arrow length is less than this, plot a dot (hexagon) of this diameter instead. color : :mpltype:`color` or list :mpltype:`color`, optional Explicit color(s) for the arrows. If *C* has been set, *color* has no effect. This is a synonym for the `.PolyCollection` *facecolor* parameter. Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs : `~matplotlib.collections.PolyCollection` properties, optional All other keyword arguments are passed on to `.PolyCollection`: %(PolyCollection:kwdoc)s Returns ------- `~matplotlib.quiver.Quiver` See Also -------- .Axes.quiverkey : Add a key to a quiver plot. Notes ----- **Arrow shape** The arrow is drawn as a polygon using the nodes as shown below. The values *headwidth*, *headlength*, and *headaxislength* are in units of *width*. .. image:: /_static/quiver_sizes.svg :width: 500px The defaults give a slightly swept-back arrow. Here are some guidelines how to get other head shapes: - To make the head a triangle, make *headaxislength* the same as *headlength*. - To make the arrow more pointed, reduce *headwidth* or increase *headlength* and *headaxislength*. - To make the head smaller relative to the shaft, scale down all the head parameters proportionally. - To remove the head completely, set all *head* parameters to 0. - To get a diamond-shaped head, make *headaxislength* larger than *headlength*. - Warning: For *headaxislength* < (*headlength* / *headwidth*), the "headaxis" nodes (i.e. the ones connecting the head with the shaft) will protrude out of the head in forward direction so that the arrow head looks broken. ) quiver_docc eZdZdZdddddZdddddZddd d dZd d d ddd d d dfd ZedZ dZ dZ e jdZdZfdZdZxZS) QuiverKeyz2Labelled arrow for use as a quiver plot scale key.centerleftrightNSEWbottomtopmiddletiptailraxesN皙?r)angle coordinatescolorlabelseplabelpos labelcolorfontpropertieszorderc Ht|||_||_||_||_||_||_||_||_ | |_ | |_ | |_ | xs t|_||_t!j"||j$|j|j&|j|j|_|j%|j(j+|jd|_| | |_y|j.dz|_y)a Add a key to a quiver plot. The positioning of the key depends on *X*, *Y*, *coordinates*, and *labelpos*. If *labelpos* is 'N' or 'S', *X*, *Y* give the position of the middle of the key arrow. If *labelpos* is 'E', *X*, *Y* positions the head, and if *labelpos* is 'W', *X*, *Y* positions the tail; in either of these two cases, *X*, *Y* is somewhere in the middle of the arrow+label key object. Parameters ---------- Q : `~matplotlib.quiver.Quiver` A `.Quiver` object as returned by a call to `~.Axes.quiver()`. X, Y : float The location of the key. U : float The length of the key. label : str The key label (e.g., length and units of the key). angle : float, default: 0 The angle of the key arrow, in degrees anti-clockwise from the horizontal axis. coordinates : {'axes', 'figure', 'data', 'inches'}, default: 'axes' Coordinate system and units for *X*, *Y*: 'axes' and 'figure' are normalized coordinate systems with (0, 0) in the lower left and (1, 1) in the upper right; 'data' are the axes data coordinates (used for the locations of the vectors in the quiver plot itself); 'inches' is position in the figure in inches, with (0, 0) at the lower left corner. color : :mpltype:`color` Overrides face and edge colors from *Q*. labelpos : {'N', 'S', 'E', 'W'} Position the label above, below, to the right, to the left of the arrow, respectively. labelsep : float, default: 0.1 Distance in inches between the arrow and the label. labelcolor : :mpltype:`color`, default: :rc:`text.color` Label color. fontproperties : dict, optional A dictionary with keyword arguments accepted by the `~matplotlib.font_manager.FontProperties` initializer: *family*, *style*, *variant*, *size*, *weight*. zorder : float The zorder of the key. The default is 0.1 above *Q*. **kwargs Any additional keyword arguments are used to override vector properties taken from *Q*. )texthorizontalalignmentverticalalignmentr Nr)super__init__QXYUrcoordrlabel_labelsep_inchesrrdictr kwmtextTexthalignvalignr# set_color_dpi_at_last_initr!)selfr(r)r*r+r-rrrrrrr r!kwargs __class__s W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/quiver.pyr'zQuiverKey.__init__sj      (  $,6JJ $ DMM :"kk$--8.. 0 ?? & II   0!% & 2f 3 c||j|jjjdjzS)NTroot)r.r(r get_figuredpir7s r:rzQuiverKey.labelsepis/$$tvv{{'='=4'='H'L'LLLr;c |jj|jjjdjk7r|jj |j tj|j|j|jtj5|jtjtj |j"z}|jtj$tj |j"z}|jj'ddggtj(|gtj(|gd|_ddd|jj,}|j/|j0t3j4|j*f|j6|j8fg|j;d||_|j>%|j<jA|j>|j<jC|jj;|j<jE|j|jjjdj|_y#1swYKxYw)NTr=)pivotUmaskuvoffsetsoffset_transform)#r(r6rr?r@_init_set_transformr _setattr_cmrCrrnomaskr+npcosradiansrsin _make_vertsarrayvertspolykwupdater0 mcollectionsPolyCollectionr)r* get_transformvectorrr5 set_transform set_figure)r7uvr8s r:rJzQuiverKey._initms vv''466;;+A+At+A+L+P+PP     !""466DMM1J)+4 TFFRVVBJJtzz$:;;FFRVVBJJtzz$:;;!VV//"b 02! rxx}dT  TVV]]F MM$'' "&55 &&$&&)*!%!3!3!5 DK zz% %%djj1 KK % %dff&:&:&< = KK " "4??#4 5%)VV[[%;%;%;%F%J%JD "% T Ts :C KKcd|jfd|j f|jdf|j dfd|jS)Nrr)rrrAs r: _text_shiftzQuiverKey._text_shiftsRdmm^$dmm^$==.!$==.!$  --  r;c`|j|jj||jj |j |j f}|jj||jz|jj|d|_ y)NF) rJrZdrawrY transformr)r*r# set_positionr`stale)r7rendererposs r:rbzQuiverKey.drawsz  "  ",,dffdff-=> sT%5%5%778 x  r;c Z|jjjd}|jt j |jjj |jjj|j|jd|jy)NFr=)datarfigureinches)r) r(rr?r[r check_getitem transData transAxes transFiguredpi_scale_transr,)r7figs r:rKzQuiverKey._set_transformsxffkk$$%$0 4--FFKK))FFKK))oo)) / zz # $r;cZt|||jj|yN)r&r\r#)r7rqr9s r:r\zQuiverKey.set_figures" 3 S!r;c|j|rdifS|jj|ds|jj|drdifSdifS)NFrT)_different_canvasr#containsrZ)r7 mouseevents r:rvzQuiverKey.containss]  ! !* -"9  II  z *1 - $$Z038Obyr;)__name__ __module__ __qualname____doc__r3r4rCr'propertyrrJr`martistallow_rasterizationrbrKr\rv __classcell__r9s@r:r r s<(g FF%hX FFF CEtc$tLG\MMK2   !$"r;r function) caller_namecldx}x}}t|}|dk(rtj|\}}no|dk(rtj|\}}}nS|dk(rtj|\}}}}n6|dk(rtj|\}}}}}ntj|d||j dk(rd|j d fn |j \}} ||j}|j}t|| k(r/t||k(r!d tj||D\}}nt|t|k7rntd |jd |jd tjtj| tj|} d| D\}}|||||fS)a Helper function to parse positional parameters for colored vector plots. This is currently used for Quiver and Barbs. Parameters ---------- *args : list list of 2-5 arguments. Depending on their number they are parsed to:: U, V U, V, C X, Y, U, V X, Y, U, V, C caller_name : str Name of the calling method (used in error messages). Nz from 2 to 5)takesgivenrc3<K|]}|jywrs)ravel.0as r: z_parse_args..s9!AGGI9sz-X and Y must be the same size, but X.size is z and Y.size is .c3FK|]}tj|ywrs)rNrrs r:rz_parse_args..s/ /s!) lenrN atleast_1dr nargs_errorndimshapermeshgrid ValueErrorsizearange) rargsr)r*Cnargsr+Vnrnc indexgrids r: _parse_argsrs&AA IE z}}d#1 !--&1a !]]D) 1a ! t, 1aA{-uMM !! a_FB} GGI GGI q6RK>,.,-  1TWWt~~ % 1)/ 1  Q1!%r;c |j}|jj|jjj |_|j Ktjtj|jdd}d|j z|z |_|j|jjdjk7rH|j<|j!|j"|j$|j&|j(|jjdj|_ y)z] Initialization delayed until first draw; allow time for axes setup. TNgQ?r=)rKinvertedtransform_bboxrbboxrspanrNclipmathsqrtrr6r?r@rrRrr+rr)r7transsns r:rJz Quiver._init's '')E(77 GMMDIzz!WWTYYtvv.26!DII-2 &&$))*>*>D*>*I*M*MM *  $&&$&&$++F%)YY%9%9t%9%D%H%HD "r;c|j}|j}||z ||z z}|j|j}tj j }|j|d|S)NT)ignore)rYget_offset_transformrcr transformsBboxnullupdate_from_data_xy)r7rmr offset_trffull_transformrrs r: get_datalimzQuiver.get_datalim<sp""$..0 )+ Y0FG  % %dgg .##%   D 1 r;c|j|j|j|j|j|j }|j |dt|!|d|_ y)NF)r) rJrRrr+rr set_vertsr&rbre)r7rfrTr9s r:rbz Quiver.drawEsU   $&&$&&$++F uU+  X r;c rtj|dj}tj|dj}|%tj|dj}td|||fD]Z\}}| |j|j k(r#|jdk(r3t d|d|jd|j dtj|j|jd d }|^tj||jd d }|tjur|j}ntj||d }|jd|_ |jd|_ ||_||j|d|_y) NTcopy)r+rrrz Argument z has a size z which does not match z, the number of arrow positionsF)rshrink)maskr)rmasked_invalidrziprrrmask_orrrMfilledrSr+rrD set_arrayre)r7r+rrnamevarrs r:rzQuiver.set_UVCMsr   ad + 1 1 3   ad + 1 1 3 =!!!$/557A_q!Qi8 CID#K388tvv#5Q 9TF,sxxj#9$&&BB"BCC C zz!&&!&&uTB =::dAFFtDDryy HHJHHQT6!! = NN1  r;c |jj}|jj}tj|j |j z |j |j z tj|jtj|jz |j |j d|jjdjd|S)z:Return a scale factor for converting from units to pixels.?Tr=)xyxyrheightdotsrk)r) rrviewLimrrlrrrNhypotrr?r@)r7rbbvls r:_dots_per_unitzQuiver._dots_per_uniths YY^^ YY  !!BHH$RYY&((BGG$rxx'99XXiiii***599#  r;c|j|j}||_tjj |}|j ||S)zb Set the PolyCollection transform to go from arrow width units to pixels. )rr _trans_scalerAffine2Drr[)r7dxrs r:rKzQuiver._set_transformvsL   ,##%++B/ 5! r;ch|jjj|}tj||f}|jjj|||zz}||z }tj |dddf|dddf} tj |j|z } | | fS)Nrr)rrmrcrNrarctan2rT) r7rr+repsrrFxypdxyrlengthss r:_angles_lengthszQuiver._angles_lengthss YY * *2 . __aV $ii!!++BrM:BhC1Is1a4y1((CEE"S(wr;cj||dzz}t|tr|nd}|dk(r(|jdk(r|j|||d\}}np|dk(s|jdk(r\t j |j jjjdz}|j||||\}}|r|jdk(r} nt j |} |jtdtj|j} |jtj ur| |jj#} n| j#} d| z| z|j$z } |j|j |_ d } nR|jdk(rd}n|j'|j}||j(z } |j  | z|_ | | |j|j*zz z}|j-|\}}|dk(r|}nR|d k(rt j.|}n7tj0t j2|j5d }|j7d }||dzzt j8d|zz|j*z}t j:|j<|j>fd }|jtj ur2tj@|}tjB||j<|S)Ny?rr)rgMbP? g?rrFr)rraxis)" isinstancestrrrrNabsrdataLimextentsmaxrrrrrDrrMmeanrrrr _h_arrowsrrdeg2radrreshapeexpstackrealimagrSmasked)r7rr+rrrF str_anglesrrrrameanrwidthu_per_lenurlengthr)r*thetars r:rRzQuiver._make_vertss!b&j)&#6VB  $"2"2d":#222q!2COFG 4 4#3#3t#;&&**223779EAC"222q!2EOFG $**d2Ar A :: R466*+Bzz*4::+++-%K"$tyy0E    #zz!" !O4'(()9)9: 4#4#44Ozz!"_4 odjj)@AB~~f%1  E 4 HHRLE%%bjj&89@@CE g&!b&jBFF2:. . ; XXrww(q 1 ::RYY &"BYYBtzzN r;cH|j|jz}t|}|j|d}t j |dd|t j d|j |j dgtj}|t j gd|zz}dt j dd|jdgtjz}t j|tjddf|d}t j d||jz ||jz |gtj}dt j dd|jdgtjz}gd }|dd|f} |dd|f} | ddd d fxxd zcc<||} ||} | d d xxxd zccc|d k7r||z nd } | | tjddfz} | | tjddfz} t j||kd d}t j| | |t j| | ||jdk(r| d| ddd tjfzz} n]|jdk(r| | ddd tjfz } n2|jdk7r#tjgd|j||j k}|j#r%t j$dd dtjtj&dz z}t j(||j zdz}t j*||j zdz}t j|tjddf|d}t j|tjddf|d}t j|d d}t j| ||t j| ||| | fS)zLength is in arrow width units.rri)out)rrrrg?Nr)rrrrrrrrrrrEr)whererrr)rrrrg@)rrrrrNrrSrfloat64rrepeatnewaxiscopytorCrrranyrpirOrQ)r7rminshrrrx0y0iir)r*X0Y0rshorttooshortthx1y1X1Y1s r:rzQuiver._h_arrowss]  / K1% 7/ HHa$---&+ZZ ! &/ / "((Aq$..!4bjjA A IIa A & 2 XXq%$"5"55t.78: D 288Q4>>15rzzB B % aeH aeH !QrT' b V V 1RB#(B;%B bQ' ' bQ' ' &5.!!4 !Ru% !Ru% :: ! qArzz)** *A ZZ5 AaBJJ&''A ZZ6 !   8 KDNN* <<>1aBJJ/2553;?Bdnn,s2Bdnn,s2B2bjj!m,aa8B2bjj!m,aa8Byy1a0H IIa8 , IIa8 ,!t r;rs)r)rxryrzr{rr Substitution _quiver_docr'rJrr}r~rbrrrKrrRrrrs@r:rrs",KZ[)qQsqTD6'&*'&RI*   !6  ;z:r;raI Plot a 2D field of wind barbs. Call signature:: barbs([X, Y], U, V, [C], /, **kwargs) Where *X*, *Y* define the barb locations, *U*, *V* define the barb directions, and *C* optionally sets the color. The arguments *X*, *Y*, *U*, *V*, *C* are positional-only and may be 1D or 2D. *U*, *V*, *C* may be masked arrays, but masked *X*, *Y* are not supported at present. Barbs are traditionally used in meteorology as a way to plot the speed and direction of wind observations, but can technically be used to plot any two dimensional vector quantity. As opposed to arrows, which give vector magnitude by the length of the arrow, the barbs give more quantitative information about the vector magnitude by putting slanted lines or a triangle for various increments in magnitude, as show schematically below:: : /\ \ : / \ \ : / \ \ \ : / \ \ \ : ------------------------------ The largest increment is given by a triangle (or "flag"). After those come full lines (barbs). The smallest increment is a half line. There is only, of course, ever at most 1 half line. If the magnitude is small and only needs a single half-line and no full lines or triangles, the half-line is offset from the end of the barb so that it can be easily distinguished from barbs with a single full line. The magnitude for the barb shown above would nominally be 65, using the standard increments of 50, 10, and 5. See also https://en.wikipedia.org/wiki/Wind_barb. Parameters ---------- X, Y : 1D or 2D array-like, optional The x and y coordinates of the barb locations. See *pivot* for how the barbs are drawn to the x, y positions. If not given, they will be generated as a uniform integer meshgrid based on the dimensions of *U* and *V*. If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)`` must match the column and row dimensions of *U* and *V*. U, V : 1D or 2D array-like The x and y components of the barb shaft. C : 1D or 2D array-like, optional Numeric data that defines the barb colors by colormapping via *norm* and *cmap*. This does not support explicit colors. If you want to set colors directly, use *barbcolor* instead. length : float, default: 7 Length of the barb in points; the other parts of the barb are scaled against this. pivot : {'tip', 'middle'} or float, default: 'tip' The part of the arrow that is anchored to the *X*, *Y* grid. The barb rotates about this point. This can also be a number, which shifts the start of the barb that many points away from grid point. barbcolor : :mpltype:`color` or color sequence The color of all parts of the barb except for the flags. This parameter is analogous to the *edgecolor* parameter for polygons, which can be used instead. However this parameter will override facecolor. flagcolor : :mpltype:`color` or color sequence The color of any flags on the barb. This parameter is analogous to the *facecolor* parameter for polygons, which can be used instead. However, this parameter will override facecolor. If this is not set (and *C* has not either) then *flagcolor* will be set to match *barbcolor* so that the barb has a uniform color. If *C* has been set, *flagcolor* has no effect. sizes : dict, optional A dictionary of coefficients specifying the ratio of a given feature to the length of the barb. Only those values one wishes to override need to be included. These features include: - 'spacing' - space between features (flags, full/half barbs) - 'height' - height (distance from shaft to top) of a flag or full barb - 'width' - width of a flag, twice the width of a full barb - 'emptybarb' - radius of the circle used for low magnitudes fill_empty : bool, default: False Whether the empty barbs (circles) that are drawn should be filled with the flag color. If they are not filled, the center is transparent. rounding : bool, default: True Whether the vector magnitude should be rounded when allocating barb components. If True, the magnitude is rounded to the nearest multiple of the half-barb increment. If False, the magnitude is simply truncated to the next lowest multiple. barb_increments : dict, optional A dictionary of increments specifying values to associate with different parts of the barb. Only those values one wishes to override need to be included. - 'half' - half barbs (Default is 5) - 'full' - full barbs (Default is 10) - 'flag' - flags (default is 50) flip_barb : bool or array-like of bool, default: False Whether the lines and flags should point opposite to normal. Normal behavior is for the barbs and lines to point right (comes from wind barbs having these features point towards low pressure in the Northern Hemisphere). A single value is applied to all barbs. Individual barbs can be flipped by passing a bool array of the same size as *U* and *V*. Returns ------- barbs : `~matplotlib.quiver.Barbs` Other Parameters ---------------- data : indexable object, optional DATA_PARAMETER_PLACEHOLDER **kwargs The barbs can further be customized using `.PolyCollection` keyword arguments: %(PolyCollection:kwdoc)s ) barbs_docc veZdZdZej dddddddddd fd Zd d Zd Zdd Z fd Z xZ S)Barbsa> Specialized PolyCollection for barbs. The only API method is :meth:`set_UVC`, which can be used to change the size, orientation, and color of the arrows. Locations are changed using the :meth:`set_offsets` collection method. Possibly this method will be useful in animations. There is one internal function :meth:`_find_tails` which finds exactly what should be put on the barb given the vector magnitude. From there :meth:`_make_barbs` is used to find the vertices of the polygon to represent the barb based on this information. rNFT) rCr barbcolor flagcolorsizes fill_emptybarb_incrementsrounding flip_barbc |xs t|_||_|xs t|_| |_t j | |_| jd|j} ||_ ||_ d||fvr(d| d<|r|| d<n%|r|| d<n| jddn || d<|| d<d| vr d| vrd | d<t| d d i\}}}}}||_||_t j ||f}|jd zd z }t#|Hg|ff|| d| |j't)j*|j-|||y)z The constructor takes one required argument, an Axes instance, followed by the args and kwargs described by the following pyplot interface documentation: %(barbs_doc)s rcNface edgecolorsrr linewidthlwrrbarbsrrrG)r/r;r<r=r>rNrfliprrm_pivot_lengthrrrrrr&r'r[rIdentityTransformr)r7rrCrr9r:r;r<r=r>r?rr8rcrrr]r^cr barb_sizer9s r:r'zBarbs.__init__su_df $.8$&  MM), JJ{BLL9    Iy) )#)F< '0|$'0|$!!,4#,F< #,F<  f $V);"#F; $T?w? 1aA __aV $LLA%)     P&(9 PHN P :779: Q1r;c|r|tj||z z}t||\}}t||\}}||k\}||dkDz|dkDz} |jt|jt|| fS)a Find how many of each of the tail pieces is necessary. Parameters ---------- mag : `~numpy.ndarray` Vector magnitudes; must be non-negative (and an actual ndarray). rounding : bool, default: True Whether to round or to truncate to the nearest half-barb. half, full, flag : float, defaults: 5, 10, 50 Increments for a half-barb, a barb, and a flag. Returns ------- n_flags, n_barbs : int array For each entry in *mag*, the number of flags and barbs. half_flag : bool array For each entry in *mag*, whether a half-barb is needed. empty_flag : bool array For each entry in *mag*, whether nothing is drawn. r)rNarounddivmodastypeint) r7magr>halffullflagn_flagsn_barb half_flag empty_flags r: _find_tailszBarbs._find_tailss0 3:..Cc4( S$' 4K  GaK0FQJ?@ ~~c"FMM#$6 :MMr;c || jddz} || jddz} || jddz}|| jddz}td | d z }d } t|}t j ||tjd z z }td |j}| r|}ntj||dddf}g}tj|D]d\}}||r|j|||fg}|}| |r| n| }t||D]F}||k7r|| d z z }|j|||zg||z||d z z |zg|||z |zgg||| zz}Ht||D]3}|j|||zf||z||z|d z zf|||zfg|| z}5||rR||k(r|j|||zf|d| zz}|j|||zf||d z z||z|dz zf|||zfgt!j"j%| j'|}|j|g|S#t$r||j }YwxYw)a Create the wind barbs. Parameters ---------- u, v Components of the vector in the x and y directions, respectively. nflags, nbarbs, half_barb, empty_flag Respectively, the number of flags, number of barbs, flag for half a barb, and flag for empty barb, ostensibly obtained from :meth:`_find_tails`. length The length of the barb staff in points. pivot : {"tip", "middle"} or number The point on the barb around which the entire barb should be rotated. If a number, the start of the barb is shifted by that many points from the origin. sizes : dict Coefficients specifying the ratio of a given feature to the length of the barb. These features include: - *spacing*: space between features (flags, full/half barbs). - *height*: distance from shaft of top of a flag or full barb. - *width*: width of a flag, twice the width of a full barb. - *emptybarb*: radius of the circle used for low magnitudes. fill_empty : bool Whether the circle representing an empty barb should be filled or not (this changes the drawing of the polygon). flip : list of bool Whether the features should be flipped to the other side of the barb (useful for winds in the southern hemisphere). Returns ------- list of arrays of vertices Polygon vertices for each of the wind barbs. These polygons have been rotated to properly align with the vector direction. spacingg?rg?rg? emptybarbg333333?rEg@)rrr)rr)radiusNrg?r)getr/rrrrrrNr%r get_verts concatenate ndenumerateappendrangeextendrrrotaterc)r7r]r^nflagsnbarbs half_barbrXrrCr;r<rFr[ full_height full_width empty_rad pivot_pointsendxendyrcirc empty_barb barb_listindexr poly_vertsoffset barb_heightis r: _make_barbszBarbs._make_barbssb599Y66uyy377 eii66 UYY{D99 VGbL9  /r=rwrHrGr;r<rrr_offsetsre)r7r+rrrFrJrrr]r^ magnitudeflagsrEhalvesempty plot_barbsrs r:rz Barbs.set_UVCs ""140668""140668 tyy>Q ??499dffll;D99D =!!!$/557A"'"<"<   # Aq!Q4 %Q1aD 9$99    N Aq!Q $Q1a 6HHQN &6d&6&6 t}}'>(,(<(<'>#ufe %%aE5&%&*llDKK&*oot=  z" = NN1 __aV $  r;cv|dddf|_|dddf|_tj|jj |jj |j |j \}}}}t||||tj||f}t|-|d|_ y)z Set the offsets for the barb polygons. This saves the offsets passed in and masks them as appropriate for the existing U/V data. Parameters ---------- xy : sequence of pairs of floats NrrT) rrrrzrr]r^rrNrr& set_offsetsre)r7rrrr]r^r9s r:rzBarbs.set_offsetssAqDAqD// FFLLNDFFLLNDFFDFF< 1a Aq!, __aV $ B r;)Trr2rs) rxryrzr{rinterpdr'rYrwrrrrs@r:r7r7sV $Q$$t%66pN@N`+Zr;r7)"r{rnumpyrNr matplotlibrrrmatplotlib.artistartistr}matplotlib.collections collectionsrWmatplotlib.patchesrmatplotlib.textr#r1matplotlib.transformsrrparamsr4registerArtistr rrrXr _barbs_docr7r;r:rs  ..#-,*rder h {3WWt$.1hL [\ ( ([|GNOG R j1yL ' 'yr;