ggplot2.violinplot: Easy violinplot plot with R package ggplot2

Description Usage Arguments Value Author(s) References See Also Examples

Description

Easy violinplot plot with R package ggplot2

Usage

1
2
3
4
5
ggplot2.violinplot(data, xName = NULL, yName = NULL, groupName = NULL,
  addMean = F, meanPointShape = 5, meanPointSize = 4,
  meanPointColor = "black", meanPointFill = "blue", addDot = FALSE,
  dotSize = 1, dotPosition = c("center", "jitter"), jitter = 0.2,
  groupColors = NULL, brewerPalette = NULL, ...)

Arguments

data

data.frame or a numeric vector. Columns are variables and rows are observations.

xName

The name of column containing x variable (i.e groups). Default value is NULL.

yName

The name of column containing y variable. If yName=NULL, data should be a numeric vector.

groupName

The name of column containing group variable. This variable is used to color plot according to the group.

addMean

if TRUE, the mean point is added on the plot for each group. Default value is FALSE.

meanPointShape

The shape of mean point.

meanPointSize

The size of mean point

meanPointColor

Border color of the mean point. Default value is "black".

meanPointFill

Fill color of mean point. This parameter is used only when meanPointShape=21 to 25. Default value is "blue"

addDot

If TRUE, dotplot is added on the boxplot. Default value is FALSE.

dotSize

The size of dots.

dotPosition

Possible values are "center" and "jitter". Default value is "center".

jitter

Degree of jitter in x direction. Default value is 0.2.

groupColors

Color of groups. groupColors should have the same length as groups.

brewerPalette

This can be also used to indicate group colors. In this case the parameter groupColors should be NULL. e.g: brewerPalette="Paired".

...

Other arguments passed on to ggplot2.customize custom function or to geom_dotplot and to geom_violin functions from ggplot2 package.

Value

a ggplot

Author(s)

Alboukadel Kassambara <alboukadel.kassambara@gmail.com>

References

http://www.sthda.com

See Also

ggplot2.dotplot, ggplot2.boxplot, ggplot2.stripchart, ggplot2.density, ggplot2.histogram

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
df <- ToothGrowth
ggplot2.violinplot(data=df, xName='dose',yName='len',
                mainTitle="Plot of length according\n to the dose",
                xtitle="Dose (mg)", ytitle="Length")

#Or use this
plot<-ggplot2.violinplot(data=df, xName='dose',yName='len')
plot<-ggplot2.customize(plot, mainTitle="Plot of length according\n to the dose",
                        xtitle="Dose (mg)", ytitle="Length")
print(plot)

YTLogos/easyGgplot2 documentation built on May 3, 2019, 9:03 p.m.