脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - python 画三维图像 曲面图和散点图的示例

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

2021-05-09 00:42baoyan2015 Python

今天小编就为大家分享一篇python 画三维图像 曲面图和散点图的示例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

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

散点图

?
1
2
3
4
5
6
7
8
9
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()

曲面图:

?
1
2
3
4
5
6
7
8
9
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 画三维图像 曲面图和散点图的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/baoyan2015/article/details/52805349

延伸 · 阅读

精彩推荐