Skip to content

Commit 503a5f4

Browse files
committed
update docstring
1 parent 66ffcf9 commit 503a5f4

File tree

1 file changed

+40
-44
lines changed
  • packages/python/plotly/plotly/figure_factory

1 file changed

+40
-44
lines changed

packages/python/plotly/plotly/figure_factory/_quiver.py

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,88 +11,84 @@ def create_quiver(
1111
"""
1212
Returns data for a quiver plot.
1313
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-
14+
Parameters
15+
----------
16+
x : list or ndarray
17+
x coordinates of the arrow locations.
18+
y : list or ndarray
19+
y coordinates of the arrow locations.
20+
u : list or ndarray
21+
x components of the arrow vectors.
22+
v : list or ndarray
23+
y components of the arrow vectors.
24+
scale : float
25+
Scales size of the arrows (ideally to avoid overlap). Must be in the range [0, 1]. Default is 0.1.
26+
arrow_scale : float
27+
Value multiplied to length of barb to get length of arrowhead. Must be in the range [0, 1]. Default is 0.3.
28+
angle : float
29+
Angle of arrowhead in radians. Default is pi/9.
30+
scaleratio : float
31+
The ratio between the scale of the y-axis and the scale of the x-axis (scale_y / scale_x). Must be a positive float. Default is None, meaning the scale ratio is not fixed.
32+
**kwargs
33+
Additional keyword arguments passed through to `plotly.graph_objs.Scatter`. For more information on valid kwargs, call `help(plotly.graph_objs.Scatter)`.
34+
35+
Returns
36+
-------
37+
dict
38+
A representation of the quiver figure.
39+
40+
Examples
41+
--------
3242
Example 1: Trivial Quiver
3343
3444
>>> from plotly.figure_factory import create_quiver
3545
>>> import math
36-
3746
>>> # 1 Arrow from (0,0) to (1,1)
3847
>>> fig = create_quiver(x=[0], y=[0], u=[1], v=[1], scale=1)
3948
>>> fig.show()
4049
41-
4250
Example 2: Quiver plot using meshgrid
4351
4452
>>> from plotly.figure_factory import create_quiver
45-
4653
>>> import numpy as np
4754
>>> import math
48-
4955
>>> # 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
56+
>>> x, y = np.meshgrid(np.arange(0, 2, .2), np.arange(0, 2, .2))
57+
>>> u = np.cos(x) * y
58+
>>> v = np.sin(x) * y
59+
>>> # Create quiver
5560
>>> fig = create_quiver(x, y, u, v)
5661
>>> fig.show()
5762
58-
5963
Example 3: Styling the quiver plot
6064
6165
>>> from plotly.figure_factory import create_quiver
6266
>>> import numpy as np
6367
>>> import math
64-
6568
>>> # Add data
66-
>>> x, y = np.meshgrid(np.arange(-np.pi, math.pi, .5),
67-
... np.arange(-math.pi, math.pi, .5))
68-
>>> u = np.cos(x)*y
69-
>>> v = np.sin(x)*y
70-
69+
>>> x, y = np.meshgrid(np.arange(-np.pi, math.pi, .5), np.arange(-math.pi, math.pi, .5))
70+
>>> u = np.cos(x) * y
71+
>>> v = np.sin(x) * y
7172
>>> # Create quiver
72-
>>> fig = create_quiver(x, y, u, v, scale=.2, arrow_scale=.3, angle=math.pi/6,
73-
... name='Wind Velocity', line=dict(width=1))
74-
73+
>>> fig = create_quiver(x, y, u, v, scale=.2, arrow_scale=.3, angle=math.pi/6, name='Wind Velocity', line=dict(width=1))
7574
>>> # Add title to layout
7675
>>> fig.update_layout(title='Quiver Plot') # doctest: +SKIP
7776
>>> fig.show()
7877
79-
80-
Example 4: Forcing a fix scale ratio to maintain the arrow length
78+
Example 4: Forcing a fixed scale ratio to maintain the arrow length
8179
8280
>>> from plotly.figure_factory import create_quiver
8381
>>> import numpy as np
84-
8582
>>> # Add data
86-
>>> x,y = np.meshgrid(np.arange(0.5, 3.5, .5), np.arange(0.5, 4.5, .5))
83+
>>> x, y = np.meshgrid(np.arange(0.5, 3.5, .5), np.arange(0.5, 4.5, .5))
8784
>>> u = x
8885
>>> v = y
8986
>>> angle = np.arctan(v / u)
9087
>>> norm = 0.25
9188
>>> u = norm * np.cos(angle)
9289
>>> v = norm * np.sin(angle)
93-
94-
>>> # Create quiver with a fix scale ratio
95-
>>> fig = create_quiver(x, y, u, v, scale = 1, scaleratio = 0.5)
90+
>>> # Create quiver with a fixed scale ratio
91+
>>> fig = create_quiver(x, y, u, v, scale=1, scaleratio=0.5)
9692
>>> fig.show()
9793
"""
9894
utils.validate_equal_length(x, y, u, v)

0 commit comments

Comments
 (0)