Skip to content

Commit 4ac00fe

Browse files
Remove iris (#4077)
Fix #4075
1 parent 112f960 commit 4ac00fe

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

R/position-dodge.r

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
#' )
6565
#'
6666
#' # Box plots use position_dodge2 by default, and bars can use it too
67-
#' ggplot(data = iris, aes(Species, Sepal.Length)) +
68-
#' geom_boxplot(aes(colour = Sepal.Width < 3.2))
67+
#' ggplot(mpg, aes(factor(year), displ)) +
68+
#' geom_boxplot(aes(colour = hwy < 30))
6969
#'
70-
#' ggplot(data = iris, aes(Species, Sepal.Length)) +
71-
#' geom_boxplot(aes(colour = Sepal.Width < 3.2), varwidth = TRUE)
70+
#' ggplot(mpg, aes(factor(year), displ)) +
71+
#' geom_boxplot(aes(colour = hwy < 30), varwidth = TRUE)
7272
#'
7373
#' ggplot(mtcars, aes(factor(cyl), fill = factor(vs))) +
7474
#' geom_bar(position = position_dodge2(preserve = "single"))

man/position_dodge.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-geom-boxplot.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ test_that("can use US spelling of colour", {
5555
})
5656

5757
test_that("boxes with variable widths do not overlap", {
58-
p <- ggplot(data = iris, aes(Species, Sepal.Length)) +
59-
geom_boxplot(aes(colour = Sepal.Width < 3.2), varwidth = TRUE)
58+
df <- data_frame(
59+
value = 1:12,
60+
group = rep(c("a", "b", "c"), each = 4L),
61+
subgroup = rep(c("A", "B"), times = 6L)
62+
)
63+
64+
p <- ggplot(df, aes(group, value, colour = subgroup)) +
65+
geom_boxplot(varwidth = TRUE)
6066
d <- layer_data(p)[c("xmin", "xmax")]
6167
xid <- find_x_overlaps(d)
6268

tests/testthat/test-position-dodge2.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ test_that("cols at the same x position are dodged", {
5151
})
5252

5353
test_that("padding argument controls space between elements", {
54-
p1 <- ggplot(iris, aes(1, Sepal.Length, fill = Sepal.Width < 3.2)) +
54+
df <- data_frame(value = 1:3, group = c("a", "a", "b"))
55+
56+
p1 <- ggplot(df, aes(1, value, fill = group)) +
5557
geom_boxplot(position = position_dodge2(padding = 0))
56-
p2 <- ggplot(iris, aes(1, Sepal.Length, fill = Sepal.Width < 3.2)) +
58+
p2 <- ggplot(df, aes(1, value, fill = group)) +
5759
geom_boxplot(position = position_dodge2(padding = 0.1))
5860

5961
d1 <- layer_data(p1)
@@ -72,9 +74,14 @@ test_that("padding argument controls space between elements", {
7274
})
7375

7476
test_that("boxes in facetted plots keep the correct width", {
77+
df <- data_frame(
78+
value = 1:12,
79+
group = rep(c("a", "b", "c"), each = 4L),
80+
subgroup = rep(c("A", "B"), times = 6L)
81+
)
7582

76-
p <- ggplot(mtcars, aes(x = factor(vs), y = mpg)) +
77-
facet_wrap( ~ factor(cyl)) +
83+
p <- ggplot(df, aes(subgroup, value)) +
84+
facet_wrap( ~ group) +
7885
geom_boxplot()
7986

8087
d <- layer_data(p)

0 commit comments

Comments
 (0)