jitter in matplotlib?

Hi all,

I am interested in jittering points in a plot. I searched the forum, but I am amazed at the dearth of results on the topic. I am referring to something like this:

http://goo.gl/Db47s

or

http://goo.gl/BjIZt

Is there a standard way people do this with MPL?

Thanks!

Uri

Uri Laserson
Graduate Student, Biomedical Engineering
Harvard-MIT Division of Health Sciences and Technology
M +1 917 742 8019

laserson@…2396…

I haven't seen this done before so I don't know if there's a standard
way. The idea seems to be to take some points which are real data,
create a random variable for each point with the points' position as
the mean, then choose some number of points from each distribution to
create some new points clustered around the original data. Some
examples online seem to use uniform distributions and Poisson
distributions or mixtures of these (uniform for the x-variable and
Poisson for the y). If my take on this is correct, you can use
scipy.stats to do this - an example is in the attached file which
creates Gaussian distributions for each of the x and y coordinates
then creates an equal number of new points for each of the seed
points. The online examples I saw seem to choose random numbers of new
points for each seed point. I didn't bother trying to cover all the
possibilities. Hopefully this is helpful,

Gary R.

jitter.py (451 Bytes)

···

On Thu, Feb 24, 2011 at 3:04 PM, Uri Laserson <laserson@...1166...> wrote:

Hi all,
I am interested in jittering points in a plot. I searched the forum, but I
am amazed at the dearth of results on the topic. I am referring to
something like this:
http://goo.gl/Db47s
or
http://goo.gl/BjIZt

Is there a standard way people do this with MPL?
Thanks!
Uri
...................................................................................
Uri Laserson
Graduate Student, Biomedical Engineering
Harvard-MIT Division of Health Sciences and Technology
M +1 917 742 8019
laserson@...1166...