add_grid: Add gridding, arrows, and plotting theme for a cross-stitch...

Description Usage Arguments Value Examples

View source: R/ggplot2_theme.R

Description

Add gridding, arrows, and plotting theme for a cross-stitch plot

Usage

1
2
add_grid(p, x_range = c(0, 100), y_range = c(0, 100), pad = 5,
  center_arrows = TRUE, base_size = 10, base_family = "")

Arguments

p

The plot object to use.

x_range

The range of the x values in the plot. Default is c(0,100), but should be entered per-project.

y_range

The range of the y values in the plot. Default is c(0,100), but should be entered per-project.

pad

Stitch padding to add around the edges of the pattern. Default is 5.

center_arrows

Logical, whether or not to include arrows pointing to the center stitch. Default is TRUE.

base_size

Base font size for the plot theme. Default is 10. See ?ggplot2::theme() for more information.

base_family

Base font family for the plot theme. Default is "", which will use system defaults.

Value

A ggplot2 object with grid, optional arrows, and theme applied.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(ggplot2)

vmat <- floor((volcano - 100)/30)
vdf <- reshape2::melt(vmat)

p <- ggplot() +
  geom_point(data = vdf,
             aes(x = Var1,
                 y = Var2,
                 pch = as.factor(value),
                 color = as.factor(value)))

add_grid(p,
         x_range = c(1,87),
         y_range = c(1,61),
         center_arrows = T)

hypercompetent/xstitch documentation built on July 22, 2019, 10:11 p.m.