Skip to content
This repository
Newer
Older
100644 51 lines (45 sloc) 1.708 kb
953fe471 »
2010-12-31 Convert all documentation to roxygen
1 #' Jitter points to avoid overplotting.
2 #'
6d18b308 »
2011-12-28 Better docs for position adjustment
3 #' @family position adjustments
b9b3f490 » davidmorrison
2011-07-16 escape percent signs in the roxygen source
4 #' @param width degree of jitter in x direction. Defaults to 40\% of the
953fe471 »
2010-12-31 Convert all documentation to roxygen
5 #' resolution of the data.
b9b3f490 » davidmorrison
2011-07-16 escape percent signs in the roxygen source
6 #' @param height degree of jitter in y direction. Defaults to 40\% of the
953fe471 »
2010-12-31 Convert all documentation to roxygen
7 #' resolution of the data
8 #' @export
9 #' @examples
119b1029 » unknown
2012-01-03 Add aes pages and translate pages
10 #' qplot(am, vs, data = mtcars)
1244716e »
2014-02-24 Trim whitespace
11 #'
12 #' # Default amount of jittering will generally be too much for
953fe471 »
2010-12-31 Convert all documentation to roxygen
13 #' # small datasets:
119b1029 » unknown
2012-01-03 Add aes pages and translate pages
14 #' qplot(am, vs, data = mtcars, position = "jitter")
953fe471 »
2010-12-31 Convert all documentation to roxygen
15 #' # Control the amount as follows
119b1029 » unknown
2012-01-03 Add aes pages and translate pages
16 #' qplot(am, vs, data = mtcars, position = position_jitter(w = 0.1, h = 0.1))
17 #'
18 #' # With ggplot
19 #' ggplot(mtcars, aes(x = am, y = vs)) + geom_point(position = "jitter")
20 #' ggplot(mtcars, aes(x = am, y = vs)) + geom_point(position = position_jitter(w = 0.1, h = 0.1))
1244716e »
2014-02-24 Trim whitespace
21 #'
22 #' # The default works better for large datasets, where it will
62a52745 » JakeRuss
2011-06-24 More examples, added arrow example to geom_path & geom_line, listed m…
23 #' # take up as much space as a boxplot or a bar
c5b872ed »
2012-01-25 Don't test any example that takes over 5 seconds
24 #' qplot(class, hwy, data = mpg, geom = c("boxplot", "jitter"))
1244716e »
2014-02-24 Trim whitespace
25 position_jitter <- function (width = NULL, height = NULL) {
e4b97745 »
2011-12-28 Remove ... from position adjustments
26 PositionJitter$new(width = width, height = height)
ede677cb » JakeRuss
2011-06-28 Removed xxx.r (build_accessor file) and @name tags, added functions t…
27 }
28
61984574 »
2007-11-06 Add ggplot
29 PositionJitter <- proto(Position, {
46c1796d »
2011-01-04 Fix loading problems
30 objname <- "jitter"
1244716e »
2014-02-24 Trim whitespace
31
f267a1db »
2011-05-17 Position adjustments no longer need scales
32 adjust <- function(., data) {
376fb863 »
2009-03-05 New annotation function, plus changes to support it.
33 if (empty(data)) return(data.frame())
61984574 »
2007-11-06 Add ggplot
34 check_required_aesthetics(c("x", "y"), names(data), "position_jitter")
1244716e »
2014-02-24 Trim whitespace
35
5cce66c5 » wch
2012-07-05 Fix jittering resolution calculation. Fixes #572
36 if (is.null(.$width)) .$width <- resolution(data$x, zero = FALSE) * 0.4
37 if (is.null(.$height)) .$height <- resolution(data$y, zero = FALSE) * 0.4
1244716e »
2014-02-24 Trim whitespace
38
d2a6c1e1 »
2008-08-20 position_jitter now jitters all x and y positions
39 trans_x <- NULL
40 trans_y <- NULL
12a14c8c »
2008-08-26 Position cleanup
41 if(.$width > 0) {
42 trans_x <- function(x) jitter(x, amount = .$width)
d2a6c1e1 »
2008-08-20 position_jitter now jitters all x and y positions
43 }
12a14c8c »
2008-08-26 Position cleanup
44 if(.$height > 0) {
45 trans_y <- function(x) jitter(x, amount = .$height)
d2a6c1e1 »
2008-08-20 position_jitter now jitters all x and y positions
46 }
1244716e »
2014-02-24 Trim whitespace
47
d2a6c1e1 »
2008-08-20 position_jitter now jitters all x and y positions
48 transform_position(data, trans_x, trans_y)
61984574 »
2007-11-06 Add ggplot
49 }
1244716e »
2014-02-24 Trim whitespace
50
61984574 »
2007-11-06 Add ggplot
51 })
Something went wrong with that request. Please try again.