Skip to content

Commit

Permalink
Merge branch 'main' into scale_name_first
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Dec 14, 2023
2 parents 4679548 + 4d7e202 commit e592fd8
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* The `name` argument in most scales is now explicitly the first argument
(#5535)

* When using `geom_dotplot(binaxis = "x")` with a discrete y-variable, dots are
now stacked from the y-position rather than from 0 (@teunbrand, #5462)

* (breaking) In the `scale_{colour/fill}_gradient2()` and
`scale_{colour/fill}_steps2()` functions, the `midpoint` argument is
transformed by the scale transformation (#3198).
Expand Down
8 changes: 4 additions & 4 deletions R/geom-dotplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ GeomDotplot <- ggproto("GeomDotplot", Geom,
# ymin, ymax, xmin, and xmax define the bounding rectangle for each stack
# Can't do bounding box per dot, because y position isn't real.
# After position code is rewritten, each dot should have its own bounding box.
yoffset <- if (is_mapped_discrete(data$y)) data$y else 0
data$xmin <- data$x - data$binwidth / 2
data$xmax <- data$x + data$binwidth / 2
data$ymin <- stackaxismin
data$ymax <- stackaxismax
data$y <- 0

data$ymin <- stackaxismin + yoffset
data$ymax <- stackaxismax + yoffset
data$y <- yoffset
} else if (params$binaxis == "y") {
# ymin, ymax, xmin, and xmax define the bounding rectangle for each stack
# Can't do bounding box per dot, because x position isn't real.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/testthat/test-geom-dotplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ test_that("geom_dotplot draws correctly", {
# Binning along y, with multiple grouping factors
dat2 <- data_frame(x = rep(factor(LETTERS[1:3]), 30), y = rnorm(90), g = rep(factor(LETTERS[1:2]), 45))

expect_doppelganger("bin x, three y groups, stack centerwhole",
ggplot(dat2, aes(y, x)) + geom_dotplot(binwidth = .25, binaxis = "x", stackdir = "centerwhole")
)
expect_doppelganger("bin y, three x groups, stack centerwhole",
ggplot(dat2, aes(x, y)) + geom_dotplot(binwidth = .25, binaxis = "y", stackdir = "centerwhole")
)
Expand Down

0 comments on commit e592fd8

Please sign in to comment.