gf_facet_grid: Add facets to a plot

Description Usage Arguments See Also Examples

View source: R/gf_aux.R

Description

These functions provide more control over faceting than is possible using the formula interface.

Usage

1
2
3
gf_facet_wrap(object, ...)

gf_facet_grid(object, ...)

Arguments

object

A ggplot object

...

Additional arguments passed to facet_wrap() or facet_grid(). This typically includes an unnamed formula argument describing the facets. scales and space are additional useful arguments. See the examples.

See Also

ggplot2::facet_grid(), ggplot2::facet_wrap().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
gf_histogram(~avg_drinks, data = mosaicData::HELPrct) %>%
  gf_facet_grid(~substance)
gf_histogram(~avg_drinks, data = mosaicData::HELPrct) %>%
  gf_facet_grid(~substance, scales = "free")
gf_histogram(~avg_drinks, data = mosaicData::HELPrct) %>%
  gf_facet_grid(~substance, scales = "free", space = "free")
gf_line(births ~ date, data = mosaicData::Births, color = ~wday) %>%
  gf_facet_wrap(~year, scales = "free_x", nrow = 5) %>%
  gf_theme(
    axis.title.x = element_blank(),
    axis.text.x = element_blank(), axis.ticks.x = element_blank()
  ) %>%
  gf_labs(color = "Day")

Example output

Loading required package: ggplot2
Loading required package: ggstance

Attaching package: 'ggstance'

The following objects are masked from 'package:ggplot2':

    GeomErrorbarh, geom_errorbarh


New to ggformula?  Try the tutorials: 
	learnr::run_tutorial("introduction", package = "ggformula")
	learnr::run_tutorial("refining", package = "ggformula")

ggformula documentation built on Jan. 16, 2021, 5:42 p.m.