OwlCyberSecurity - MANAGER
Edit File: quiver.cpython-38.pyc
U ��]�� � @ s� d Z ddlZddlZddlZddlmZ ddlmZmZm Z ddl mZ ddl mZ ddlmZ ddlmZ ddlmZ dejj ZdZG dd � d ej�Zd d� Zdd � ZG dd� dej�Z dejj Z!ejj"e!d� G dd� dej�Z#dS )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)�cbook� docstring�font_manager)� CirclePolygonaT Plot a 2D field of arrows. Call signature:: quiver([X, Y], U, V, [C], **kw) Where *X*, *Y* define the arrow locations, *U*, *V* define the arrow directions, and *C* optionally sets the color. **Arrow size** 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 defaults give a slightly swept-back arrow; 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. You will probably do best to leave minshaft alone. **Arrow outline** *linewidths* and *edgecolors* can be used to customize the arrow outlines. 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. 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. units : {'width', 'height', 'dots', 'inches', 'x', 'y' 'xy'}, default: 'width' The arrow dimensions (except for *length*) are measured in multiples of this unit. The following values are supported: - 'width', 'height': The width or height of the axis. - '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 arrows scale differently depending on the units. For 'x' or 'y', the arrows get larger as one zooms in; for other units, the arrow size is independent of the zoom state. For 'width or 'height', the arrow size increases with the width and height of the axes, respectively, when the window is resized; for 'dots' or 'inches', resizing does not change the arrows. angles : {'uv', 'xy'} or array-like, optional, default: 'uv' Method for determining the angle of the arrows. - 'uv': The arrow axis aspect ratio is 1 so that if *U* == *V* the orientation of the arrow on the plot is 45 degrees counter-clockwise from the horizontal axis (positive to the right). Use this if the arrows symbolize a quantity that is not based on *X*, *Y* data coordinates. - 'xy': Arrows point from (x,y) to (x+u, y+v). Use this for plotting a gradient field, for example. - Alternatively, 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. Note: inverting a data axis will correspondingly invert the arrows only with ``angles='xy'``. scale : float, optional Number of data units per arrow length unit, e.g., m/s per plot width; a smaller scale parameter makes the arrow longer. Default is *None*. If *None*, a simple autoscaling algorithm is used, 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'}, optional If the *scale* kwarg is *None*, the arrow length unit. Default is *None*. e.g. *scale_units* is 'inches', *scale* is 2.0, and ``(u,v) = (1,0)``, then the vector will be 0.5 inches long. If *scale_units* is 'width' or 'height', then the vector will be half the width/height of the axes. If *scale_units* is 'x' then the vector will be 0.5 x-axis units. 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``. width : float, optional Shaft width in arrow units; 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, optional, default: 3 Head width as multiple of shaft width. headlength : float, optional, default: 5 Head length as multiple of shaft width. headaxislength : float, optional, default: 4.5 Head length at shaft intersection. minshaft : float, optional, 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, optional, 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. pivot : {'tail', 'mid', 'middle', 'tip'}, optional, 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'. color : color or color sequence, 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 ---------------- **kwargs : `~matplotlib.collections.PolyCollection` properties, optional All other keyword arguments are passed on to `.PolyCollection`: %(PolyCollection)s See Also -------- quiverkey : Add a key to a quiver plot. ae Add a key to a quiver plot. Call signature:: quiverkey(Q, X, Y, U, label, **kw) Arguments: *Q*: The Quiver instance returned by a call to quiver. *X*, *Y*: The location of the key; additional explanation follows. *U*: The length of the key *label*: A string with the length and units of the key Keyword arguments: *angle* = 0 The angle of the key arrow. Measured in degrees anti-clockwise from the x-axis. *coordinates* = [ 'axes' | 'figure' | 'data' | 'inches' ] 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*: 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*: Distance in inches between the arrow and the label. Default is 0.1 *labelcolor*: defaults to default :class:`~matplotlib.text.Text` color. *fontproperties*: A dictionary with keyword arguments accepted by the :class:`~matplotlib.font_manager.FontProperties` initializer: *family*, *style*, *variant*, *size*, *weight* Any additional keyword arguments are used to override vector properties taken from *Q*. 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. c @ s� e Zd ZdZddddd�Zddddd�Zddd d d�Zddd ddd d d�dd�Zdd� Ze e_dd� Z dd� Zdd� Ze jdd� �Zdd� Zdd � Zd!d"� Ze Zd S )#� QuiverKeyz3 Labelled arrow for use as a quiver plot scale key.�center�left�right)�N�S�E�WZbottom�top�middle�tip�tailr �axesN皙�����?r )�angle�coordinates�color�labelsep�labelpos� labelcolor�fontpropertiesc s� t j�| � || _|| _|| _|| _|| _|| _|| _ || _ | | _| j|jj j | _t�| �� � fdd�}|jj j�d|�| _| | _|| _|p�t� | _| | _| j}tj|| j| j | j| j tjf |�d�| _ | jd k r�| j �!| j� d| _"|j#d | _#d S )Nc s&