3

I am trying to make a 3D plot from x, y, z points list, and I want to plot color depending on the values of a fourth variable rho.

Currently I have ;

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot3D(cell_x, cell_y, cell_z, linestyle='None', marker='o', markersize = 5, antialiased=True)
ax.set_xlim3d(0.45, 0.55)
ax.set_ylim3d(0.45, 0.55)
ax.set_zlim3d(0.45, 0.55)

How to add cell_rho (my fourth array) as the color of my x, y, z points ? (for example for a jet colormap).

Thank you very much.

EDIT : I can't use scatter plots because for my 18000 points scatter plots are very slow compared to plot3d with markers only.

3

1 Answer 1

7

If you want to display a simple 3D scatterplot, can't you just use scatter?
E.g.,

x, y, z = randn(100), randn(100), randn(100)
fig = plt.figure()
from mpl_toolkits.mplot3d import Axes3D
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x, y, z, c=randn(100))
plt.show()

(I'm running the above code under python -pylab.)

enter image description here

It seems, on the contrary, that with plot3D you must convert your fourth dimension to RGB tuples.

Sign up to request clarification or add additional context in comments.

1 Comment

My problem is that for my 18000 points scatter plots are way slower than plot3D with markers only...

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.