In python, given a three-dimensional coordinate sequence, use matplotlib to draw a three-dimensional scatter plot

1  # Example: 
2  # First, still need to take coordinates 
. 3  Import numpy NP AS 
# assumption, m is given a three-dimensional scatter sequence
. 4 m = np.array ([[1,. 3,. 3 ], . 5 [. 4, 1 , 6 ], 6 [1, 4, 3 ], 7 [1, 6, 3 ]]) 8 x = [x [0] for x in m] 9 y = [x [1] for x in m] 10 z = [x [2] for x in m] 11 print (x) 12 print(Y) 13 is Print (Z) 14 15 # and normal Paint 16 Import matplotlib.pyplot AS PLT . 17 Import mpl_toolkits.mplot3d 18 is . 19 AX = plt.subplot (Projection = ' 3D ' ) # create a three-dimensional engineering drawing 20 is AX. SET_TITLE ( ' 3d_image_show ' ) # set the name of the present FIG. 21 is ax.scatter (X, Y, Z, C = ' R & lt ' ) # plot the data c: 'r' red, 'y' yellow, color, etc. 22 is 23 is AX. set_xlabel ( ' X ') # Set the x-axis 24 ax.set_ylabel ( ' the Y ' ) # Set y coordinate axes 25 ax.set_zlabel ( ' the Z ' ) # Set z axis 26 is 27 plt.show ()

Guess you like

Origin www.cnblogs.com/cainiaoxuexi2017-ZYA/p/12695421.html