1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ggadd.R
\name{ggadd}
\alias{ggadd}
\title{Add Summary Statistics or a Geom onto a ggplot}
\usage{
ggadd(
p,
add = NULL,
color = "black",
fill = "white",
group = 1,
width = 1,
shape = 19,
size = NULL,
alpha = 1,
jitter = 0.2,
seed = 123,
binwidth = NULL,
dotsize = size,
linetype = 1,
show.legend = NA,
error.plot = "pointrange",
ci = 0.95,
data = NULL,
position = position_dodge(0.8),
p_geom = ""
)
}
\arguments{
\item{p}{a ggplot}
\item{add}{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_hilow", "median_q1q3", "median_mad",
"median_range".}
\item{color}{point or outline color.}
\item{fill}{fill color. Used only when \code{error.plot = "crossbar"}.}
\item{group}{grouping variable. Allowed values are 1 (for one group) or a
character vector specifying the name of the grouping variable. Used only for
adding statistical summary per group.}
\item{width}{numeric value between 0 and 1 specifying bar or box width.
Example width = 0.8. Used only when \code{error.plot} is one of
c("crossbar", "errorbar").}
\item{shape}{point shape. Allowed values can be displayed using the function
\code{\link{show_point_shapes}()}.}
\item{size}{numeric value in [0-1] specifying point and line size.}
\item{alpha}{numeric value specifying fill color transparency. Value should be
in [0, 1], where 0 is full transparency and 1 is no transparency.}
\item{jitter}{a numeric value specifying the amount of jittering. Used only
when \code{add} contains "jitter".}
\item{seed}{A random seed to make the jitter reproducible. Default is `123`. Useful if you need
to apply the same jitter twice, e.g., for a point and a corresponding label.
The random seed is reset after jittering. If `NA`, the
seed is initialized with a random value; this makes sure that two subsequent
calls start with a different seed. Use NULL to use the current random seed
and also avoid resetting (the behaviour of ggplot 2.2.1 and earlier).}
\item{binwidth}{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 \code{add} contains "dotplot".}
\item{dotsize}{as \code{size} but applied only to dotplot.}
\item{linetype}{line type.}
\item{show.legend}{logical. Should this layer be included in the legends? NA,
the default, includes if any aesthetics are mapped. \code{FALSE} never
includes, and TRUE always includes. It can also be a named logical vector to
finely select the aesthetics to display.}
\item{error.plot}{plot type used to visualize error. Allowed values are one of
\code{c("pointrange", "linerange", "crossbar", "errorbar", "upper_errorbar",
"lower_errorbar", "upper_pointrange", "lower_pointrange", "upper_linerange",
"lower_linerange")}. Default value is "pointrange".}
\item{ci}{the percent range of the confidence interval (default is 0.95).}
\item{data}{a \code{data.frame} to be displayed. If \code{NULL}, the default,
the data is inherited from the plot data as specified in the call to
\link[ggplot2]{ggplot}.}
\item{position}{position adjustment, either as a string, or the result of a
call to a position adjustment function. Used to adjust position for multiple
groups.}
\item{p_geom}{the geometry of the main plot. Ex: p_geom = "geom_line". If
NULL, the geometry is extracted from p. Used only by \link{ggline}().}
}
\description{
Add summary statistics or a geometry onto a ggplot.
}
\examples{
# 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")
}
|