0

I'm trying to draw a 3d figure but i get this error(it's not the complete code)

...
...
X = pca1.transform(d1)
fig2 = plot.figure(1,figsize=(10,6))
ax = fig2.gca(projection = '3d')
ax.scatter(X[:,0],X[:,1],X[:,2])
X.show()

Calling x.show()

'numpy.ndarray' object has no attribute 'show'

How can I draw it?

1
  • 3
    What about plot.show()? Commented Mar 26, 2018 at 18:14

1 Answer 1

0

X is a numpy array, type(X) == numpy.ndarray. The error tells you that numpy arrays do not have a show method; which is expected, since it wouldn't be clear how to show them anyways.

For visualization you use matplotlib.pyplot.

If pyplot is imported like import matplotlib.pyplot as plt you can show all plots created with pyplot via

plt.show()

Inside interactive sessions you may also show a figure. In this case,

fig2.show()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.