0
我想用matplotlib繪製一個包含數組的點,但是它無法讀取數據的數組。使用matplotlib和Python中的numpy繪製一個3D點
測試用例這裏提供,在這裏如果我使用plt.plot([1], [1], [1], 'or')
它的工作原理,但如果我用plt.plot(Point[0], Point[1], Point[2], 'or')
失敗產生的錯誤:
TypeError: object of type 'numpy.int32' has no len()
有什麼建議?
感謝您的幫助!
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from scipy.spatial import ConvexHull
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_xlim3d(0,3)
ax.set_ylim3d(0,3)
ax.set_zlim3d(0,3)
Point = np.array([1,1,1])
plt.plot([1], [1], [1], 'or')
plt.plot(Point[0], Point[1], Point[2], 'or')
plt.show()
它失敗,因爲'.plot()'需要一個點序列,'Point [0]'不是一個序列。 – cel
請提供它引發的確切錯誤。 –
您能否建議我使用我放入Point中的數據以使其工作?對不起,如果它可能太簡單了,但我真的是新的Python –