violinPlot | R Documentation |
Produce a quick violin plot with a boxplot inside from a data frame or matrix and if wanted a vector with group membership
violinPlot(df, group=NULL, same=TRUE, missing=TRUE, color="#F4A460", group1="Group1",
group2="Group2", legendLab="Group", title1="Title", numBreaks=10)
df |
vector, data frame or matrix |
group |
variable group (df$variable) |
same |
If you want one plot with all groups set to TRUE, otherwise FALSE |
color |
color when group is NULL (default "#F4A460") |
colorBox |
boxplot color for group (default = "Spectral" from RColorBrewer) |
labList |
default NULL uses factor levels as group membership label.Else list (p.eg c("group1", "group2")) |
legendLab |
Legend title label (default="Group") |
title1 |
Plot title (default=NULL) |
numBreaks |
when there are more than 15 response values breaks are modified for better visualization (default=10) |
plot |
Ariadna Angulo-Brunet (ariadna.angulo@uab.cat), Carme Viladrich
boxPlot
, ggplot2
#generate some random data
x<-1:5
y<-c("Female", "Male")
v1<-sample(x,80,replace=TRUE)
v2<-sample(x,80,replace=TRUE)
v3<-sample(x,80,replace=TRUE)
v4<-sample(x,80,replace=TRUE)
gender<- sample(y, 80, replace=TRUE)
df <- data.frame(v1, v2,v3,v4)
#default plot
violinPlot(df)
#change color
violinPlot(df, color="green")
#by group
violinPlot(df, gender)
#a plot for each group
violinPlot(df, gender, out="rearrange")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.