Learn R Programming

egg (version 0.4.5)

tag_facet: tag_facet

Description

Adds a dummy text layer to a ggplot to label facets and sets facet strips to blank. This is the typical formatting for some journals that consider facets as subfigures and want to minimise margins around figures.

Usage

tag_facet(p, open = "(", close = ")", tag_pool = letters, x = -Inf,
  y = Inf, hjust = -0.5, vjust = 1.5, fontface = 2, family = "",
  ...)

Arguments

p

ggplot

open

opening character, default: (

close

closing character, default: )

tag_pool

character vector to pick tags from

x

x position within panel, default: -Inf

y

y position within panel, default: Inf

hjust

hjust

vjust

vjust

fontface

fontface

family

font family

...

further arguments passed to geom_text layer

Value

plot with facet strips removed and replaced by in-panel tags

Examples

Run this code
# NOT RUN {
library(ggplot2)
mydf = data.frame(
  x = 1:90,
  y = rnorm(90),
  red = rep(letters[1:3], 30),
  blue = c(rep(1, 30), rep(2, 30), rep(3, 30)))

p <- ggplot(mydf) +
  geom_point(aes(x = x, y = y)) +
  facet_wrap(
    ~ red + blue)
tag_facet(p)
# }

Run the code above in your browser using DataLab