sequential_layer_facets: Change facet ordering behaviour

Description Usage Arguments Value Examples

View source: R/ggstrat-plot_addons.R

Description

Normally, facets are ordered using as.factor on all values that occur within layer data, which means that when adding additional layers, any ordering is not preserved unless the factor levels are identical on all factors. This function changes this behaviour such that facet levels are combined in layer order. This is useful when adding standalone layers to a plot without disturbing the existing order.

Usage

1

Arguments

reverse

Use TRUE to process layers in reverse order

Value

An object that can be added to a ggplot2::ggplot()

Examples

1
2
3
4
5
6
7
8
9
library(ggplot2)

p <- ggplot(mapping = aes(x, y)) +
  geom_point(data = data.frame(x = 1:5, y = 1:5, facet = "b")) +
  geom_point(data = data.frame(x = 1:5, y = 1:5, facet = "a")) +
  facet_wrap(vars(facet))

p
p + sequential_layer_facets()

tidypaleo documentation built on April 7, 2021, 5:10 p.m.