|
20 | 20 | #' # generate sample data |
21 | 21 | #' library(plyr) |
22 | 22 | #' abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1)) |
23 | | -#' b <- ggplot(abc, aes(x = X1, ymin = "0%", lower = "25%", middle = "50%", upper = "75%", ymax = "100%")) |
| 23 | +#' b <- ggplot(abc, aes(x = X1, ymin = "0%", lower = "25%", |
| 24 | +#' middle = "50%", upper = "75%", ymax = "100%")) |
24 | 25 | #' b + geom_boxplot(stat = "identity") |
25 | 26 | #' |
26 | 27 | #' # Using annotate |
27 | 28 | #' p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() |
28 | | -#' p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25, fill = "dark grey", alpha = .5) |
| 29 | +#' p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25, |
| 30 | +#' fill = "dark grey", alpha = .5) |
29 | 31 | #' |
30 | 32 | #' # Geom_segment examples |
31 | 33 | #' library(grid) |
32 | | -#' p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25), arrow = arrow(length = unit(0.5, "cm"))) |
33 | | -#' p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15), arrow = arrow(length = unit(0.5, "cm"))) |
34 | | -#' p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm"))) |
| 34 | +#' p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25), |
| 35 | +#' arrow = arrow(length = unit(0.5, "cm"))) |
| 36 | +#' p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15), |
| 37 | +#' arrow = arrow(length = unit(0.5, "cm"))) |
| 38 | +#' p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), |
| 39 | +#' arrow = arrow(length = unit(0.5, "cm"))) |
35 | 40 | #' |
36 | 41 | #' # You can also use geom_segment to recreate plot(type = "h") : |
37 | 42 | #' counts <- as.data.frame(table(x = rpois(100, 5))) |
38 | 43 | #' counts$x <- as.numeric(as.character(counts$x)) |
39 | 44 | #' with(counts, plot(x, Freq, type = "h", lwd = 10)) |
40 | 45 | #' |
41 | | -#' qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x, size = I(10)) |
| 46 | +#' qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x, |
| 47 | +#' size = I(10)) |
42 | 48 | NULL |
0 commit comments