In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "Python+matplotlib how to achieve the volume field drawing". In the daily operation, I believe that many people have doubts about how to achieve the quantity field drawing by Python+matplotlib. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how to realize the quantity field drawing by Python+matplotlib". Next, please follow the editor to study!
1. An overview of the quantity field diagram what is the quantity field diagram?
The quantity field chart is also known as the vibration diagram and the quantity field diagram. Represented by a set of vector arrows
The vector field graph represents one vector corresponding to another vector.
The quantity that forms the field is a vector, which is called a vector field.
Usage scenario of quantum field diagram
Quantum field diagrams are usually used in physics, such as electromagnetic field representation.
The quantity field map is also used to draw geomagnetic maps based on the observed data of various magnetic stations.
The commonly used vector fields in physics are wind field, gravitational field, electromagnetic field, water flow field and so on.
The method of drawing quantity field graph import matplotlib.pyplot as plt plt.quiver () 2. Set the color of the field chart attribute
Vector color keyword: color or facecolor
When facecolor and color are set at the same time, facecolor will be given priority
Value range
English words for color: such as red "red"
Abbreviations for color words such as red "r" and yellow "y"
RGB format: hexadecimal format such as "# 88c999"; (rMagnegMagneb) tuple form
You can also pass in a color list
Set transparency
Keyword: alpha
The value is 0: 1.
Set vector arrowhead size
Keyword: units
Default value is: width
Available values are: {'width',' height', 'dots',' inches','x,'y', 'xy'}
Width,height: represents the width and height of the axis
Dots,inches: pixels or inches based on graphics dpi
Data of the square root of x ^ 2 + y ^ 2)
Set the position of vector arrows in coordinates
Keyword: pivot
Default value is: tail
Value can be: {'tail',' mid', 'middle',' tip'}
Set the width of the vector arrow
Keyword: width
The default value is 0.005
The value is as follows: floating point
3. Steps of drawing quantum field diagram
We also need to use matplotlib.pyplot when drawing the quantum field, so let's take a look at the steps of drawing the quantum field.
Import matplotlib.pyplot CLA
Import matplotlib.pyplot as plt
Use arange (), random (), sin (), cos () and other methods in the numpy library to prepare XPerot y-axis data.
X = np.arange (- 10pc10rem 1) y = np.arange (- 10pje 10rem 1)
Call the numpy.meshgrid () method to generate 2D grid coordinates
UBI v = np.meshgrid (XBI y)
Call pyplot.quiver (xmeny _ rep _ umeno _ v _ c) to draw the quantity field diagram.
Plt.quiver parameter description x one-dimensional or two-dimensional array or sequence, represents the one-dimensional or two-dimensional array or sequence of the arrow position, represents the one-dimensional or two-dimensional array or sequence of the y coordinate u of the arrow position, represents the one-dimensional or two-dimensional array or sequence of the x component v of the arrow vector, represents the one-dimensional or two-dimensional array or sequence of the y component c of the arrow vector, and represents the arrow color.
Call pyplot.show () to render the display icon
Plt.show ()
4. Try a bull's knife
Let's learn the method of drawing the quantum field above. Let's draw an electromagnetic field diagram of the scene in senior high school physics.
Call the numpy.meshgrid () method to generate a two-dimensional list of x _ ray y-axis data
Call numpy.gradient () to generate gradient data for UBI v
A = np.arange, b = np.arange, z = x*np.exp (- x**2-y**2), v, np.gradient, u, np.gradient, plt.quiver, pivot=, tip, units=, inches, plt.scatter, plt.scatter, plt.show, etc. On the "Python+matplotlib how to achieve the volume field drawing" study is over, I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.