@@ -149,6 +149,7 @@ geom_dotplot <- function(mapping = NULL, data = NULL,
149
149
if (stackgroups && method == " dotdensity" && binpositions == " bygroup" )
150
150
message(' geom_dotplot called with stackgroups=TRUE and method="dotdensity". You probably want to set binpositions="all"' )
151
151
152
+ stackdir <- arg_match0(stackdir , c(" up" , " down" , " center" , " centerwhole" ), " stackdir" )
152
153
layer(
153
154
data = data ,
154
155
mapping = mapping ,
@@ -210,23 +211,27 @@ GeomDotplot <- ggproto("GeomDotplot", Geom,
210
211
stackaxismax <- .5
211
212
}
212
213
213
-
214
214
# Fill the bins: at a given x (or y), if count=3, make 3 entries at that x
215
215
data <- data [rep(1 : nrow(data ), data $ count ), ]
216
216
217
217
# Next part will set the position of each dot within each stack
218
218
# If stackgroups=TRUE, split only on x (or y) and panel; if not stacking, also split by group
219
219
plyvars <- params $ binaxis %|| % " x"
220
+ stackaxis <- setdiff(c(" x" , " y" ), plyvars )
220
221
plyvars <- c(plyvars , " PANEL" )
221
222
if (is.null(params $ stackgroups ) || ! params $ stackgroups )
222
223
plyvars <- c(plyvars , " group" )
223
224
225
+ if (stackaxis == " x" ) {
226
+ plyvars <- c(plyvars , " x" )
227
+ }
228
+
224
229
# Within each x, or x+group, set countidx=1,2,3, and set stackpos according to stack function
225
230
data <- dapply(data , plyvars , function (xx ) {
226
- xx $ countidx <- 1 : nrow(xx )
227
- xx $ stackpos <- stackdots(xx $ countidx )
228
- xx
229
- })
231
+ xx $ countidx <- 1 : nrow(xx )
232
+ xx $ stackpos <- stackdots(xx $ countidx )
233
+ xx
234
+ })
230
235
231
236
232
237
# Set the bounding boxes for the dots
0 commit comments