# Load data
data("ToothGrowth")
df <- ToothGrowth
# Basic plot with summary statistics: mean_se
# +++++++++++++++++++++++++++
# Change point shapes by groups: "dose"
ggstripchart(df, x = "dose", y = "len",
shape = "dose", size = 3,
add = "mean_se")
# Use mean_sd
# Change error.plot to "crossbar"
ggstripchart(df, x = "dose", y = "len",
shape = "dose", size = 3,
add = "mean_sd", add.params = list(width = 0.5),
error.plot = "crossbar")
# Add summary statistics
# ++++++++++++++++++++++++++
# Add box plot
ggstripchart(df, x = "dose", y = "len",
shape = "dose", add = "boxplot")
# Add violin + mean_sd
ggstripchart(df, x = "dose", y = "len",
shape = "dose", add = c("violin", "mean_sd"))
# Change colors
# +++++++++++++++++++++++++++
# Change colors by groups: dose
# Use custom color palette
ggstripchart(df, "dose", "len", shape = "dose",
color = "dose", palette = c("#00AFBB", "#E7B800", "#FC4E07"),
add = "mean_sd")
# Plot with multiple groups
# +++++++++++++++++++++
# Change shape and color by a second group : "supp"
ggstripchart(df, "dose", "len", shape = "supp",
color = "supp", palette = c("#00AFBB", "#E7B800"))
# Adjust point position
ggstripchart(df, "dose", "len", shape = "supp",
color = "supp", palette = c("#00AFBB", "#E7B800"),
position = position_dodge(0.8) )
# You can also use position_jitterdodge()
# but fill aesthetic is required
ggstripchart(df, "dose", "len", shape = "supp",
color = "supp", palette = c("#00AFBB", "#E7B800"),
position = position_jitterdodge() )
# Add boxplot
ggstripchart(df, "dose", "len", shape = "supp",
color = "supp", palette = c("#00AFBB", "#E7B800"),
add = "boxplot", add.params = list(color = "black") )
Run the code above in your browser using DataLab