以下是使用matplotlib库的Python三维绘图代码示例:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# 创建一个三维坐标轴
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# 生成数据
x = [1, 2, 3, 4, 5]
y = [1, 2, 3, 4, 5]
z = [1, 4, 9, 16, 25]

# 绘制散点图
ax.scatter(x, y, z)

# 设置坐标轴标签
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

# 显示图形
plt.show()

该代码创建了一个三维坐标轴,并通过设置x、y、z轴的数据来绘制散点图。可以根据需要修改数据和图形设置来绘制不同的三维图形。


原文地址: https://www.cveoy.top/t/topic/eTJG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录