2

alt text

Is there any module that could aid me in producing something like this?

1
  • These are not density plots, they're scatter plots (as you can tell by the method name in the accepted answer). I'm looking to make 3D density plots which is how I ended up here! Commented Oct 1, 2013 at 17:21

3 Answers 3

6

Like this, say?

matplotlib 3D scatter plot
(source: sourceforge.net)

The matplotlib examples gallery is a wonderful thing to behold.


Code copied from the linked example.

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

def randrange(n, vmin, vmax):
    return (vmax-vmin)*np.random.rand(n) + vmin

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100
for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
    xs = randrange(n, 23, 32)
    ys = randrange(n, 0, 100)
    zs = randrange(n, zl, zh)
    ax.scatter(xs, ys, zs, c=c, marker=m)

ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

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

1 Comment

Very nice answer, that should help him out :-)
3

Adapted from the Cookbook

from numpy import *
import pylab as p
import mpl_toolkits.mplot3d.axes3d as p3

x=random.randn(100)
y=random.randn(100)
z=random.randn(100)

fig=p.figure()
ax = p3.Axes3D(fig)
ax.scatter3D(ravel(x),ravel(y),ravel(z))
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
p.show()

Comments

1

I think matplotlib should be able to do something like that.

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.