@@ -40,30 +40,40 @@ def create_streamline(
40
40
"""
41
41
Returns data for a streamline plot.
42
42
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
+ --------
60
71
Example 1: Plot simple streamline and increase arrow size
61
72
62
73
>>> from plotly.figure_factory import create_streamline
63
74
>>> import plotly.graph_objects as go
64
75
>>> import numpy as np
65
76
>>> import math
66
-
67
77
>>> # Add data
68
78
>>> x = np.linspace(-3, 3, 100)
69
79
>>> y = np.linspace(-3, 3, 100)
@@ -72,7 +82,6 @@ def create_streamline(
72
82
>>> v = 1 + X - Y**2
73
83
>>> u = u.T # Transpose
74
84
>>> v = v.T # Transpose
75
-
76
85
>>> # Create streamline
77
86
>>> fig = create_streamline(x, y, u, v, arrow_scale=.1)
78
87
>>> fig.show()
@@ -82,7 +91,6 @@ def create_streamline(
82
91
>>> from plotly.figure_factory import create_streamline
83
92
>>> import numpy as np
84
93
>>> import math
85
-
86
94
>>> # Add data
87
95
>>> N = 50
88
96
>>> x_start, x_end = -2.0, 2.0
@@ -92,18 +100,14 @@ def create_streamline(
92
100
>>> X, Y = np.meshgrid(x, y)
93
101
>>> ss = 5.0
94
102
>>> x_s, y_s = -1.0, 0.0
95
-
96
103
>>> # Compute the velocity field on the mesh grid
97
104
>>> u_s = ss/(2*np.pi) * (X-x_s)/((X-x_s)**2 + (Y-y_s)**2)
98
105
>>> v_s = ss/(2*np.pi) * (Y-y_s)/((X-x_s)**2 + (Y-y_s)**2)
99
-
100
106
>>> # Create streamline
101
107
>>> fig = create_streamline(x, y, u_s, v_s, density=2, name='streamline')
102
-
103
108
>>> # Add source point
104
109
>>> point = go.Scatter(x=[x_s], y=[y_s], mode='markers',
105
110
... marker_size=14, name='source point')
106
-
107
111
>>> fig.add_trace(point) # doctest: +SKIP
108
112
>>> fig.show()
109
113
"""
0 commit comments