The content of this article is about using matplotlib to draw 3D graphics (code examples) in Python. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. help.
3D graphics are widely used in the fields of data analysis, data modeling, graphics and image processing. The following will introduce to you how to use matplotlib in Python to draw 3D graphics, including 3D scatter. Drawing of points, 3D surfaces, 3D contours, 3D straight lines (curves) and 3D text, etc.
Preparation work:
To draw 3D graphics in python, you still use the commonly used drawing module matplotlib, but you need to install the mpl_toolkits toolkit. The installation method is as follows: enter the python installation directory from the windows command line In the Scripts folder, execute: pip install --upgrade matplotlib; execute this command directly in Linux environment.
After installing this module, you can call the mplot3d class under mpl_tookits to draw 3D graphics.
The following is an example.
1. Drawing of 3D surface shape
2. Drawing of 3D straight lines (curves)
3. Draw 3D contour
4. Draw a 3D histogram
##The drawing results are as follows:
6. Draw 3D triangle patch diagram
##The drawing results are as follows:
7. Draw a 3D scatter plot
The drawing results are as follows:
The above is the detailed content of Python uses matplotlib to draw 3D graphics (code example). For more information, please follow other related articles on the PHP Chinese website!