Visualize the distribution of single or multiple variables using violin plots, boxplots, and sina plots
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
)
A ggplot object.
Vector or data.frame of numerical values visualized on the plot.
Character for the test method ('anova', 'kruskal', or 'wilcox').
Character for the multiple correction test among 'BH', 'BY', 'bonferroni', 'fdr', 'hochberg', 'holm', 'hommel', 'none'
Character for the title.
Integer for the maximum length of the subtitle(s).
Integer for the maximum length of the title.
Color or vector of colors for the violin and boxplot.
Color for the title.
Integer for the transparency of the points (ranging from 0 to 1 for maximum opacity).
Color for the sina points.
Integer for the magnification factor for the points relative to the default.
Integer for the magnification factor for the text relative to the default.
Integer for the magnification factor for the axis labels relative to the default.
Integer for the magnification factor for the subtitles relative to the default.
Integer for the magnification factor for the main title relative to the default.
Boolean to display the results of statistical tests.
Integer for the number of decimals.
Integer for the transparency of the violin plot (ranging from 0 to 1 for maximum opacity)
Integer to multiply the quantiles by.
Integer for the horizontal justification (in [0,1]).
Integer for the line width.
Integer vector of probabilities (in [0,1]).
Character for the subtitle.
Character for the title of the Y-axis.
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
)
Run the code above in your browser using DataLab