9595# '
9696# ' ggplot(mtcars, aes(x = 1, y = mpg, fill = factor(cyl))) +
9797# ' geom_dotplot(binaxis = "y", stackgroups = TRUE, binwidth = 1, method = "histodot")
98+ # '
99+ # ' # Use qplot instead
100+ # ' qplot(mpg, data = mtcars, geom = "dotplot")
98101# '
99102geom_dotplot <- function (mapping = NULL , data = NULL , stat = " bindot" , position = " identity" ,
100103na.rm = FALSE , binwidth = NULL , binaxis = " x" , method = " dotdensity" , binpositions = " bygroup" , stackdir = " up" ,
@@ -152,7 +155,7 @@ GeomDotplot <- proto(Geom, {
152155 params $ width %|| % (resolution(df $ x , FALSE ) * 0.9 )
153156
154157 # Set up the stacking function and range
155- if (params $ stackdir == " up" ) {
158+ if (is.null( params $ stackdir ) || params $ stackdir == " up" ) {
156159 stackdots <- function (a ) a - .5
157160 stackaxismin <- 0
158161 stackaxismax <- 1
@@ -176,8 +179,9 @@ GeomDotplot <- proto(Geom, {
176179
177180 # Next part will set the position of each dot within each stack
178181 # If stackgroups=TRUE, split only on x (or y) and panel; if not stacking, also split by group
179- plyvars <- c(params $ binaxis , " PANEL" )
180- if (! params $ stackgroups )
182+ plyvars <- params $ binaxis %|| % " x"
183+ plyvars <- c(plyvars , " PANEL" )
184+ if (is.null(params $ stackgroups ) || ! params $ stackgroups )
181185 plyvars <- c(plyvars , " group" )
182186
183187 # Within each x, or x+group, set countidx=1,2,3, and set stackpos according to stack function
@@ -189,7 +193,7 @@ GeomDotplot <- proto(Geom, {
189193
190194
191195 # Set the bounding boxes for the dots
192- if (params $ binaxis == " x" ) {
196+ if (is.null( params $ binaxis ) || params $ binaxis == " x" ) {
193197 # ymin, ymax, xmin, and xmax define the bounding rectangle for each stack
194198 # Can't do bounding box per dot, because y position isn't real.
195199 # After position code is rewritten, each dot should have its own bounding box.
0 commit comments