网络编程
位置:首页>> 网络编程>> Python编程>> python 画三维图像 曲面图和散点图的示例

python 画三维图像 曲面图和散点图的示例

作者:baoyan2015  发布时间:2022-04-13 01:28:16 

标签:python,曲面图,散点图

用python画图很多是根据z=f(x,y)来画图的,本博文将三个对应的坐标点输入画图:

散点图:


import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
X = [1, 1, 2, 2]
Y = [3, 4, 4, 3]
Z = [1, 2, 1, 1]
ax.scatter(X, Y, Z)
plt.show()

曲面图:


import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
X = [1, 1, 2, 2]
Y = [3, 4, 4, 3]
Z = [1, 2, 1, 1]
ax.plot_trisurf(X, Y, Z)
plt.show()

来源:https://blog.csdn.net/baoyan2015/article/details/52805349

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com