March 2014
Beginner to intermediate
222 pages
4h 7m
English
Using arrows to represent a vector field works fairly well. But matplotlib can do better than this—it can show the streamlines of a vector field. A streamline shows how the vector field flows. In this recipe, we will show you how to create streamlines.
Let's use the fluid flow example of the previous recipe. We will simply replace the arrows with streamlines, as shown in the following code:
import numpy as np import sympy from sympy.abc import x, y from matplotlib import pyplot as plt import matplotlib.patches as patches def cylinder_stream_function(U = 1, R = 1): r = sympy.sqrt(x ** 2 + y ** 2) theta = sympy.atan2(y, x) return U * (r - R ** 2 / r) * sympy.sin(theta) def velocity_field(psi): ...
Read now
Unlock full access