Add summary statistics or a geometry onto a ggplot.
ggadd(p, add = NULL, color = "black", fill = "white", width = 1,
shape = 19, size = NULL, alpha = 1, jitter = 0.2, binwidth = NULL,
dotsize = size, error.plot = "pointrange", data = NULL,
position = position_dodge(0.8), p_geom = "")
a ggplot
character vector specifying other plot elements to be added. Allowed values are one or the combination of: "none", "dotplot", "jitter", "boxplot", "point", "mean", "mean_se", "mean_sd", "mean_ci", "mean_range", "median", "median_iqr", "median_mad", "median_range".
point or outline color.
fill color. Used only when error.plot = "crossbar"
.
numeric value between 0 and 1 specifying bar or box width.
Example width = 0.8. Used only when error.plot
is one of
c("crossbar", "errorbar").
point shape. Allowed values can be displayed using the function
show_point_shapes()
.
numeric value in [0-1] specifying point and line size.
numeric value specifying fill color transparency. Value should be in [0, 1], where 0 is full transparency and 1 is no transparency.
a numeric value specifying the amount of jittering. Used only
when add
contains "jitter".
numeric value specifying bin width. use value between 0 and 1
when you have a strong dense dotplot. For example binwidth = 0.2. Used only
when add
contains "dotplot".
as size
but applied only to dotplot.
plot type used to visualize error. Allowed values are one of
c("pointrange", "linerange", "crossbar", "errorbar", "upper_errorbar",
"lower_errorbar", "upper_pointrange", "lower_pointrange", "upper_linerange",
"lower_linerange")
. Default value is "pointrange".
a data.frame
to be displayed. If NULL
, the default, the
data is inherited from the plot data as specified in the call to ggplot.
position adjustment, either as a string, or the result of a call to a position adjustment function. Used to adjust position for multiple groups.
the geometry of the main plot. Ex: p_geom = "geom_line". If NULL, the geometry is extracted from p. Used only by ggline().
# NOT RUN {
# Basic violin plot
data("ToothGrowth")
p <- ggviolin(ToothGrowth, x = "dose", y = "len", add = "none")
# Add mean +/- SD and jitter points
p %>% ggadd(c("mean_sd", "jitter"), color = "dose")
# Add box plot
p %>% ggadd(c("boxplot", "jitter"), color = "dose")
# }
Run the code above in your browser using DataLab