scale_x_upset: Scale to make UpSet plots

Description Usage Arguments Examples

View source: R/scale_upset.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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"))

Example output

Warning message:
Removed 33 rows containing non-finite values (stat_count). 
Warning message:
Removed 28 rows containing non-finite values (stat_count). 
Warning message:
Removed 90 rows containing missing values (stat_boxplot). 

ggupset documentation built on July 8, 2020, 7:26 p.m.