python matplotlib 绘制3D曲面图
"""
绘制3D曲面图
"""
import numpy
as np
import matplotlib
.pyplot
as mp
from mpl_toolkits
.mplot3d
import Axes3D
n
= 1000
x
, y
= np
.meshgrid
(np
.linspace
(-3, 3, n
),
np
.linspace
(-3, 3, n
))
z
= (1 - x
/ 2 + x
** 5 + y
** 3) * \
np
.exp
(-x
** 2 - y
** 2)
fig
= mp
.figure
("3D Surface", facecolor
="lightgray")
mp
.title
("3D Surface", fontsize
=18)
ax3d
= Axes3D
(fig
)
ax3d
.set_xlabel
("X")
ax3d
.set_ylabel
("Y")
ax3d
.set_zlabel
("Z")
mp
.tick_params
(labelsize
=10)
ax3d
.plot_surface
(x
, y
, z
, cstride
=20, rstride
=20, cmap
="jet")
mp
.show
()
转载请注明原文地址:https://ipadbbs.8miu.com/read-53785.html