grid_maker {artpack}R Documentation

Data Generation for A Custom-built Square Grid

Description

Creates a dataframe of x and y points to visualize a square grid based on given x and y limits. Providing a color palette and fill style are optional.

Usage

grid_maker(
  xlim,
  ylim,
  size,
  fill_pal = NULL,
  fill_style = "range",
  color_pal = NULL,
  color_style = "range"
)

Arguments

xlim

A numeric vector with two X limits. A minimum and maximum limit for the X axis. Must be a length of 2.

ylim

A numeric vector with two Y limits. A minimum and maximum limit for the Y axis. Must be a length of 2.

size

A numeric input. The size of the grid. How many shapes will appear in a single row or column. Must be a length of 1, greater than 0, and less than or equal to the max xlim and max ylim.

fill_pal

Optional. A character vector of 6 digit hexadecimal webcolor code, or R colors() color strings to be applied to fill the grid.

fill_style

Optional. A character input. "range" or "random". Determines how the fill color palette is mapped.

color_pal

Optional. A character vector of 6 digit hexadecimal webcolor code, or R colors() color strings to be applied to borders of the grid.

color_style

Optional. A character input. "range" or "random". Determines how the border color palette is mapped.

Value

A Tibble

Examples



# Creating data for a grid:

library(ggplot2)
grid_data <- grid_maker(
  xlim = c(0, 50),
  ylim = c(0, 50),
  size = 10,
  fill_pal = c("turquoise", "black", "purple"),
  color_pal = c("black", "limegreen")
)

ggplot() +
  geom_polygon(
    data = grid_data,
    aes(x, y, group = group),
    fill = grid_data$fill,
    color = grid_data$color
  ) +
  coord_equal()


[Package artpack version 0.1.0 Index]