mirror of
https://github.com/Estom/notes.git
synced 2026-06-28 01:26:12 +08:00
19 lines
423 B
Python
19 lines
423 B
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from mpl_toolkits.mplot3d import Axes3D
|
|
|
|
# 生成数据
|
|
|
|
x = np.arange(-4,4,0.25)
|
|
y = np.arange(-4,4,0.25)
|
|
X,Y = np.meshgrid(x,y)
|
|
R = np.sqrt(X**2+Y**2)
|
|
Z = np.sin(R)
|
|
|
|
# 画图
|
|
|
|
fig = plt.figure()
|
|
ax = Axes3D(fig)
|
|
ax.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap = plt.get_cmap('rainbow'))
|
|
ax.contourf(X, Y, Z, zdir='x', offset=-4, cmap=plt.get_cmap('rainbow'))
|
|
plt.show() |