Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中使用matplotlib和带有numpy的数组绘制三维点_Python_Arrays_Numpy_Matplotlib_3d - Fatal编程技术网

在Python中使用matplotlib和带有numpy的数组绘制三维点

在Python中使用matplotlib和带有numpy的数组绘制三维点,python,arrays,numpy,matplotlib,3d,Python,Arrays,Numpy,Matplotlib,3d,我想使用matplotlib使用数组绘制点,但它无法读取数组中的数据 这里提供了一个测试用例,如果我使用plt.plot([1]、[1]、“或”)它可以工作,但是如果我使用plt.plot(点[0]、[1]、[2]、“或”)它无法生成错误: TypeError:类型为“numpy.int32”的对象没有len() 有什么建议吗 谢谢你的帮助 from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from s

我想使用matplotlib使用数组绘制点,但它无法读取数组中的数据

这里提供了一个测试用例,如果我使用
plt.plot([1]、[1]、“或”)
它可以工作,但是如果我使用
plt.plot(点[0]、[1]、[2]、“或”)
它无法生成错误:

TypeError:类型为“numpy.int32”的对象没有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()

正如@cel在评论中所说的那样,图中显示了点的顺序。例如,尝试以下方法:

plt.plot([[1]], [[1]], [[1]], 'or')
plt.plot([Point[0]], [Point[1]], [Point[2]], 'or')

它失败是因为
.plot()
需要一个点序列,而
点[0]
不是一个序列。请提供它引发的确切错误。您能建议我如何使用我在点中输入的数据使其工作吗?抱歉,这可能太简单了,但我对Python真的很陌生