Skip to content

Jitter options & parameters (for plotting points) #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2016

Conversation

bennn
Copy link
Contributor

@bennn bennn commented Jan 3, 2016

New optional arguments for points and points3d, and new parameters to match.

When > 0, parameters x-jitter, y-jitter, and z-jitter will add random noise to each point along the specified dimension.
New points lie within a rectangle with width x-jitter, height y-jitter, and depth z-jitter centered at each point's original location, but kept within the bounds for x-min, x-max, etc. given to points or points3d.

Inspired by R's ggplot2. I think this is a nice substitute for boxplots and violin plots.

Example:

#lang racket
(require plot)

(plot
 (points (for/list ([_i (in-range 999)])
           (list (* 10 (random)) 2))
         #:alpha 0.4
         #:y-jitter 0.5
         #:sym 'fullcircle1
         #:color "red")
 #:x-min 0 #:x-max 10 #:y-min -5 #:y-max 5)

screen shot 2016-01-03 at 1 28 01 am

When >0, parameters `x-jitter`, `y-jitter`, and `z-jitter` will
 add random noise to each point along the specified dimension.
New points lie within a rectangle with width `x-jitter`, height `y-jitter`, and
 depth `z-jitter` centered at each point's original location, but
 kept within the bounds for x-min, x-max, etc. given to `points` or `points3d`.
@@ -51,6 +54,10 @@ For example, a scatter plot of points sampled uniformly from the surface of a sp

(plot3d (points3d (map vector xs ys zs) #:sym 'dot)
#:altitude 25)]

When @(racket x-jitter), @(racket y-jitter), or @(racket z-jitter) is non-zero,
each point @(racket p) is translated to a random location inside a rectangle centered at @(racket p) with width @(racket x-jitter), height @(racket y-jitter), and depth @(racket z-jitter).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/rectangle/box/ ?

@stamourv
Copy link
Contributor

stamourv commented Jan 3, 2016

I think the docs should mention/discuss use cases. Otherwise, it's not clear when one might want this.
You may also want to hint at when it's even "ok" to do that. Randomly moving data points is (usually) not semantics-preserving! :)

@bennn
Copy link
Contributor Author

bennn commented Jan 3, 2016

Good points, thanks

@samth
Copy link
Member

samth commented Jan 3, 2016

This blog post has a nice example of jitter use: http://kieranhealy.org/blog/archives/2015/02/03/another-look-at-the-california-vaccination-data/

@bennn
Copy link
Contributor Author

bennn commented Jan 3, 2016

Should I add a margin note for this? (and maybe, Typing with Pleasure)

@samth
Copy link
Member

samth commented Jan 3, 2016

Sounds like a good idea.

@bennn
Copy link
Contributor Author

bennn commented Jan 3, 2016

Removed the extreme caution & added the external links.

@stamourv
Copy link
Contributor

stamourv commented Jan 4, 2016

LGTM

bennn added a commit that referenced this pull request Jan 9, 2016
Jitter options & parameters (for plotting points)
@bennn bennn merged commit 7c0ae8b into racket:master Jan 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants