Skip to content
Advertisement

How to plot 3D points in Matplotlib

I have a question I have a dataset which contain 1200060 rows and 3 column. column contain points and I have to draw a 3D plot for it. I’m using the code below but I don’t know where is the error.

JavaScript

error is:

JavaScript

I tried this one too but unsuccessful

JavaScript

this one run but didn’t show any output

and using this one same error as the first one

JavaScript

error: ValueError: shape mismatch: objects cannot be broadcast to a single shape

Advertisement

Answer

Either use data1['z'] instead of data1[['z']], or you could even use data1[['z']].values.

Why? Because you want to work with either Series or numpy arrays here, not with DataFrames.

See the difference between:

JavaScript

To be more precise, the underlying issue is that pandas does not know how it is supposed to handle the addition of two differently named columns, as can be seen here:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement