October 2018
Beginner to intermediate
676 pages
18h 30m
English
We have seen a basic stream plot in the previous section. We can control the density and thickness as functions of the speed and color of the stream lines. Here is the code and its output:
# Define the speed as a function of U and Vspeed = np.sqrt (U*U + V*V)# Varying line width along a streamlinelw = 5 * speed / speed.max()strm = plt.streamplot(X, Y, U, V, density=[0.5, 1], color=V, linewidth=lw)plt.colorbar(strm.lines)plt.title('Varying Density, Color and Line Width')plt.show()
np.sqrt(U*U + V*V) defines the speed; line width (lw) is defined as a function of speed.plt.streamplot() draws the stream plot using the parameters supplied. density=[0.5, 1] specifies density values to be used, color=V specifies how the color of ...
Read now
Unlock full access