Tutorial

Violin plots

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


# Multiple variables
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",
    colour = brewer.pal(9, "Set1")[seq(3)]
)


# Advanced parameters
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
)

Session information

#> R version 4.2.2 (2022-10-31 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 22621)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=C                   LC_CTYPE=French_France.utf8   
#> [3] LC_MONETARY=French_France.utf8 LC_NUMERIC=C                  
#> [5] LC_TIME=French_France.utf8    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] RColorBrewer_1.1-3 GimmeMyPlot_0.1.0 
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyselect_1.2.0  xfun_0.39         bslib_0.5.1       purrr_1.0.1      
#>  [5] carData_3.0-5     colorspace_2.1-0  vctrs_0.6.2       generics_0.1.3   
#>  [9] htmltools_0.5.5   yaml_2.3.7        utf8_1.2.3        rlang_1.1.1      
#> [13] jquerylib_0.1.4   pillar_1.9.0      ggpubr_0.6.0      glue_1.6.2       
#> [17] withr_2.5.0       tweenr_2.0.2      lifecycle_1.0.3   stringr_1.5.0    
#> [21] munsell_0.5.0     ggsignif_0.6.4    gtable_0.3.4      evaluate_0.21    
#> [25] knitr_1.43        fastmap_1.1.1     fansi_1.0.4       highr_0.10       
#> [29] broom_1.0.5       Rcpp_1.0.10       scales_1.2.1      backports_1.4.1  
#> [33] cachem_1.0.8      jsonlite_1.8.4    abind_1.4-5       farver_2.1.1     
#> [37] ggforce_0.4.1     ggplot2_3.4.3     digest_0.6.31     stringi_1.7.12   
#> [41] rstatix_0.7.2     dplyr_1.1.2       polyclip_1.10-4   grid_4.2.2       
#> [45] cli_3.6.0         tools_4.2.2       magrittr_2.0.3    sass_0.4.7       
#> [49] tibble_3.2.1      tidyr_1.3.0       car_3.1-2         pkgconfig_2.0.3  
#> [53] MASS_7.3-58.1     rmarkdown_2.24    rstudioapi_0.15.0 R6_2.5.1         
#> [57] compiler_4.2.2