I want to plot a point with an array using matplotlib, but it fails to read the array for data.
A test case is provided here, where if I use plt.plot([1], [1], [1], 'or')
it works, but if I use plt.plot(Point[0], Point[1], Point[2], 'or')
it fails generating the error:
TypeError: object of type 'numpy.int32' has no len()
Any suggestions?
Thanks for the help!
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()
expects a sequence of points, andPoint[0]
is not a sequence. – cel Nov 13 at 15:04