geometry_stack: Stack objects on top of one another.

Description Usage Arguments Examples

Description

Rects are always stacked upwards from the x-axis, ignoring non-zero y1_.

Usage

1
geometry_stack(geom, dir = c("y", "x"))

Arguments

geom

A geometry data frame.

dir

Direction in which to stack. "x" or "y" for rects, only "y" for smooths, "r" or "theta" for arcs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
bar_ex %>% plot()
bar_ex %>% geometry_stack() %>% plot()

bar_ex %>% geometry_flip() %>% plot()
bar_ex %>% geometry_flip() %>% geometry_stack("x") %>% plot()

# Overlapping bars are stacked on top of each other
df <- data.frame(x = 1:3, y = 1:3)
df %>% render_bar(~x, ~y, 2) %>% plot()
df %>% render_bar(~x, ~y, 2) %>% geometry_stack() %>% plot()

# Stacking ribbons
theta <- seq(0, 2 * pi, length = 50)
df <- data.frame(theta)
waves <- rbind(
  df %>% render_area(~theta, ~abs(sin(theta))),
  df %>% render_area(~theta, ~abs(cos(theta)))
)
waves %>% plot(col = c("red", "black"))
waves %>% geometry_stack() %>% plot(col = c("red", "black"))
df %>% render_area(~theta, ~abs(sin(theta)) + abs(cos(theta))) %>% plot()

# You can also stack arcs, in either r or theta direction
pies <- render_arc(mtcars, ~vs, ~am, 0, 0.1, 0, ~mpg / max(mpg) * 2 / pi)
pies %>% plot()
pies %>% geometry_stack() %>% plot()
pies %>% geometry_stack("r") %>% plot()

disks <- render_arc(mtcars, ~vs, ~am, 0, 0.05, 0, 2 * pi)
disks %>% geometry_stack("r") %>% plot()

rstudio/gggeom documentation built on May 28, 2019, 4:35 a.m.