|
23 | 23 | #' # A pie chart = stacked bar chart + polar coordinates
|
24 | 24 | #' pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
|
25 | 25 | #' geom_bar(width = 1)
|
26 |
| -#' pie + coord_polar(theta = "y") |
| 26 | +#' pie + coord_radial(theta = "y", expand = FALSE) |
27 | 27 | #'
|
28 | 28 | #' \donttest{
|
29 | 29 | #'
|
30 | 30 | #' # A coxcomb plot = bar chart + polar coordinates
|
31 | 31 | #' cxc <- ggplot(mtcars, aes(x = factor(cyl))) +
|
32 | 32 | #' geom_bar(width = 1, colour = "black")
|
33 |
| -#' cxc + coord_polar() |
| 33 | +#' cxc + coord_radial(expand = FALSE) |
34 | 34 | #' # A new type of plot?
|
35 |
| -#' cxc + coord_polar(theta = "y") |
| 35 | +#' cxc + coord_radial(theta = "y", expand = FALSE) |
36 | 36 | #'
|
37 | 37 | #' # The bullseye chart
|
38 |
| -#' pie + coord_polar() |
| 38 | +#' pie + coord_radial(expand = FALSE) |
39 | 39 | #'
|
40 | 40 | #' # Hadley's favourite pie chart
|
41 | 41 | #' df <- data.frame(
|
|
45 | 45 | #' ggplot(df, aes(x = "", y = value, fill = variable)) +
|
46 | 46 | #' geom_col(width = 1) +
|
47 | 47 | #' scale_fill_manual(values = c("red", "yellow")) +
|
48 |
| -#' coord_polar("y", start = pi / 3) + |
| 48 | +#' coord_radial("y", start = pi / 3, expand = FALSE) + |
49 | 49 | #' labs(title = "Pac man")
|
50 | 50 | #'
|
51 | 51 | #' # Windrose + doughnut plot
|
|
56 | 56 | #' doh <- ggplot(movies, aes(x = rrating, fill = budgetq))
|
57 | 57 | #'
|
58 | 58 | #' # Wind rose
|
59 |
| -#' doh + geom_bar(width = 1) + coord_polar() |
| 59 | +#' doh + geom_bar(width = 1) + coord_radial(expand = FALSE) |
60 | 60 | #' # Race track plot
|
61 |
| -#' doh + geom_bar(width = 0.9, position = "fill") + coord_polar(theta = "y") |
| 61 | +#' doh + geom_bar(width = 0.9, position = "fill") + |
| 62 | +#' coord_radial(theta = "y", expand = FALSE) |
62 | 63 | #' }
|
63 | 64 | #' }
|
64 | 65 | coord_polar <- function(theta = "x", start = 0, direction = 1, clip = "on") {
|
|
0 commit comments