line_coords: Makes coordinates for a line

Description Usage Arguments Examples

View source: R/heat_tree--shape_generators.R

Description

Generates an n x 2 matrix containing x and y coordinates between 1 and 0 for the points of a line with a specified width in cartesian coordinates.

Usage

1
line_coords(x1, y1, x2, y2, width)

Arguments

x1

(numeric of length 1) x coordinate of the center of one end

y1

(numeric of length 1) y coordinate of the center of one end

x2

(numeric of length 1) x coordinate of the center of the other end

y2

(numeric of length 1) y coordinate of the center of the other end

width

(numeric of length 1) The width of the line.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
library(ggplot2)
ggplot(data = line_coords(x1 = 1, y1 = 1, x2 = 2, y2 = 2, width = .1)) + 
  geom_polygon(aes(x = x, y = y, fill = group))
ggplot(data = line_coords(x1 = rnorm(10), y1 = rnorm(10), x2 = rnorm(10),
                          y2 = rnorm(10), width = rnorm(10)/5)) + 
  geom_polygon(aes(x = x, y = y, fill = group))

## End(Not run)

grunwaldlab/metacoder documentation built on Nov. 30, 2018, 7:53 p.m.