render_segment: Render a line segment

Description Usage Arguments Examples

Description

A line segment is a single straight line. render_spoke is an alternative parameterisation in terms of start point, angle and distance.

Usage

1
2
3
render_segment(data, x1, y1, x2, y2)

render_spoke(data, x, y, theta, r)

Arguments

data

A data frame.

x1,y1,x2,y2

Locations of start and end points.

x,y,r,theta

Location of x points, radius and angle.

Examples

1
2
3
4
5
6
7
8
9
df <- expand.grid(x = 1:2, y = 1:2)
a <- render_rect(df, ~x - 0.5, ~y - 0.5, ~x + 0.5, ~y + 0.5)
b <- render_segment(df, ~x - 0.5, ~y - 0.5, ~x + 0.5, ~y + 0.5)

plot(a)
plot(b, add = TRUE, col = "red", lwd = 2)

# Spokes are just an alternative parameterisation
df %>% render_spoke(~x, ~y, ~runif(4, 0, 2 * pi), ~0.25) %>% plot()

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