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

3D plotting in python

編輯:Python

python3D drawing of

  • 三維表面圖
  • 三維曲線圖
  • 三維曲線

三維表面圖

Draw a 3D surface map Z = sin ⁡ ( x 2 + y 2 ) \text{Draw a 3D surface map}Z=\sin \left( \sqrt{x^2+y^2} \right) Draw a 3D surface mapZ=sin(x2+y2​)

import pylab as plt
import numpy as np
ax=plt.axes(projection="3d")
X=np.arange(-6,6,0.25)
Y=np.arange(-6,6,0.25)
X,Y=np.meshgrid(X,Y)
Z=np.sin(np.sqrt(X**2+Y**2))
surf=ax.plot_surface(X,Y,Z,cmap="coolwarm")
plt.colorbar(surf)
plt.show()

三維曲線圖

Draw a 3D surface graph Z = 50 sin ⁡ ( x + y ) \text{Draw a 3D surface graph}Z=50\sin \left( x+y \right) Draw a 3D surface graphZ=50sin(x+y)

import pylab as plt
import numpy as np
x=np.linspace(-4,4,100)
x,y=np.meshgrid(x,x)
z=50*np.sin(x+y)
ax=plt.axes(projection="3d")
ax.plot_surface(x,y,z,cmap="coolwarm")
plt.show()

三維曲線

Draw a three-dimensional curve x = s 2 sin ⁡ s , y = s 2 cos ⁡ s , s = s , s ∈ [ − 50 , 50 ] \text{Draw a three-dimensional curve}x=s^2\sin s,y=s^2\cos s,s=s,s\in \left[ -50,50 \right] Draw a three-dimensional curvex=s2sins,y=s2coss,s=s,s∈[−50,50]

import pylab as plt
import numpy as np
s=np.linspace(-50,50,1000)
x=s**2*np.sin(s);y=s**2*np.cos(s)
ax=plt.axes(projection="3d")
ax.plot(x,y,s,"k")
plt.show()


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