@@ -17,7 +17,7 @@ test_that("dodging works", {
17
17
ndodge <- 3
18
18
19
19
# The amount of space allocated within each dodge group
20
- dwidth <- .9 / ndodge
20
+ dwidth <- 0 .9 / ndodge
21
21
22
22
# This should be the x position for each before dodging
23
23
xbase <- ceiling(df $ group / ndodge )
@@ -36,20 +36,20 @@ test_that("dodging works", {
36
36
37
37
test_that(" binning works" , {
38
38
bp <- ggplot(dat , aes(y )) +
39
- geom_dotplot(binwidth = .4 , method = " histodot" )
39
+ geom_dotplot(binwidth = 0 .4 , method = " histodot" )
40
40
x <- get_layer_data(bp )$ x
41
41
42
42
# Need ugly hack to make sure mod function doesn't give values like -3.99999
43
43
# due to floating point error
44
- expect_true(all(abs((x - min(x ) + 1e-7 ) %% .4 ) < 1e-6 ))
44
+ expect_true(all(abs((x - min(x ) + 1e-7 ) %% 0 .4 ) < 1e-6 ))
45
45
46
46
bp <- ggplot(dat , aes(x = y )) +
47
- geom_dotplot(binwidth = .4 , method = " dotdensity" )
47
+ geom_dotplot(binwidth = 0 .4 , method = " dotdensity" )
48
48
x <- get_layer_data(bp )$ x
49
49
50
50
# This one doesn't ensure that dotdensity works, but it does check that it's not
51
51
# doing fixed bin sizes
52
- expect_false(all(abs((x - min(x ) + 1e-7 ) %% .4 ) < 1e-6 ))
52
+ expect_false(all(abs((x - min(x ) + 1e-7 ) %% 0 .4 ) < 1e-6 ))
53
53
})
54
54
55
55
test_that(" NA's result in warning from stat_bindot" , {
@@ -58,7 +58,7 @@ test_that("NA's result in warning from stat_bindot", {
58
58
dat $ x [c(2 ,10 )] <- NA
59
59
60
60
# Need to assign it to a var here so that it doesn't automatically print
61
- expect_snapshot_warning(ggplot_build(ggplot(dat , aes(x )) + geom_dotplot(binwidth = .2 )))
61
+ expect_snapshot_warning(ggplot_build(ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .2 )))
62
62
})
63
63
64
64
test_that(" when binning on y-axis, limits depend on the panel" , {
@@ -92,99 +92,99 @@ test_that("geom_dotplot draws correctly", {
92
92
93
93
# Basic dotplot with binning along x axis
94
94
expect_doppelganger(" basic dotplot with dot-density binning, binwidth = .4" ,
95
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 )
95
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 )
96
96
)
97
97
expect_doppelganger(" histodot binning (equal bin spacing)" ,
98
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , method = " histodot" )
98
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , method = " histodot" )
99
99
)
100
100
expect_doppelganger(" dots stacked closer: stackratio=.5, fill=white" ,
101
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackratio = .5 , fill = " white" )
101
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackratio = 0 .5 , fill = " white" )
102
102
)
103
103
expect_doppelganger(" larger dots: dotsize=1.5, fill=white" ,
104
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , dotsize = 1.4 , fill = " white" )
104
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , dotsize = 1.4 , fill = " white" )
105
105
)
106
106
107
107
# Stacking methods
108
108
expect_doppelganger(" stack up" ,
109
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackdir = " up" )
109
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackdir = " up" )
110
110
)
111
111
expect_doppelganger(" stack down" ,
112
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackdir = " down" )
112
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackdir = " down" )
113
113
)
114
114
expect_doppelganger(" stack center" ,
115
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackdir = " center" )
115
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackdir = " center" )
116
116
)
117
117
expect_doppelganger(" stack centerwhole" ,
118
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackdir = " centerwhole" )
118
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackdir = " centerwhole" )
119
119
)
120
120
121
121
# Stacking methods with coord_flip
122
122
expect_doppelganger(" stack up with coord_flip" ,
123
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackdir = " up" ) + coord_flip()
123
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackdir = " up" ) + coord_flip()
124
124
)
125
125
expect_doppelganger(" stack down with coord_flip" ,
126
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackdir = " down" ) + coord_flip()
126
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackdir = " down" ) + coord_flip()
127
127
)
128
128
expect_doppelganger(" stack center with coord_flip" ,
129
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackdir = " center" ) + coord_flip()
129
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackdir = " center" ) + coord_flip()
130
130
)
131
131
expect_doppelganger(" stack centerwhole with coord_flip" ,
132
- ggplot(dat , aes(x )) + geom_dotplot(binwidth = .4 , stackdir = " centerwhole" ) + coord_flip()
132
+ ggplot(dat , aes(x )) + geom_dotplot(binwidth = 0 .4 , stackdir = " centerwhole" ) + coord_flip()
133
133
)
134
134
135
135
# Binning along x, with groups
136
136
expect_doppelganger(" multiple groups, bins not aligned" ,
137
- ggplot(dat , aes(x , fill = g )) + geom_dotplot(binwidth = .4 , alpha = .4 )
137
+ ggplot(dat , aes(x , fill = g )) + geom_dotplot(binwidth = 0 .4 , alpha = 0 .4 )
138
138
)
139
139
expect_doppelganger(" multiple groups, bins aligned" ,
140
- ggplot(dat , aes(x , fill = g )) + geom_dotplot(binwidth = .4 , alpha = .4 , binpositions = " all" )
140
+ ggplot(dat , aes(x , fill = g )) + geom_dotplot(binwidth = 0 .4 , alpha = 0 .4 , binpositions = " all" )
141
141
)
142
142
143
143
# Binning along y axis
144
144
expect_doppelganger(" bin along y, stack center" ,
145
- ggplot(dat , aes(0 , x )) + geom_dotplot(binwidth = .4 , binaxis = " y" , stackdir = " center" )
145
+ ggplot(dat , aes(0 , x )) + geom_dotplot(binwidth = 0 .4 , binaxis = " y" , stackdir = " center" )
146
146
)
147
147
expect_doppelganger(" bin along y, stack centerwhole" ,
148
- ggplot(dat , aes(0 , x )) + geom_dotplot(binwidth = .4 , binaxis = " y" , stackdir = " centerwhole" )
148
+ ggplot(dat , aes(0 , x )) + geom_dotplot(binwidth = 0 .4 , binaxis = " y" , stackdir = " centerwhole" )
149
149
)
150
150
expect_doppelganger(" bin along y, stack centerwhole, histodot" ,
151
- ggplot(dat , aes(0 , x )) + geom_dotplot(binwidth = .4 , binaxis = " y" , stackdir = " centerwhole" , method = " histodot" )
151
+ ggplot(dat , aes(0 , x )) + geom_dotplot(binwidth = 0 .4 , binaxis = " y" , stackdir = " centerwhole" , method = " histodot" )
152
152
)
153
153
154
154
# Binning along y, with multiple grouping factors
155
155
dat2 <- data_frame(x = rep(factor (LETTERS [1 : 3 ]), 30 ), y = rnorm(90 ), g = rep(factor (LETTERS [1 : 2 ]), 45 ))
156
156
157
157
expect_doppelganger(" bin x, three y groups, stack centerwhole" ,
158
- ggplot(dat2 , aes(y , x )) + geom_dotplot(binwidth = .25 , binaxis = " x" , stackdir = " centerwhole" )
158
+ ggplot(dat2 , aes(y , x )) + geom_dotplot(binwidth = 0 .25 , binaxis = " x" , stackdir = " centerwhole" )
159
159
)
160
160
expect_doppelganger(" bin y, three x groups, stack centerwhole" ,
161
- ggplot(dat2 , aes(x , y )) + geom_dotplot(binwidth = .25 , binaxis = " y" , stackdir = " centerwhole" )
161
+ ggplot(dat2 , aes(x , y )) + geom_dotplot(binwidth = 0 .25 , binaxis = " y" , stackdir = " centerwhole" )
162
162
)
163
163
expect_doppelganger(" bin y, three x groups, bins aligned across groups" ,
164
- ggplot(dat2 , aes(x , y )) + geom_dotplot(binwidth = .25 , binaxis = " y" , stackdir = " center" , binpositions = " all" )
164
+ ggplot(dat2 , aes(x , y )) + geom_dotplot(binwidth = 0 .25 , binaxis = " y" , stackdir = " center" , binpositions = " all" )
165
165
)
166
166
expect_doppelganger(" bin y, three x groups, bins aligned, coord_flip" ,
167
- ggplot(dat2 , aes(x , y )) + geom_dotplot(binwidth = .25 , binaxis = " y" , stackdir = " center" , binpositions = " all" ) +
167
+ ggplot(dat2 , aes(x , y )) + geom_dotplot(binwidth = 0 .25 , binaxis = " y" , stackdir = " center" , binpositions = " all" ) +
168
168
coord_flip()
169
169
)
170
170
expect_doppelganger(" bin y, dodged" ,
171
- ggplot(dat2 , aes(" foo" , y , fill = x )) + scale_y_continuous(breaks = seq(- 4 , 4 , .4 )) +
172
- geom_dotplot(binwidth = .25 , position = " dodge" , binaxis = " y" , stackdir = " center" )
171
+ ggplot(dat2 , aes(" foo" , y , fill = x )) + scale_y_continuous(breaks = seq(- 4 , 4 , 0 .4 )) +
172
+ geom_dotplot(binwidth = 0 .25 , position = " dodge" , binaxis = " y" , stackdir = " center" )
173
173
)
174
174
expect_doppelganger(" bin y, dodged, coord_flip" ,
175
- ggplot(dat2 , aes(" foo" , y , fill = x )) + scale_y_continuous(breaks = seq(- 4 , 4 , .4 )) +
176
- geom_dotplot(binwidth = .25 , position = " dodge" , binaxis = " y" , stackdir = " center" ) +
175
+ ggplot(dat2 , aes(" foo" , y , fill = x )) + scale_y_continuous(breaks = seq(- 4 , 4 , 0 .4 )) +
176
+ geom_dotplot(binwidth = 0 .25 , position = " dodge" , binaxis = " y" , stackdir = " center" ) +
177
177
coord_flip()
178
178
)
179
179
expect_doppelganger(" bin y, three x groups, fill and dodge" ,
180
- ggplot(dat2 , aes(x , y , fill = g )) + scale_y_continuous(breaks = seq(- 4 ,4 , .4 )) +
181
- geom_dotplot(binwidth = .2 , position = " dodge" , binaxis = " y" , stackdir = " center" )
180
+ ggplot(dat2 , aes(x , y , fill = g )) + scale_y_continuous(breaks = seq(- 4 ,4 , 0 .4 )) +
181
+ geom_dotplot(binwidth = 0 .2 , position = " dodge" , binaxis = " y" , stackdir = " center" )
182
182
)
183
183
expect_doppelganger(" bin y, continous x-axis, grouping by x" ,
184
- ggplot(dat2 , aes(as.numeric(x ), y , group = x )) + geom_dotplot(binwidth = .2 , binaxis = " y" , stackdir = " center" )
184
+ ggplot(dat2 , aes(as.numeric(x ), y , group = x )) + geom_dotplot(binwidth = 0 .2 , binaxis = " y" , stackdir = " center" )
185
185
)
186
186
expect_doppelganger(" bin y, continous x-axis, single x group" ,
187
- ggplot(dat2 , aes(as.numeric(x ), y )) + geom_dotplot(binwidth = .2 , binaxis = " y" , stackdir = " center" )
187
+ ggplot(dat2 , aes(as.numeric(x ), y )) + geom_dotplot(binwidth = 0 .2 , binaxis = " y" , stackdir = " center" )
188
188
)
189
189
190
190
# border width and size
@@ -198,31 +198,31 @@ test_that("geom_dotplot draws correctly", {
198
198
stroke = rep(c(1 , 2 ), length.out = nrow(dat ))
199
199
)
200
200
) +
201
- geom_dotplot(binwidth = .4 , fill = " red" , col = " blue" ) +
201
+ geom_dotplot(binwidth = 0 .4 , fill = " red" , col = " blue" ) +
202
202
continuous_scale(" stroke" , palette = function (x ) scales :: rescale(x , to = c(1 , 6 ))) +
203
203
guides(linetype = guide_legend(order = 1 ))
204
204
)
205
205
206
206
# Stacking groups
207
207
expect_doppelganger(" 3 stackgroups, dot-density with aligned bins" ,
208
- ggplot(dat2 , aes(y , fill = x )) + geom_dotplot(binwidth = .25 , stackgroups = TRUE , binpositions = " all" , alpha = 0.5 )
208
+ ggplot(dat2 , aes(y , fill = x )) + geom_dotplot(binwidth = 0 .25 , stackgroups = TRUE , binpositions = " all" , alpha = 0.5 )
209
209
)
210
210
expect_doppelganger(" 3 stackgroups, histodot" ,
211
- ggplot(dat2 , aes(y , fill = x )) + geom_dotplot(binwidth = .25 , stackgroups = TRUE , method = " histodot" , alpha = 0.5 )
211
+ ggplot(dat2 , aes(y , fill = x )) + geom_dotplot(binwidth = 0 .25 , stackgroups = TRUE , method = " histodot" , alpha = 0.5 )
212
212
)
213
213
expect_doppelganger(" 3 stackgroups, bin y, histodot" ,
214
- ggplot(dat2 , aes(1 , y , fill = x )) + geom_dotplot(binaxis = " y" , binwidth = .25 , stackgroups = TRUE , method = " histodot" , alpha = 0.5 )
214
+ ggplot(dat2 , aes(1 , y , fill = x )) + geom_dotplot(binaxis = " y" , binwidth = 0 .25 , stackgroups = TRUE , method = " histodot" , alpha = 0.5 )
215
215
)
216
216
217
217
# This one is currently broken but it would be a really rare case, and it
218
218
# probably requires a really ugly hack to fix
219
219
expect_doppelganger(" bin y, dodging, 3 stackgroups, histodot" ,
220
220
ggplot(dat2 , aes(x , y , fill = g )) +
221
- geom_dotplot(binaxis = " y" , binwidth = .25 , stackgroups = TRUE , method = " histodot" ,
221
+ geom_dotplot(binaxis = " y" , binwidth = 0 .25 , stackgroups = TRUE , method = " histodot" ,
222
222
alpha = 0.5 , stackdir = " centerwhole" )
223
223
)
224
224
expect_doppelganger(" facets, 3 groups, histodot, stackgroups" ,
225
- ggplot(dat2 , aes(y , fill = g )) + geom_dotplot(binwidth = .25 , stackgroups = TRUE , method = " histodot" , alpha = 0.5 ) +
225
+ ggplot(dat2 , aes(y , fill = g )) + geom_dotplot(binwidth = 0 .25 , stackgroups = TRUE , method = " histodot" , alpha = 0.5 ) +
226
226
facet_grid(x ~ . )
227
227
)
228
228
@@ -231,10 +231,10 @@ test_that("geom_dotplot draws correctly", {
231
231
dat2 $ x [c(1 , 10 )] <- NA
232
232
233
233
expect_warning(expect_doppelganger(" 2 NA values, dot-density binning, binwidth = .4" ,
234
- ggplot(dat2 , aes(x )) + geom_dotplot(binwidth = .4 )
234
+ ggplot(dat2 , aes(x )) + geom_dotplot(binwidth = 0 .4 )
235
235
))
236
236
expect_warning(expect_doppelganger(" 2 NA values, bin along y, stack center" ,
237
- ggplot(dat2 , aes(0 , x )) + geom_dotplot(binwidth = .4 , binaxis = " y" , stackdir = " center" )
237
+ ggplot(dat2 , aes(0 , x )) + geom_dotplot(binwidth = 0 .4 , binaxis = " y" , stackdir = " center" )
238
238
))
239
239
})
240
240
0 commit comments