sequential_layer_facets {tidypaleo} | R Documentation |
Change facet ordering behaviour
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
sequential_layer_facets(reverse = FALSE)
Arguments
reverse |
Use TRUE to process layers in reverse order |
Value
An object that can be added to a ggplot2::ggplot()
Examples
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()
[Package tidypaleo version 0.1.3 Index]