
    \cg#                        d Z ddlZddlZddlmZ ddlmZmZmZ ddl	m
Z ddlmZ ddlmZ ddlmZ ddlmZ dej,                  j.                  z  Zej,                  j3                  e        G d d	ej4                        Zd
ddZd Z G d dej<                        Zdej,                  j.                  z  Z ej,                  j3                  e         G d dej<                        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)_apicbook
_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 <coordinate-systems>`; 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_unit="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            	            e Zd ZdZdddddZdddddZddd	d
dZddddddddd fd
Zed        Z	d Z
d Zej                  d        Zd Z fdZd Z xZS )	QuiverKeyz2Labelled arrow for use as a quiver plot scale key.centerleftrightNSEWbottomtopmiddletiptailr   axesN皙?r   )anglecoordinatescolorlabelseplabelpos
labelcolorfontpropertieszorderc                H   t         |           || _        || _        || _        || _        || _        || _        || _        || _	        |	| _
        |
| _        || _        |xs
 t               | _        || _        t!        j"                  || j$                  | j                     | j&                  | j                     | j                        | _        | j                  %| j(                  j+                  | j                         d| _        ||| _        y|j.                  dz   | _        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*.
        )texthorizontalalignmentverticalalignmentr    Nr   )super__init__QXYUr   coordr   label_labelsep_inchesr   r   dictr    kwmtextTexthalignvalignr#   	set_color_dpi_at_last_initr!   )selfr(   r)   r*   r+   r-   r   r   r   r   r   r   r    r!   kwargs	__class__s                  L/var/www/html/bid-api/venv/lib/python3.12/site-packages/matplotlib/quiver.pyr'   zQuiverKey.__init__  s    j 	
 


 ( $,6JJ $DMM :"kk$--8..	0	
 ??&II0!% & 2f3    c                 |    | j                   | j                  j                  j                  d      j                  z  S )NTroot)r.   r(   r   
get_figuredpir7   s    r:   r   zQuiverKey.labelsepi  s/    $$tvv{{'='=4'='H'L'LLLr;   c                    	 | j                   j                  | j                   j                  j                  d      j                  k7  r| j                   j                          | j                          t        j                  | j                   | j                  | j                     t        j                        5  | j                  t        j                  t        j                   | j"                              z  }| j                  t        j$                  t        j                   | j"                              z  }| j                   j'                  ddggt        j(                  |g      t        j(                  |g      d      | _        d d d        | j                   j,                  }|j/                  | j0                         t3        j4                  | j*                  f| j6                  | j8                  fg| j;                         d|| _        | j>                  %| j<                  jA                  | j>                         | j<                  jC                  | j                   j;                                | j<                  jE                  | j                                | j                   j                  j                  d      j                  | _        y # 1 sw Y   KxY w)NTr=   )pivotUmask        uvoffsetsoffset_transform)#r(   r6   r   r?   r@   _init_set_transformr   _setattr_cmrC   r   r   nomaskr+   npcosradiansr   sin_make_vertsarrayvertspolykwupdater0   mcollectionsPolyCollectionr)   r*   get_transformvectorr   r5   set_transform
set_figure)r7   uvr8   s       r:   rJ   zQuiverKey._initm  s   vv''466;;+A+At+A+L+P+PP!""466DMM1J)+4 FFRVVBJJtzz$:;;FFRVVBJJtzz$:;;!VV//"b
02!rxx}dT
4 VV]]FMM$''"&55

&&$&&)*!%!3!3!5 	DK
 zz%%%djj1KK%%dff&:&:&<=KK""4??#45%)VV[[%;%;%;%F%J%JD"%4 4s   :CKKc                     d| j                   fd| j                    f| j                   df| j                    dfd| j                     S )Nr   r   )r   r   rA   s    r:   _text_shiftzQuiverKey._text_shift  sR    dmm^$dmm^$==.!$==.!$	

 -- 	r;   c                 `   | j                          | j                  j                  |       | j                         j	                  | j
                  | j                  f      }| j                  j                  || j                         z          | j                  j                  |       d| _
        y )NF)rJ   rZ   drawrY   	transformr)   r*   r#   set_positionr`   stale)r7   rendererposs      r:   rb   zQuiverKey.draw  sz    

"  ",,dffdff-=>		sT%5%5%778		x 
r;   c           	      Z   | j                   j                  j                  d      }| j                  t	        j
                  | j                   j                  j                  | j                   j                  j                  |j                  |j                  d| j                               y )NFr=   )datar   figureinches)r   )r(   r   r?   r[   r   check_getitem	transData	transAxestransFiguredpi_scale_transr,   )r7   figs     r:   rK   zQuiverKey._set_transform  sx    ffkk$$%$04--FFKK))FFKK))oo))	/

 zz# 	$r;   c                 Z    t         |   |       | j                  j                  |       y N)r&   r\   r#   )r7   rq   r9   s     r:   r\   zQuiverKey.set_figure  s"    3		S!r;   c                     | j                  |      rdi fS | j                  j                  |      d   s| j                  j                  |      d   rdi fS di fS )NFr   T)_different_canvasr#   containsrZ   )r7   
mouseevents     r:   rv   zQuiverKey.contains  s]    !!*-"9 IIz*1-$$Z038Obyr;   )__name__
__module____qualname____doc__r3   r4   rC   r'   propertyr   rJ   r`   martistallow_rasterizationrb   rK   r\   rv   __classcell__r9   s   @r:   r
   r
     s    <(gFF%hXFFFCE tc$tLG\ M MK2    !$"r;   r
   function)caller_namec                 l   dx}x}}t        |      }|dk(  rt        j                  | \  }}no|dk(  rt        j                  | \  }}}nS|dk(  rt        j                  | \  }}}}n6|dk(  rt        j                  | \  }}}}}nt        j                  | d|      |j
                  dk(  rd|j                  d	   fn|j                  \  }}	||j                         }|j                         }t        |      |	k(  r/t        |      |k(  r!d
 t        j                  ||      D        \  }}nt        |      t        |      k7  rnt        d|j                   d|j                   d      t        j                  t        j                  |	      t        j                  |            }
d |
D        \  }}|||||fS )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).
    N            zfrom 2 to 5)takesgiven   r   c              3   <   K   | ]  }|j                           y wrs   )ravel.0as     r:   	<genexpr>z_parse_args.<locals>.<genexpr>  s     9'8!AGGI'8s   z-X and Y must be the same size, but X.size is z and Y.size is .c              3   F   K   | ]  }t        j                  |        y wrs   )rN   r   r   s     r:   r   z_parse_args.<locals>.<genexpr>  s     /YYs   !)lenrN   
atleast_1dr   nargs_errorndimshaper   meshgrid
ValueErrorsizearange)r   argsr)   r*   Cnargsr+   Vnrnc	indexgrids              r:   _parse_argsr     s   & AAIEz }}d#1	!--&1a	!]]D)
1a	!t,1aA{-uMM !!a_FB}GGIGGIq6R<CFbL9r{{1a'89DAqVs1v **+&&K L L KK		"ryy}=	/Y/1aAq=r;   c                  r    | D ch c]  }|j                    }}t        |      dk7  rt        d      y c c}w )Nr   z/The shapes of the passed in arrays do not match)r   r   r   )arraysr   
all_shapess      r:   _check_consistent_shapesr     s<    #)*6a!''6J*
:!JKK  +s   4c                        e Zd ZdZdZ ej                  e      ddddddddd	dd
dd fd
       Zd Z	d Z
ej                   fd       ZddZd Zd ZddZd Zd Z xZS )Quiverar  
    Specialized PolyCollection for arrows.

    The only API method is set_UVC(), which can be used
    to change the size, orientation, and color of the
    arrows; their locations are fixed when the class is
    instantiated.  Possibly this method will be useful
    in animations.

    Much of the work in this class is done in the draw()
    method so that as much information as possible is available
    about the plot.  In subsequent draw() calls, recalculation
    is limited to things that might have changed, so there
    should be no performance penalty from putting the calculations
    in the draw() method.
    )r   r   r   Nr   r   g      @r   widthrF   kr   )scale	headwidth
headlengthheadaxislengthminshaft	minlengthunitsscale_unitsanglesr   r   rC   c                   || _         t        |ddi\  }}}}}|| _        || _        t	        j
                  ||f      | _        t        |      | _        || _	        || _
        t        |      | _        || _        || _        || _        || _        |	| _        |
| _        || _        |j)                         dk(  rd}|j)                         | _        t-        j.                  | j0                  | j*                         |j3                  d|j4                        | _        |j9                  d|       |j9                  dd	       t;        | x  g f| j                  | j6                  d
d| || _        | jA                  |||       d| _!        y)z
        The constructor takes one required argument, an Axes
        instance, followed by the args and kwargs described
        by the following pyplot interface documentation:
        %s
        r   quivermidr   rC   rc   
facecolors
linewidths)r   F)rH   rI   closedN)"_axesr   r)   r*   rN   column_stackXYr   r   r   r   floatr   r   r   r   r   r   r   r   lowerrC   r   check_in_list_PIVOT_VALSpoprm   rc   
setdefaultr&   r'   rU   set_UVCr6   )r7   axr   r   r   r   r   r   r   r   r   r   r   rC   r   r8   r)   r*   r+   r   r   r9   s                        r:   r'   zQuiver.__init__  sY    
#T@x@1aA//1a&)Q
"
+, "
&
;;=E!E[[]
4++4::>K>,.,- 	1TWWt~~ %	1)/	1Q1!%r;   c                    	 | j                         }|j                         j                  | j                  j                        j
                  | _        | j
                  Kt        j                  t        j                  | j                        dd      }d| j                  z  |z  | _        | j                  | j                  j                  d      j                  k7  rH| j                  <| j!                  | j"                  | j$                  | j&                  | j(                         | j                  j                  d      j                  | _        y)z]
        Initialization delayed until first draw;
        allow time for axes setup.
        TN      gQ?r=   )rK   invertedtransform_bboxr   bboxr   spanrN   clipmathsqrtr   r6   r?   r@   r   rR   r   r+   r   r   )r7   transsns      r:   rJ   zQuiver._init'  s     '')E(77		GMMDIzz!WWTYYtvv.26!DII-2
 &&$))*>*>D*>*I*M*MM

*  $&&$&&$++F%)YY%9%9t%9%D%H%HD"r;   c                     | j                         }| j                         }||z
  ||z
  z   }|j                  | j                        }t        j
                  j                         }|j                  |d       |S )NT)ignore)rY   get_offset_transformrc   r   
transformsBboxnullupdate_from_data_xy)r7   rm   r   
offset_trffull_transformr   r   s          r:   get_datalimzQuiver.get_datalim<  sp    ""$..0
)+
Y0FG%%dgg.##%  D 1r;   c                     | j                          | j                  | j                  | j                  | j                  | j
                        }| j                  |d       t        | !  |       d| _	        y )NF)r   )
rJ   rR   r   r+   r   r   	set_vertsr&   rb   re   )r7   rf   rT   r9   s      r:   rb   zQuiver.drawE  sU    

  $&&$&&$++FuU+X
r;   c           
      r   t        j                  |d      j                         }t        j                  |d      j                         }|%t        j                  |d      j                         }t        d|||f      D ]Z  \  }}|	|j                  | j
                  k(  r#|j                  dk(  r3t        d| d|j                   d| j
                   d       t        j                  |j                  |j                  d	d
      }|^t        j                  ||j                  d	d
      }|t         j                  u r|j                         }nt        j                  ||d	      }|j                  d      | _        |j                  d      | _        || _        || j                  |       d| _        y )NTcopy)r+   r   r   r   z	Argument z has a size z which does not match z, the number of arrow positionsF)r   shrink)maskr   )r   masked_invalidr   zipr   r   r   mask_orr   rM   filledrS   r+   r   rD   	set_arrayre   )r7   r+   r   r   namevarr   s          r:   r   zQuiver.set_UVCM  sk    ad+113ad+113=!!!$/557A_q!Qi8ID#K388tvv#5Q 9TF,sxxj#9$&& BB"B C C 9 zz!&&!&&uTB=::dAFFtDDryy HHJHHQT6!!
=NN1
r;   c                    | j                   j                  }| j                   j                  }t        j                  |j
                  |j
                  z  |j                  |j                  z  t        j                  |j                   t        j                  |j                   z  |j
                  |j                  d| j                   j                  d      j                  d|      S )z:Return a scale factor for converting from units to pixels.      ?Tr=   )xyxyr   heightdotsrk   )r   )r   r   viewLimr   rl   r   r   rN   hypotr   r?   r@   )r7   r   bbvls       r:   _dots_per_unitzQuiver._dots_per_unith  s    YY^^YY!!BHH$RYY&((BGG$rxx'99XXiiii***599#
  	r;   c                     | j                  | j                        }|| _        t        j                         j                  |      }| j                  |       |S )zb
        Set the PolyCollection transform to go
        from arrow width units to pixels.
        )r   r   _trans_scaler   Affine2Dr   r[   )r7   dxr   s      r:   rK   zQuiver._set_transformv  sL    
   ,##%++B/5!r;   c                 h   | j                   j                  j                  |      }t        j                  ||f      }| j                   j                  j                  |||z  z         }||z
  }t        j
                  |d d df   |d d df         }	t        j                  |j                   |z  }
|	|
fS )Nr   r   )r   rm   rc   rN   r   arctan2r   T)r7   r   r+   r   epsr   rF   xypdxyr   lengthss              r:   _angles_lengthszQuiver._angles_lengths  s    YY  **2.__aV$ii!!++BrM:BhC1Is1a4y1((CEE"S(wr;   c                 j   ||dz  z   }t        |t              r|nd}|dk(  r(| j                  dk(  r| j                  |||d      \  }}np|dk(  s| j                  dk(  r\t	        j
                  | j                  j                  j                        j                         dz  }| j                  ||||      \  }}|r| j                  dk(  r}	nt	        j
                  |      }	| j                  t        dt        j                  | j                              }
| j                  t        j                   ur|	| j                      j#                         }n|	j#                         }d|z  |
z  | j$                  z  }| j                  | j                  | _
        d	}nR| j                  dk(  rd}n| j'                  | j                        }|| j(                  z  }| j                  
|z  | _
        |	|| j                  | j*                  z  z  z  }| j-                  |      \  }}|dk(  r|}nR|d
k(  rt	        j.                  |      }n7t        j0                  t	        j2                  |            j5                  d      }|j7                  d      }||dz  z   t	        j8                  d|z        z  | j*                  z  }t	        j:                  |j<                  |j>                  fd      }| j                  t        j                   ur2t        j@                  |      }t        jB                  || j                  <   |S )Ny              ? r   r   )r   gMbP?
   g?r   rF   r   )r   r   axis)"
isinstancestrr   r  rN   absr   dataLimextentsmaxr   r   r   r   rD   r   rM   meanr   r   r   r   	_h_arrowsr   r   deg2radr   reshapeexpstackrealimagrS   masked)r7   r   r+   r   r   rF   
str_anglesr  r   r   r   ameanr   widthu_per_lenur   lengthr)   r*   thetar   s                       r:   rR   zQuiver._make_verts  s   !b&j)&#6VB
$"2"2d": #222q!2COFG44#3#3t#; &&**223779EAC"222q!2EOFG$**d2Ar
A::R466*+Bzz*4::+++- %K"$tyy0E#zz!"
!O4'(()9)9: 4#4#44Ozz!"_4
odjj)@AB~~f%1E4HHRLE%%bjj&89@@CEg&!b&jBFF2:..;XXrww(q1::RYY&"BYYBtzzN 	r;   c                 H   | j                   | j                  z  }t        |      }|j                  |d      }t	        j
                  |dd|       t	        j                  d| j                   | j                   dgt        j                        }|t	        j                  g d      |z  z   }dt	        j                  dd| j                  dgt        j                        z  }t	        j                  |t        j                  ddf   |d      }t	        j                  d|| j                  z
  || j                  z
  |gt        j                        }dt	        j                  dd| j                  dgt        j                        z  }g d	}|dd|f   }	|dd|f   }
|
ddd
dfxx   dz  cc<   ||   }||   }|d
dxxx dz  ccc |dk7  r||z  nd}||t        j                  ddf   z  }||t        j                  ddf   z  }t	        j                  ||k  dd      }t	        j                  |	||       t	        j                  |
||       | j                  dk(  r|	d|	ddd
t        j                  f   z  z  }	n]| j                  dk(  r|	|	ddd
t        j                  f   z
  }	n2| j                  dk7  r#t        j                  g d| j                         || j                   k  }|j#                         r%t	        j$                  dddt        j                        t        j&                  dz  z  }t	        j(                  |      | j                   z  dz  }t	        j*                  |      | j                   z  dz  }t	        j                  |t        j                  ddf   |d      }t	        j                  |t        j                  ddf   |d      }t	        j                  |dd      }t	        j                  |	||       t	        j                  |
||       |	|
fS )zLength is in arrow width units.r   r   i   )out)r   r   r   r   g      ?Nr  )r   r   r   r   r   r   r   r   r   r  rE   r   )wherer   r   r   )r   r   r   r   g      @)r   r   r   r  rN   r   rS   r   float64r   repeatnewaxiscopytorC   r   r   r   anyr   pirO   rQ   )r7   r  minshr   r   r   x0y0iir)   r*   X0Y0r   shorttooshortthx1y1X1Y1s                        r:   r  zQuiver._h_arrows  s]   
 /K1% 	7/HHa$---&+ZZ! &//"((Aq$..!4bjjAAIIa

A&2XXq%$"5"55t.78:

D288Q4>>15rzzBB%aeHaeH	!QrT'
b
VV
1RB#(B;%BbQ''bQ''		&5.!!4
		!Ru%
		!Ru%::!qArzz)***AZZ5  AaBJJ&''AZZ6!8

KDNN*<<>1aBJJ/2553;?Bdnn,s2Bdnn,s2B2bjj!m,aa8B2bjj!m,aa8Byy1a0HIIa8,IIa8,!tr;   rs   )r   )rx   ry   rz   r{   r   r   Substitution_quiver_docr'   rJ   r   r}   r~   rb   r   r   rK   r  rR   r  r   r   s   @r:   r   r     s    " ,KZ[)qQsqTD6'& *'&RI*    !6	;z:r;   r   aI  
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                   v     e Zd ZdZej
                  dddddddddd	 fd
       Zdd	Zd
 ZddZ	 fdZ
 xZ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.
    r      NFT)	rC   r  	barbcolor	flagcolorsizes
fill_emptybarb_incrementsrounding	flip_barbc       	            |xs
 t               | _        || _        |xs
 t               | _        |	| _        t        j                  |
      | _        |j                  d|j                        }|| _
        || _        d||fv r(d|d<   |r||d<   n%|r||d<   n|j                  dd       n
||d<   ||d<   d|vr	d|vrd	|d<   t        |d
di\  }}}}}|| _        || _        t        j                   ||f      }| j                  dz  dz  }t#        | H  g |ff||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
        rc   Nface
edgecolorsr   r   	linewidthlwr   r   barbsr   r   rG   )r/   r;  r<  r=  r>  rN   r   flipr   rm   _pivot_lengthr   r   r   r   r   r&   r'   r[   r   IdentityTransformr   )r7   r   rC   r  r9  r:  r;  r<  r=  r>  r?  r   r8   rc   r   r   r]   r^   cr   	barb_sizer9   s                        r:   r'   zBarbs.__init__  su    _df
$.8$& MM),	JJ{BLL9	 Iy))#)F< '0|$'0|$ !!,4#,F< #,F<  f$V);"#F; $T?w?1aA__aV$ LLA%)		P&(9	PHN	P:779:Q1r;   c                     |r|t        j                  ||z        z  }t        ||      \  }}t        ||      \  }}||k\  }||dkD  z  |dkD  z   }	|j                  t              |j                  t              ||	fS )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   )rN   arounddivmodastypeint)
r7   magr>  halffullflagn_flagsn_barb	half_flag
empty_flags
             r:   _find_tailszBarbs._find_tails  s    0 3:..Cc4(S$'4K	 GaK0FQJ?@
~~c"FMM#$6	:MMr;   c           	          ||	j                  dd      z  }||	j                  dd      z  }||	j                  dd      z  }||	j                  dd      z  }t        d	| d
z        }d	}	 t        |      }t        j                  ||      t        j                  dz  z    }t        d|      j                         }|
r|}nt        j                  ||ddd   f      }g }t        j                  |      D ]d  \  }}||   r|j                  |       ||fg}|}||   r| n|}t        ||         D ]F  }||k7  r||d
z  z  }|j                  |||z   g||z   ||dz  z
  |z   g|||z
  |z   gg       |||z   z  }H t        ||         D ]3  }|j                  |||z   f||z   ||z   |dz  z   f|||z   fg       ||z  }5 ||   rR||k(  r|j                  |||z   f       |d|z  z  }|j                  |||z   f||dz  z   ||z   |dz  z   f|||z   fg       t!        j"                         j%                  |       j'                  |      }|j                  |       g |S # t        $ r ||j	                            }Y w xY w)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      ?r   g?r   g      ?	emptybarbg333333?rE   g       @)r   r   r   )r   r   )radiusNr  g      ?r   )getr/   r   r   r   r   r   rN   r%  r   	get_vertsconcatenatendenumerateappendrangeextendr   r   rotaterc   )r7   r]   r^   nflagsnbarbs	half_barbrX  r  rC   r;  r<  rF  r[  full_height
full_width	empty_radpivot_pointsendxendyr   circ
empty_barb	barb_listindexr   
poly_vertsoffsetbarb_heightis                                r:   _make_barbszBarbs._make_barbs  s   b 599Y66uyy377eii66
UYY{D99	 VGbL9	/<D ::a#beeai/0 VI6@@BJ tDbDz(:;J	NN62LE5 %    ,,JF +/u+;,;K 6%=) V#gl*F!!D6M*[($a*?&*HID:-679:
 *w.. *  6%=)!!D6M*[($-*q.*HID6M*,-
 '! *  V#%%tTF]&;<cGm+F!!D6M*[1_,dVmj1n.LMD6M*,- $,,.55uf=GGJZ(u 3x e  	/.D	/s   )I I=<I=c                 R   t        j                  |d      j                         | _        t        j                  |d      j                         | _        t        | j                        dk(  r5t        j                  | j                  | j                  j                        }n| j                  }|t        j                  |d      j                         }t        j                  | j                  j                         | j                  j                         | j                  | j                  ||j                               \  }}}}	}}t        ||||	||       nt        j                  | j                  j                         | j                  j                         | j                  | j                  |j                               \  }}}}	}t        ||||	|       t        j                  ||	      }
 | j                   |
| j"                  fi | j$                  \  }}}}| j'                  ||	||||| j(                  | j*                  | j,                  | j.                  |      }| j1                  |       || j3                         t        j4                  ||f      }|| _        d| _        y )NTr   r   )r   r   r   r]   r^   r   rF  rN   broadcast_tor   r   delete_masked_pointsr   r   r   r   rY  r>  r=  rw  rH  rG  r;  r<  r   r   r   _offsetsre   )r7   r+   r   r   rF  rJ  r   r   r]   r^   	magnitudeflagsrE  halvesempty
plot_barbsr   s                    r:   r   zBarbs.set_UVC  s    ""140668""140668
 tyy>Q??499dffll;D99D=!!!$/557A"'"<"<

#Aq!Q4 %Q1aD9$99

 NAq!Q$Q1a6HHQN	&6d&6&6t}}'>(,(<(<'>#ufe
 %%aE5&%&*llDKK&*oot=
 	z" =NN1 __aV$
r;   c                 v   |dddf   | _         |dddf   | _        t        j                  | j                   j	                         | j                  j	                         | j
                  | j                        \  }}}}t        ||||       t        j                  ||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
        Nr   r   T)r   r   r   rz  r   r]   r^   r   rN   r   r&   set_offsetsre   )r7   r   r   r   r]   r^   r9   s         r:   r  zBarbs.set_offsets  s     AqDAqD//FFLLNDFFLLNDFFDFF<
1a Aq!,__aV$B
r;   )Tr   r  2   rs   )rx   ry   rz   r{   r   interpdr'   rY  rw  r   r  r   r   s   @r:   r7  r7    sV    $ Q$$t%6 6pN@N`+Z r;   r7  )"r{   r   numpyrN   r   
matplotlibr   r   r   matplotlib.artistartistr}   matplotlib.collectionscollectionsrW   matplotlib.patchesr   matplotlib.textr#   r1   matplotlib.transformsr   r  paramsr4  registerArtistr
   r   r   rX   r   
_barbs_docr7   r;   r:   <module>r     s        . . # - ,  *rd er h     {  3W Wt $. 1hL[\(( [|GN OG 
R     j  1yL'' yr;   