plot_violin {GimmeMyPlot}R Documentation

Violin plot

Description

Visualize the distribution of single or multiple variables using violin plots, boxplots, and sina plots

Usage

plot_violin(
  x,
  method = "anova",
  method_adjust = "BH",
  title = NULL,
  width_text = 20,
  width_title = 20,
  colour = "red",
  color_title = colour,
  pch_alpha = 1,
  pch_colour = "gray50",
  pch_size = cex,
  cex = 1,
  cex_axis = 17 * cex,
  cex_main = 21 * cex,
  cex_sub = 15 * cex,
  stats = TRUE,
  digits = 0,
  alpha = 0.3,
  coef = 1.5,
  hjust = 0.5,
  lwd = 1,
  probs = c(0.25, 0.75),
  subtitle = FALSE,
  ylab = NULL
)

Arguments

x

Vector or data.frame of numerical values visualized on the plot.

method

Character for the test method ('anova', 'kruskal', or 'wilcox').

method_adjust

Character for the multiple correction test among 'BH', 'BY', 'bonferroni', 'fdr', 'hochberg', 'holm', 'hommel', 'none'

title

Character for the title.

width_text

Integer for the maximum length of the subtitle(s).

width_title

Integer for the maximum length of the title.

colour

Color or vector of colors for the violin and boxplot.

color_title

Color for the title.

pch_alpha

Integer for the transparency of the points (ranging from 0 to 1 for maximum opacity).

pch_colour

Color for the sina points.

pch_size

Integer for the magnification factor for the points relative to the default.

cex

Integer for the magnification factor for the text relative to the default.

cex_axis

Integer for the magnification factor for the axis labels relative to the default.

cex_main

Integer for the magnification factor for the subtitles relative to the default.

cex_sub

Integer for the magnification factor for the main title relative to the default.

stats

Boolean to display the results of statistical tests.

digits

Integer for the number of decimals.

alpha

Integer for the transparency of the violin plot (ranging from 0 to 1 for maximum opacity)

coef

Integer to multiply the quantiles by.

hjust

Integer for the horizontal justification (in [0,1]).

lwd

Integer for the line width.

probs

Integer vector of probabilities (in [0,1]).

subtitle

Character for the subtitle.

ylab

Character for the title of the Y-axis.

Value

A ggplot object.

Examples

library(RColorBrewer)

# Default plot
x <- runif(10)
plot_violin(x)

# Advanced parameters
df <- lapply(seq(2), function(x) runif(10))
df <- as.data.frame(df)
df[, 3] <- runif(10, 1, 2)
colnames(df) <- paste0("X", seq(3))
plot_violin(
    df,
    title = "Some random variables",
    color_title = brewer.pal(9, "Set1")[5],
    ylab = "Y-values",
    colour = brewer.pal(9, "Set1")[seq(3)],
    method = "kruskal",
    method_adjust = "none",
    cex = 1.2,
    pch_size = 3,
    width_text = 5,
    pch_colour = "gray30",
    pch_alpha = 0.5,
    width_title = 30,
    lwd = 1.25,
    digits = 2
)


[Package GimmeMyPlot version 0.1.0 Index]