Returns data for a quiver plot. :param (list|ndarray) x: x coordinates of the arrow locations :param (list|ndarray) y: y coordinates of the arrow locations :param (list|ndarray) u: x components of the arrow vectors :param (list|ndarray) v: y components of the arrow vectors
(
x, y, u, v, scale=0.1, arrow_scale=0.3, angle=math.pi / 9, scaleratio=None, **kwargs
)
| 6 | |
| 7 | |
| 8 | def create_quiver( |
| 9 | x, y, u, v, scale=0.1, arrow_scale=0.3, angle=math.pi / 9, scaleratio=None, **kwargs |
| 10 | ): |
| 11 | """ |
| 12 | Returns data for a quiver plot. |
| 13 | |
| 14 | :param (list|ndarray) x: x coordinates of the arrow locations |
| 15 | :param (list|ndarray) y: y coordinates of the arrow locations |
| 16 | :param (list|ndarray) u: x components of the arrow vectors |
| 17 | :param (list|ndarray) v: y components of the arrow vectors |
| 18 | :param (float in [0,1]) scale: scales size of the arrows(ideally to |
| 19 | avoid overlap). Default = .1 |
| 20 | :param (float in [0,1]) arrow_scale: value multiplied to length of barb |
| 21 | to get length of arrowhead. Default = .3 |
| 22 | :param (angle in radians) angle: angle of arrowhead. Default = pi/9 |
| 23 | :param (positive float) scaleratio: the ratio between the scale of the y-axis |
| 24 | and the scale of the x-axis (scale_y / scale_x). Default = None, the |
| 25 | scale ratio is not fixed. |
| 26 | :param kwargs: kwargs passed through plotly.graph_objs.Scatter |
| 27 | for more information on valid kwargs call |
| 28 | help(plotly.graph_objs.Scatter) |
| 29 | |
| 30 | :rtype (dict): returns a representation of quiver figure. |
| 31 | |
| 32 | Example 1: Trivial Quiver |
| 33 | |
| 34 | >>> from plotly.figure_factory import create_quiver |
| 35 | >>> import math |
| 36 | |
| 37 | >>> # 1 Arrow from (0,0) to (1,1) |
| 38 | >>> fig = create_quiver(x=[0], y=[0], u=[1], v=[1], scale=1) |
| 39 | >>> fig.show() |
| 40 | |
| 41 | |
| 42 | Example 2: Quiver plot using meshgrid |
| 43 | |
| 44 | >>> from plotly.figure_factory import create_quiver |
| 45 | |
| 46 | >>> import numpy as np |
| 47 | >>> import math |
| 48 | |
| 49 | >>> # Add data |
| 50 | >>> x,y = np.meshgrid(np.arange(0, 2, .2), np.arange(0, 2, .2)) |
| 51 | >>> u = np.cos(x)*y |
| 52 | >>> v = np.sin(x)*y |
| 53 | |
| 54 | >>> #Create quiver |
| 55 | >>> fig = create_quiver(x, y, u, v) |
| 56 | >>> fig.show() |
| 57 | |
| 58 | |
| 59 | Example 3: Styling the quiver plot |
| 60 | |
| 61 | >>> from plotly.figure_factory import create_quiver |
| 62 | >>> import numpy as np |
| 63 | >>> import math |
| 64 | |
| 65 | >>> # Add data |
no test coverage detected