Facets

library(gglite)

Faceting splits data into multiple panels. gglite supports rectangular and circular faceting.

1 Rectangular Facet (by x)

g2(iris, Sepal.Length ~ Sepal.Width) |>
  facet_rect(~ Species)

2 Rectangular Facet (by y)

g2(iris, Sepal.Length ~ Sepal.Width) |>
  facet_rect(y = ~ Species)

3 Rectangular Facet (by x and y)

df = data.frame(
  x = rnorm(200), y = rnorm(200),
  a = sample(c('A', 'B'), 200, replace = TRUE),
  b = sample(c('X', 'Y'), 200, replace = TRUE)
)
g2(df, y ~ x) |>
  facet_rect(b ~ a)

4 Facet with color

g2(iris, Sepal.Length ~ Sepal.Width, color = ~ Species) |>
  facet_rect(~ Species)

5 Circular Facet

g2(iris, Sepal.Length ~ Sepal.Width) |>
  facet_circle(position = ~ Species)