20
20
# ' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "dotplot")}
21
21
# '
22
22
# ' @inheritParams geom_point
23
- # ' @param geom,stat Use to override the default connection between
24
- # ' \code{geom_dotplot} and \code{stat_bindot}.
25
23
# ' @param stackdir which direction to stack the dots. "up" (default),
26
24
# ' "down", "center", "centerwhole" (centered, but with dots aligned)
27
25
# ' @param stackratio how close to stack the dots. Default is 1, where dots just
30
28
# ' @param stackgroups should dots be stacked across groups? This has the effect
31
29
# ' that \code{position = "stack"} should have, but can't (because this geom has
32
30
# ' some odd properties).
31
+ # ' @param binaxis The axis to bin along, "x" (default) or "y"
32
+ # ' @param method "dotdensity" (default) for dot-density binning, or
33
+ # ' "histodot" for fixed bin widths (like stat_bin)
34
+ # ' @param binwidth When \code{method} is "dotdensity", this specifies maximum bin
35
+ # ' width. When \code{method} is "histodot", this specifies bin width.
36
+ # ' Defaults to 1/30 of the range of the data
37
+ # ' @param binpositions When \code{method} is "dotdensity", "bygroup" (default)
38
+ # ' determines positions of the bins for each group separately. "all" determines
39
+ # ' positions of the bins with all the data taken together; this is used for
40
+ # ' aligning dot stacks across multiple groups.
41
+ # ' @param origin When \code{method} is "histodot", origin of first bin
42
+ # ' @param right When \code{method} is "histodot", should intervals be closed
43
+ # ' on the right (a, b], or not [a, b)
44
+ # ' @param width When \code{binaxis} is "y", the spacing of the dot stacks
45
+ # ' for dodging.
46
+ # ' @param na.rm If \code{FALSE} (the default), removes missing values with
47
+ # ' a warning. If \code{TRUE} silently removes missing values.
48
+ # ' @param drop If TRUE, remove all bins with zero counts
49
+ # ' @return New data frame with additional columns:
50
+ # ' \item{x}{center of each bin, if binaxis is "x"}
51
+ # ' \item{y}{center of each bin, if binaxis is "x"}
52
+ # ' \item{binwidth}{max width of each bin if method is "dotdensity";
53
+ # ' width of each bin if method is "histodot"}
54
+ # ' \item{count}{number of points in bin}
55
+ # ' \item{ncount}{count, scaled to maximum of 1}
56
+ # ' \item{density}{density of points in bin, scaled to integrate to 1,
57
+ # ' if method is "histodot"}
58
+ # ' \item{ndensity}{density, scaled to maximum of 1, if method is "histodot"}
33
59
# ' @export
34
60
# ' @references Wilkinson, L. (1999) Dot plots. The American Statistician,
35
61
# ' 53(3), 276-281.
57
83
# ' # Expand dot diameter
58
84
# ' ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5, dotsize = 1.25)
59
85
# '
60
- # '
61
86
# ' # Examples with stacking along y axis instead of x
62
87
# ' ggplot(mtcars, aes(x = 1, y = mpg)) +
63
88
# ' geom_dotplot(binaxis = "y", stackdir = "center")
84
109
# '
85
110
# ' ggplot(mtcars, aes(x = 1, y = mpg, fill = factor(cyl))) +
86
111
# ' geom_dotplot(binaxis = "y", stackgroups = TRUE, binwidth = 1, method = "histodot")
87
- # '
88
- geom_dotplot <- function (mapping = NULL , data = NULL , stat = " bindot" ,
112
+ geom_dotplot <- function (mapping = NULL , data = NULL ,
89
113
position = " identity" , na.rm = FALSE , binwidth = NULL , binaxis = " x" ,
90
114
method = " dotdensity" , binpositions = " bygroup" , stackdir = " up" ,
91
- stackratio = 1 , dotsize = 1 , stackgroups = FALSE , show_guide = NA ,
115
+ stackratio = 1 , dotsize = 1 , stackgroups = FALSE ,
116
+ origin = NULL , right = TRUE , width = 0.9 , drop = FALSE , show_guide = NA ,
92
117
inherit.aes = TRUE , ... )
93
118
{
94
119
# If identical(position, "stack") or position is position_stack(), tell them
@@ -104,7 +129,7 @@ geom_dotplot <- function (mapping = NULL, data = NULL, stat = "bindot",
104
129
layer(
105
130
data = data ,
106
131
mapping = mapping ,
107
- stat = stat ,
132
+ stat = StatBindot ,
108
133
geom = GeomDotplot ,
109
134
position = position ,
110
135
show_guide = show_guide ,
@@ -115,7 +140,11 @@ geom_dotplot <- function (mapping = NULL, data = NULL, stat = "bindot",
115
140
na.rm = na.rm ,
116
141
binwidth = binwidth ,
117
142
binpositions = binpositions ,
118
- method = method
143
+ method = method ,
144
+ origin = origin ,
145
+ right = right ,
146
+ width = width ,
147
+ drop = drop
119
148
),
120
149
geom_params = list (
121
150
binaxis = binaxis ,
0 commit comments