scale_x_upset: Scale to make UpSet plots

View source: R/scale_upset.R

scale_x_upsetR Documentation

Scale to make UpSet plots

Description

This function takes a list column and turns it into a combination matrix axis. It internally wraps the call to scale_x_mergelist() and axis_combmatrix() and makes sure that the elements are sorted by size.

Usage

scale_x_upset(
  order_by = c("freq", "degree"),
  n_sets = Inf,
  n_intersections = Inf,
  sets = NULL,
  intersections = NULL,
  reverse = FALSE,
  ytrans = "identity",
  ...,
  position = "bottom"
)

Arguments

order_by

either "freq" or "degree". Default: "freq"

n_sets

maximum number of sets that are displayed. Default: Inf

n_intersections

maximum number of intersections that are displayed. Default: Inf

sets

character vector that specifies which sets are displayed

intersections

a list of character vectors that specifies which intersections are displayed

reverse

boolean if the order of the intersections is reversed. Default: FALSE

ytrans

transformers for y axis. For more information see axis_combmatrix(). Default: "identity"

...

additional parameters for ggplot2::discrete_scale()

position

either "top" or "bottom" to specify where the combination matrix is drawn. Default: "bottom"

Examples

library(ggplot2)
ggplot(tidy_movies[1:100, ], aes(x=Genres)) +
  geom_bar() +
  scale_x_upset(reverse = TRUE, sets=c("Drama", "Action"))

 ggplot(tidy_movies[1:100, ], aes(x=Genres)) +
   geom_bar() +
   scale_x_upset(n_intersections = 5, ytrans="sqrt")

 ggplot(tidy_movies[1:100, ], aes(x=Genres, y=year)) +
   geom_boxplot() +
   scale_x_upset(intersections = list(c("Drama", "Comedy"), c("Short"), c("Short", "Animation")),
                 sets = c("Drama", "Comedy", "Short", "Animation", "Horror"))

ggupset documentation built on June 24, 2024, 5:08 p.m.