当前位置: 移动技术网 > IT编程>脚本编程>Python > python 画三维图像 曲面图和散点图的示例

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

2019年01月04日  | 移动技术网IT编程  | 我要评论

马航mh370客机已找到,坐月子可以洗头发吗,mp3播放器代码

用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()

以上这篇python 画三维图像 曲面图和散点图的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网