Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 (development version)

* Fixed bug in `guide_custom()` that would throw error with `theme_void()`
(@teunbrand, #5856).
* New helper function `ggpar()` to translate ggplot2's interpretation of
graphical parameters to {grid}'s interpretation (@teunbrand, #5866).

Expand All @@ -23,7 +25,7 @@ documentation updates.
(@teunbrand, #5757).

## Improvements

* When facets coerce the faceting variables to factors, the 'ordered' class
is dropped (@teunbrand, #5666).
* `coord_map()` and `coord_polar()` throw informative warnings when used
Expand Down
2 changes: 1 addition & 1 deletion R/guide-custom.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ GuideCustom <- ggproto(
)

# Add padding and background
gt <- gtable_add_padding(gt, elems$margin)
gt <- gtable_add_padding(gt, elems$margin %||% margin())

gt <- gtable_add_grob(
gt, element_grob(elems$background),
Expand Down
34 changes: 34 additions & 0 deletions tests/testthat/_snaps/guides/guide-custom-with-void-theme.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions tests/testthat/_snaps/guides/stylised-guide-custom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions tests/testthat/test-guides.R
Original file line number Diff line number Diff line change
Expand Up @@ -1273,3 +1273,23 @@ test_that("old S3 guides can be implemented", {
)
)
})

test_that("guide_custom can be drawn and styled", {

p <- ggplot() + guides(custom = guide_custom(
circleGrob(r = unit(1, "cm")),
title = "custom guide"
))

expect_doppelganger(
"stylised guide_custom",
p + theme(legend.background = element_rect(fill = "grey50"),
legend.title.position = "left",
legend.title = element_text(angle = 90, hjust = 0.5))
)

expect_doppelganger(
"guide_custom with void theme",
p + theme_void()
)
})