Learn R Programming

diceplot (version 0.2.0)

dice_plot: Dice Plot Visualization

Description

This function generates a custom plot based on three categorical variables and a group variable. It adapts to the number of unique categories in z and allows customization of various plot aesthetics.

Usage

dice_plot(
  data,
  x = NULL,
  y = NULL,
  z = NULL,
  group = NULL,
  group_alpha = 0.5,
  title = NULL,
  z_colors = NULL,
  group_colors = NULL,
  custom_theme = theme_minimal(),
  max_dot_size = 5,
  min_dot_size = 2,
  legend_width = 0.25,
  legend_height = 0.5,
  base_width_per_x = 0.5,
  base_height_per_y = 0.3,
  reverse_ordering = FALSE,
  cluster_by_row = TRUE,
  cluster_by_column = TRUE,
  show_legend = TRUE,
  cat_a = NULL,
  cat_b = NULL,
  cat_c = NULL,
  cat_c_colors = NULL,
  cat_b_order = NULL,
  base_width_per_cat_a = NULL,
  base_height_per_cat_b = NULL
)

Value

A ggplot object representing the dice plot.

Arguments

data

A data frame containing the categorical and group variables for plotting.

x

A string representing the column name in data for the first categorical variable.

y

A string representing the column name in data for the second categorical variable.

z

A string representing the column name in data for the third categorical variable.

group

A string representing the column name in data for the grouping variable.

group_alpha

A numeric value for the transparency level of the group rectangles. Default is 0.5.

title

An optional string for the plot title. Defaults to NULL.

z_colors

A named vector of colors for z categories or a string to chose a colorbrewer palette. Defaults to NULL using the first suitable colorbrewer palette to use.

group_colors

A named vector of colors for the group variableor a string to chose a colorbrewer palette. Defaults to NULL using the first suitable colorbrewer palette to use.

custom_theme

A ggplot2 theme for customizing the plot's appearance. Defaults to theme_minimal().

max_dot_size

Maximal dot size for the plot to scale the dot sizes.

min_dot_size

Minimal dot size for the plot to scale the dot sizes.

legend_width

Relative width of your legend. Default is 0.25.

legend_height

Relative width of your legend. Default is 0.5.

base_width_per_x

Used for dynamically scaling the width. Default is 0.5.

base_height_per_y

Used for dynamically scaling the height. Default is 0.3.

reverse_ordering

Should the cluster ordering be reversed?. Default is FALSE.

cluster_by_row

Cluster rows, defaults to TRUE

cluster_by_column

Cluster columns, defaults to TRUE

show_legend

Do you want to show the legend? Default is TRUE

cat_a

Deprecated. Use x instead.

cat_b

Deprecated. Use y instead.

cat_c

Deprecated. Use z instead.

cat_c_colors

Deprecated. Use z_colors instead.

cat_b_order

Deprecated. Use cluster_by_row instead. Will be removed in a future version.

base_width_per_cat_a

Deprecated. Use base_width_per_x instead.

base_height_per_cat_b

Deprecated. Use base_height_per_y instead.