18
18
# ' (default) or `"y"`.
19
19
# ' @param reverse If `TRUE`, will reverse the default stacking order.
20
20
# ' This is useful if you're rotating both the plot and legend.
21
- # ' @param stack_overlap Specifies if and how to stack the dodged geoms. Possible
21
+ # ' @param stack.overlap Specifies if and how to stack the dodged geoms. Possible
22
22
# ' values are `"no"` (default), `"by_extent"` or `"by_center"`. This parameter
23
23
# ' implements the dodge and stack functionality together. Use `"by_extent"` for
24
24
# ' columns and `"by_center"` for errorbars.
91
91
# ' ggplot(mtcars, aes(factor(cyl), fill = factor(vs))) +
92
92
# ' geom_bar(position = position_dodge2(preserve = "total"))
93
93
position_dodge <- function (width = NULL , preserve = " total" , orientation = " x" ,
94
- reverse = FALSE , stack_overlap = " no" ) {
94
+ reverse = FALSE , stack.overlap = " no" ) {
95
95
check_bool(reverse )
96
96
ggproto(NULL , PositionDodge ,
97
97
width = width ,
98
98
preserve = arg_match0(preserve , c(" total" , " single" )),
99
99
orientation = arg_match0(orientation , c(" x" , " y" )),
100
- stack_overlap = arg_match0(stack_overlap , c(" no" ," by_extent" ," by_center" )),
100
+ stack.overlap = arg_match0(stack.overlap , c(" no" ," by_extent" ," by_center" )),
101
101
reverse = reverse
102
102
)
103
103
}
@@ -109,7 +109,7 @@ position_dodge <- function(width = NULL, preserve = "total", orientation = "x",
109
109
PositionDodge <- ggproto(" PositionDodge" , Position ,
110
110
width = NULL ,
111
111
preserve = " total" ,
112
- stack_overlap = " no" ,
112
+ stack.overlap = " no" ,
113
113
orientation = " x" ,
114
114
reverse = NULL ,
115
115
default_aes = aes(order = NULL ),
@@ -142,7 +142,7 @@ PositionDodge <- ggproto("PositionDodge", Position,
142
142
143
143
list (
144
144
width = self $ width ,
145
- stack_overlap = self $ stack_overlap ,
145
+ stack.overlap = self $ stack.overlap ,
146
146
n = n ,
147
147
flipped_aes = flipped_aes ,
148
148
reverse = self $ reverse %|| % FALSE
@@ -179,7 +179,7 @@ PositionDodge <- ggproto("PositionDodge", Position,
179
179
strategy = pos_dodge ,
180
180
n = params $ n ,
181
181
check.width = FALSE ,
182
- stack_overlap = params $ stack_overlap ,
182
+ stack.overlap = params $ stack.overlap ,
183
183
reverse = ! params $ reverse # for consistency with `position_dodge2()`
184
184
)
185
185
flip_data(collided , params $ flipped_aes )
@@ -188,7 +188,7 @@ PositionDodge <- ggproto("PositionDodge", Position,
188
188
189
189
# Dodge overlapping interval.
190
190
# Assumes that each set has the same horizontal position.
191
- pos_dodge <- function (df , width , n = NULL , stack_overlap = " no" ) {
191
+ pos_dodge <- function (df , width , n = NULL , stack.overlap = " no" ) {
192
192
if (is.null(n )) {
193
193
n <- vec_unique_count(df $ group )
194
194
}
@@ -213,7 +213,7 @@ pos_dodge <- function(df, width, n = NULL, stack_overlap = "no") {
213
213
df $ xmin <- df $ x - d_width / n / 2
214
214
df $ xmax <- df $ x + d_width / n / 2
215
215
216
- if (stack_overlap == " by_extent" ) {
216
+ if (stack.overlap == " by_extent" ) {
217
217
# The code chunk below is just to implement the following line without tidyverse functions, as ggplot2 can be imported without that
218
218
# df %>% group_by(group) %>% mutate(ymaxx = cumsum(ymax)) %>% mutate(ymin = ymaxx-ymax, ymax = ymaxx)
219
219
@@ -228,7 +228,7 @@ pos_dodge <- function(df, width, n = NULL, stack_overlap = "no") {
228
228
229
229
df $ ymaxx = NULL # Remove the extra variable
230
230
231
- } else if (stack_overlap == " by_center" ) {
231
+ } else if (stack.overlap == " by_center" ) {
232
232
# Similarly to above, the complicated code below is just to do the next line without tidyverse
233
233
# df %>% group_by(group) %>% mutate(extent = ymax-ymin, ymaxx = cumsum((ymax+ymin)/2)) %>% mutate(ymin = ymaxx-extent/2, ymax = ymaxx+extent/2)
234
234
0 commit comments