render_path: Render paths and path specialisations (line and polygons).

Description Usage Arguments Examples

Description

A polygon is a closed path. A line is path where x values are ordered.

Usage

1
2
3
4
5
6
7
render_path(data, x, y)

render_line(data, x, y)

render_step(data, x, y, direction = c("hv", "vh"))

render_polygon(data, x, y)

Arguments

data

A data frame.

x,y

Formulas specifying x and y positions.

direction

Direction of steps. Either "hv", horizontal then vertical or "vh", vertical then horizontal.

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
# For paths and polygons, the x_ and y_ variables are lists of vectors
# See ?coord for more details
theta <- seq(0, 6*pi, length = 200)
r <- seq(1, 0, length = 200)
df <- data.frame(x = r * sin(theta), y = r * cos(theta))
spiral <- df %>% render_path(~x, ~y)

spiral
str(spiral)
spiral %>% plot()

# Rendering a spiral as a line doesn't work so well
df %>% render_line(~x, ~y) %>% plot()
df %>% render_step(~x, ~y) %>% plot()

# More reasonable example
x <- runif(20)
y <- x ^ 2
squared <- data.frame(x, y)

squared %>% render_path(~x, ~y) %>% plot()
squared %>% render_line(~x, ~y) %>% plot()
squared %>% render_step(~x, ~y) %>% plot()
squared %>% render_step(~x, ~y, "vh") %>% plot()

nz
nz %>% plot()

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