Get the App
SLTechnology News&Howtos  ›  Development  › 

How to draw 3D graphics by python Axes3D

Shulou Source: shulou.com Published: 2022-06-03 17:42:00 09月11日 Update

Editor to share with you how to draw 3D graphics in python Axes3D. I hope you will get something after reading this article. Let's discuss it together.

Description

1. Axes3D, a function for drawing 3D coordinates.

Create a drawing object and use this drawing object to create an Axes object.

2. X axis-2 to 2, Y axis-2 to 2.

Draw the lattice on the plane with the points on the two axes, the square sum of X and Y and the root sign.

3. Calculate the sin function and assign it to Z coordinate.

Specific function methods can be viewed with help (function).

4. Indicate the three axes.

Example

#-*-coding: utf-8-*-# By:Eastmount CSDNfrom matplotlib import pyplot as pltimport numpy as npfrom mpl_toolkits.mplot3d import Axes3D # function for drawing 3D coordinates fig = plt.figure () # create a drawing object ax = Axes3D (fig) # create an Axes object X = np.arange (- 2,2) with this drawing object Y = np.arange (- 2,2,0.25) # Y axis-2 to 2 print (Y) X, Y = np.meshgrid (X) Y) # use points on two axes to draw the lattice R = np.sqrt (X-axis 2 + Y-axis 2) # the sum of squares of X and Y, the open root sign Z = np.sin (R) # calculate the sin function assignment to the Z coordinate # the specific function method can be viewed by help (function) For example: help (ax.plot_surface) ax.plot_surface (X, Y, Z, rstride=1, cstride=1, cmap='rainbow') # Mark the three axes ax.set_xlabel ('xlabel', color='r') ax.set_ylabel ('ylabel', color='g') ax.set_zlabel ('zlabel', color='b') plt.show () after reading this article, I believe you have some understanding of "how python Axes3D draws 3D graphics" If you want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

Tags: Coordinates functions objects between axes drawings graphics three two square sum plane method root article done examples more knowledge industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Information Redmi Apple Microsoft