程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python data analysis 10 -- using Matplotlib to draw 3D graphs

編輯:Python

Catalog

3D Three dimensional figure

3D mapping

3D Scatter plot

3D diagram

3D plan


3D Three dimensional figure

Drawing three-dimensional images mainly through mplot3d Module implementation .

from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
%matplotlib notebook

3D mapping

3D Drawing and 2D The method of drawing is basically the same , The difference is , The object of the operation becomes Axes3D() object .

3D Scatter plot

from matplotlib import pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
x = np.random.rand(100)
y = np.random.rand(100)
z = np.random.rand(100)
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(x,y,z,s=10,color="r",marker='o')
plt.show()

3D diagram

from matplotlib import pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
zline = np.linspace(0,15,1000)
xline = np.sin(zline)
yline = np.cos(zline)
fig = plt.figure()
ax = Axes3D(fig)
ax.plot(xline,yline,zline)
plt.show()

3D plan

x = [1,2,3,4]
y = [1,2,3,4]
X, Y = np.meshgrid(x, y)
# Create a canvas
fig = plt.figure()
# establish 3D Coordinate system
ax = Axes3D(fig)
ax.plot_surface(X,
Y,
Z=X+Y
)


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved