Preparatory work:
Drawing 3D graphics in python still uses the commonly used drawing module matplotlib, but the mpl_toolkits toolkit needs to be installed. The installation method is as follows: windows command line enters the Scripts folder under python installation directory and executes: pipi 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.
Here is an example.
1, 3D surface shape diagram
This code is to draw a 3D ellipsoid, and the result is as follows:
2. Draw 3D lines (curves)
This code is used to draw spiral 3D curves, and the results are as follows:
3. Draw a three-dimensional outline
The drawing results are as follows:
Related recommendation: Python video tutorial
4. Draw a three-dimensional histogram
The drawing results are as follows:
5. Draw three-dimensional grid lines
The drawing results are as follows:
6. Draw a 3D triangular patch.
The drawing results are as follows:
7. Draw a three-dimensional scatter plot
The drawing results are as follows: