plotly.figure_factory.create_streamline

plotly.figure_factory.create_streamline(x, y, u, v, density=1, angle=0.3490658503988659, arrow_scale=0.09, **kwargs)

Returns data for a streamline plot.

Parameters
  • x ((list|ndarray)) – 1 dimensional, evenly spaced list or array

  • y ((list|ndarray)) – 1 dimensional, evenly spaced list or array

  • u ((ndarray)) – 2 dimensional array

  • v ((ndarray)) – 2 dimensional array

  • density ((float|int)) – controls the density of streamlines in plot. This is multiplied by 30 to scale similiarly to other available streamline functions such as matplotlib. Default = 1

  • in radians) angle ((angle) – angle of arrowhead. Default = pi/9

  • in [0,1]) arrow_scale ((float) – value to scale length of arrowhead Default = .09

  • kwargs – kwargs passed through plotly.graph_objects.Scatter for more information on valid kwargs call help(plotly.graph_objects.Scatter)

Rtype (dict)

returns a representation of streamline figure.

Example 1: Plot simple streamline and increase arrow size

>>> from plotly.figure_factory import create_streamline
>>> import plotly.graph_objects as go
>>> import numpy as np
>>> import math
>>> # Add data
>>> x = np.linspace(-3, 3, 100)
>>> y = np.linspace(-3, 3, 100)
>>> Y, X = np.meshgrid(x, y)
>>> u = -1 - X**2 + Y
>>> v = 1 + X - Y**2
>>> u = u.T  # Transpose
>>> v = v.T  # Transpose
>>> # Create streamline
>>> fig = create_streamline(x, y, u, v, arrow_scale=.1)
>>> fig.show()

Example 2: from nbviewer.ipython.org/github/barbagroup/AeroPython

>>> from plotly.figure_factory import create_streamline
>>> import numpy as np
>>> import math
>>> # Add data
>>> N = 50
>>> x_start, x_end = -2.0, 2.0
>>> y_start, y_end = -1.0, 1.0
>>> x = np.linspace(x_start, x_end, N)
>>> y = np.linspace(y_start, y_end, N)
>>> X, Y = np.meshgrid(x, y)
>>> ss = 5.0
>>> x_s, y_s = -1.0, 0.0
>>> # Compute the velocity field on the mesh grid
>>> u_s = ss/(2*np.pi) * (X-x_s)/((X-x_s)**2 + (Y-y_s)**2)
>>> v_s = ss/(2*np.pi) * (Y-y_s)/((X-x_s)**2 + (Y-y_s)**2)
>>> # Create streamline
>>> fig = create_streamline(x, y, u_s, v_s, density=2, name='streamline')
>>> # Add source point
>>> point = go.Scatter(x=[x_s], y=[y_s], mode='markers',
...                    marker_size=14, name='source point')
>>> fig.add_trace(point) 
>>> fig.show()