【发布时间】:2021-09-21 01:54:18
【问题描述】:
我试图在 3d 空间中表示金字塔的二维数组。在matlab中我可以只使用函数mesh()。但是在python中我很难做到。
import numpy as np
import matplotlib.pyplot as plt
Pyramid = np.zeros([512, 512])
x = Pyramid.shape[0]
y = Pyramid.shape[1]
if x != y:
print("ERROR: 'Not square'")
exit()
for i in range(x // 2):
for j in range(i, x - i):
for h in range(i, x - i):
Pyramid[j, h] = i
fig = plt.figure()
ax = plt.axes(projection="3d")
plt.show()
【问题讨论】:
-
有什么问题或错误?
-
这不是错误。我只是不知道如何在 3d 中表示数组。
标签: python arrays numpy matplotlib 3d