My Coding >
Programming language >
Python >
Python graphics >
Matplotlib >
Streamplot in Matplotlib
Streamplot in MatplotlibMatplotlib.pyplot.streamplot() in Python is used to visualize 2D vector fields in Python. It is useful to visualise any kind of 2 dimensional vector fields and gradients. I already show an example how to visualise electric field lines visualise electric field lines. But in this article I will give more detailed description of this function. How to use StreamplotTo run Streamplot it is necessary to have coordinates in the domain and values of components of the vector to display, so you need to load libraries first
Then, it is necessary to create coordinates, X and Y, 2Dnumpy arrays, containing x and y coordinates in every cell of your domain
At the nest step, it is necessary to calculate vector field in the projection to x and y basis in every point. For example, let’s create circular movement around center
And at the next step print it out. Base format to call this function is: plt.streamplot(X, Y, Vx, Vy). Optionally it is better to add density of plotted lines and other parameters of the line.
The full code is:
Disadvantages of StreamplotDespite it’s convenience, Streamplot have few disadvantages:
But despite all these disadvantages it is very nice, and simple tool for studying vector fields. Electric field with streamplotI’ve already shown, how to plot electric field intensity with streamlines.

Last 10 artitles
9 popular artitles


© 2020 MyCoding.uk My blog about coding and further learning. This blog was writen with pure Perl and frontend output was performed with TemplateToolkit. 