axis_combmatrix {ggupset}R Documentation

Convert delimited text labels into a combination matrix axis

Description

The function splits the text based on the sep argument and views each occurring element as potential set.

Usage

axis_combmatrix(
  sep = "[^[:alnum:]]+",
  levels = NULL,
  xlim = NULL,
  ylim = NULL,
  expand = TRUE,
  clip = "on",
  ytrans = "identity"
)

Arguments

sep

The separator that is used to split the string labels. Can be a regex. Default: "[^[:alnum:]]+"

levels

The selection of string elements that are displayed in the combination matrix axis. Default: NULL, which means simply all elements in the text labels are used

xlim, ylim

The limits fort the x and y axes

expand

Boolean with the same effect as in ggplot2::coord_cartesian(). Default: TRUE

clip

String with the same effect as in ggplot2::coord_cartesian(). Default: "on"

ytrans

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

Details

Technically the function appends a coord system to the ggplot object. To maintain compatibility additional arguments like ytrans, ylim, and clip are forwarded to coord_trans().

Note: make sure that the argument to the 'x' aesthetic is character vector that contains the sep sequence. The only exception is if axis_combmatrix() is combined with a scale_x_mergelist(). This pattern works because in the first step scale_x_mergelist() turns a list argument to 'x' into a character vector that axis_combmatrix() can work with.

Examples

  library(ggplot2)
  mtcars$combined <- paste0("Cyl: ", mtcars$cyl, "_Gears: ", mtcars$gear)
  head(mtcars)
  ggplot(mtcars, aes(x=combined)) +
    geom_bar() +
    axis_combmatrix(sep = "_")


[Package ggupset version 0.3.0 Index]