You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: How to make a streamline plot in Python. A streamline plot displays
26
+
vector field data.
27
+
display_as: scientific
28
+
has_thumbnail: true
29
+
ipynb: ~notebook_demo/43
30
+
language: python
31
+
layout: user-guide
32
+
name: Streamline Plots
33
+
order: 13
34
+
permalink: python/streamline-plots/
35
+
thumbnail: thumbnail/streamline.jpg
36
+
title: Python Streamline Plots | plotly
37
+
---
38
+
39
+
A Streamline plot is a representation based on a 2-D vector field interpreted as a velocity field, consisting of closed curves tangent to the velocity field. In the case of a stationary velocity field, streamlines coincide with trajectories (see also the [Wikipedia page on streamlines, streaklines and pathlines](https://en.wikipedia.org/wiki/Streamlines,_streaklines,_and_pathlines)).
40
+
41
+
For the streamline figure factory, one needs to provide
42
+
- uniformly spaced ranges of `x` and `y` values (1D)
43
+
- 2-D velocity values `u` and `v` defined on the cross-product (`np.meshgrid(x, y)`) of `x` and `y`.
44
+
45
+
Velocity values are interpolated when determining the streamlines. Streamlines are initialized on the boundary of the `x-y` domain.
46
+
47
+
#### Basic Streamline Plot
48
+
49
+
```python
50
+
import plotly.figure_factory as ff
51
+
52
+
import numpy as np
53
+
54
+
x = np.linspace(-3, 3, 100)
55
+
y = np.linspace(-3, 3, 100)
56
+
Y, X = np.meshgrid(x, y)
57
+
u =-1- X**2+ Y
58
+
v =1+ X - Y**2
59
+
60
+
# Create streamline figure
61
+
fig = ff.create_streamline(x, y, u, v, arrow_scale=.1)
In streamtube plots, attributes inlcude`x`, `y`, and `z`, which set the coordinates of the vector field, and `u`, `v`, and `w`, which sets the x, y, and z components of the vector field. Additionally, you can use `starts` to determine the streamtube's starting position. Lastly, `maxdisplayed` determines the maximum segments displayed in a streamtube.
43
+
In streamtube plots, attributes include`x`, `y`, and `z`, which set the coordinates of the vector field, and `u`, `v`, and `w`, which set the x, y, and z components of the vector field. Additionally, you can use `starts` to determine the streamtube's starting position.
By default, streamlines are initialized in the x-z plane of minimal y value. You can change this behaviour by providing directly the starting points of streamtubes.
59
+
232
60
```python
233
61
import plotly.graph_objects as go
234
62
@@ -273,8 +101,36 @@ fig.update_layout(
273
101
fig.show()
274
102
```
275
103
104
+
### Tube color and diameter
105
+
106
+
The color of tubes is determined by their local norm, and the diameter of the field by the local [divergence](https://en.wikipedia.org/wiki/Divergence) of the vector field.
107
+
108
+
In all cases below the norm is proportional to `z**2` but the direction of the vector is different, resulting in a different divergence field.
0 commit comments