make_tiles: calculate the centre and width/height of a data range.

View source: R/make_tiles.R

make_tilesR Documentation

calculate the centre and width/height of a data range.

Description

Used to help make tiles.

Usage

make_tiles(
  df,
  x_var,
  y_var,
  xstretch = 1.2,
  ystretch = 2,
  add_animation_vars = TRUE
)

Arguments

df

the data frame

x_var, y_var

the variables to be summarised

xstretch, ystretch

how much extra to expand the width and height of the tiles. Set to 1 for no expansion. NB expanding the data range might expand the range of your chart.

add_animation_vars

add a selection of variables to aid tweening?

Examples

data <- data.frame(x1 = runif(10), y2=runif(10))
tiles <- make_tiles(data, x1, y2, ystretch=1, add=FALSE)

library(ggplot2)
ggplot(data, aes(x=x1, y=y2)) +
 geom_tile(data=tiles, aes(width=width, height=height),
   colour="red", fill=NA) + 
 geom_point()

make_tiles(data, x1, y2)

bbcuffer/rcutils documentation built on Nov. 10, 2023, 12:08 p.m.