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 –