Skip to content

Commit 5249afb

Browse files
committed
Update _streamline.py
1 parent a1622bd commit 5249afb

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

packages/python/plotly/plotly/figure_factory/_streamline.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,40 @@ def create_streamline(
4040
"""
4141
Returns data for a streamline plot.
4242
43-
:param (list|ndarray) x: 1 dimensional, evenly spaced list or array
44-
:param (list|ndarray) y: 1 dimensional, evenly spaced list or array
45-
:param (ndarray) u: 2 dimensional array
46-
:param (ndarray) v: 2 dimensional array
47-
:param (float|int) density: controls the density of streamlines in
48-
plot. This is multiplied by 30 to scale similiarly to other
49-
available streamline functions such as matplotlib.
50-
Default = 1
51-
:param (angle in radians) angle: angle of arrowhead. Default = pi/9
52-
:param (float in [0,1]) arrow_scale: value to scale length of arrowhead
53-
Default = .09
54-
:param kwargs: kwargs passed through plotly.graph_objs.Scatter
55-
for more information on valid kwargs call
56-
help(plotly.graph_objs.Scatter)
57-
58-
:rtype (dict): returns a representation of streamline figure.
59-
43+
Parameters
44+
----------
45+
x : list or ndarray
46+
1-dimensional, evenly spaced list or array.
47+
y : list or ndarray
48+
1-dimensional, evenly spaced list or array.
49+
u : ndarray
50+
2-dimensional array representing the x-components of the vector field.
51+
v : ndarray
52+
2-dimensional array representing the y-components of the vector field.
53+
density : float or int
54+
Controls the density of streamlines in the plot. This is multiplied by 30 to scale similarly to other
55+
available streamline functions such as matplotlib. Default is 1.
56+
angle : float
57+
Angle of arrowhead in radians. Default is pi/9.
58+
arrow_scale : float
59+
Value to scale the length of the arrowhead. Default is 0.09.
60+
**kwargs
61+
Additional keyword arguments passed through to `plotly.graph_objs.Scatter`.
62+
For more information on valid kwargs, call `help(plotly.graph_objs.Scatter)`.
63+
64+
Returns
65+
-------
66+
dict
67+
A representation of the streamline figure.
68+
69+
Examples
70+
--------
6071
Example 1: Plot simple streamline and increase arrow size
6172
6273
>>> from plotly.figure_factory import create_streamline
6374
>>> import plotly.graph_objects as go
6475
>>> import numpy as np
6576
>>> import math
66-
6777
>>> # Add data
6878
>>> x = np.linspace(-3, 3, 100)
6979
>>> y = np.linspace(-3, 3, 100)
@@ -72,7 +82,6 @@ def create_streamline(
7282
>>> v = 1 + X - Y**2
7383
>>> u = u.T # Transpose
7484
>>> v = v.T # Transpose
75-
7685
>>> # Create streamline
7786
>>> fig = create_streamline(x, y, u, v, arrow_scale=.1)
7887
>>> fig.show()
@@ -82,7 +91,6 @@ def create_streamline(
8291
>>> from plotly.figure_factory import create_streamline
8392
>>> import numpy as np
8493
>>> import math
85-
8694
>>> # Add data
8795
>>> N = 50
8896
>>> x_start, x_end = -2.0, 2.0
@@ -92,18 +100,14 @@ def create_streamline(
92100
>>> X, Y = np.meshgrid(x, y)
93101
>>> ss = 5.0
94102
>>> x_s, y_s = -1.0, 0.0
95-
96103
>>> # Compute the velocity field on the mesh grid
97104
>>> u_s = ss/(2*np.pi) * (X-x_s)/((X-x_s)**2 + (Y-y_s)**2)
98105
>>> v_s = ss/(2*np.pi) * (Y-y_s)/((X-x_s)**2 + (Y-y_s)**2)
99-
100106
>>> # Create streamline
101107
>>> fig = create_streamline(x, y, u_s, v_s, density=2, name='streamline')
102-
103108
>>> # Add source point
104109
>>> point = go.Scatter(x=[x_s], y=[y_s], mode='markers',
105110
... marker_size=14, name='source point')
106-
107111
>>> fig.add_trace(point) # doctest: +SKIP
108112
>>> fig.show()
109113
"""

0 commit comments

Comments
 (0)