1

I'm stumped as to why this is not working. I am pulling a bunch of floating point data in to a numpy array from a csv file, and I just want to create a 3d scatter plot based from 3 of the columns in the array.

#import data from the csv file
data = np.genfromtxt('data.csv', delimiter=',', dtype=float, skiprows=1)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(data[:,1], data[:,2], data[:,7], c='r', marker='0')
plt.show()

every time i get an assertion error:

/usr/lib/pymodules/python2.7/matplotlib/path.pyc in __init__(self, vertices, codes, _interpolation_steps, closed)
127             codes[-1] = self.CLOSEPOLY
128 
--> 129         assert vertices.ndim == 2
130         assert vertices.shape[1] == 2
131 

AssertionError:

I have... just figured it out, but i'll post this any way because that is the single most useless error message i have ever encountered. the problem was here:

ax.scatter(data[:,1], data[:,2], data[:,7], c='r', marker='0')

marker='0' is invalid, i meant to hit marker='o', once fixed it works just fine.

1
  • Are you really showing the full error message here? Bad error messages are never a good thing. Which matplotlib version is that? If relevant, please report this to the matplotlib project via github. Commented May 11, 2014 at 20:50

1 Answer 1

2

You can use the scatter3D() method of the Axes3DSubplot object:

from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.scatter3D(data[:,1], data[:,2], data[:,7], c='r', marker='0')
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.