- Matplotlib 3.0 Cookbook
- Srinivasa Rao Poladi
- 79字
- 2021-08-13 15:16:02
How to do it...
The following code block creates a stream plot:
- Prepare the data for the stream plot:
x, y = np.linspace(-3,3,100), np.linspace(-2,4,50)
- Create the mesh grid:
X, Y = np.meshgrid(x, y)
- Compute velocities, U and V, as a function of X and Y respectively:
U = 1 - X**2
V = 1 + Y**2
- Plot the stream plot:
plt.streamplot(X, Y, U, V)
- Set the title for the plot:
plt.title('Basic Streamplot')
- Display the graph on the screen:
plt.show()