Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inheritance of theme-based aesthetics #6285

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test
teunbrand committed Jan 21, 2025
commit 4fd2ce3f5f2f0e0a756dc2c58444f1f1f8d01370
20 changes: 20 additions & 0 deletions tests/testthat/test-theme.R
Original file line number Diff line number Diff line change
@@ -673,6 +673,26 @@ test_that("margin_part() mechanics work as expected", {
expect_equal(as.numeric(test), c(5.5, 5.5, 11, 5.5))
})

test_that("geom elements are inherited correctly", {

GeomFoo <- ggproto("GeomFoo", GeomPoint)
GeomBar <- ggproto("GeomBar", GeomFoo)

p <- ggplot(data.frame(x = 1), aes(x, x)) +
stat_identity(geom = GeomBar) +
theme(
geom = element_geom(pointshape = 15),
geom.point = element_geom(borderwidth = 2, ink = "blue"),
geom.foo = element_geom(pointsize = 2),
geom.bar = element_geom(ink = "red")
)
p <- layer_data(p)
expect_equal(p$shape, 15)
expect_equal(p$stroke, 2)
expect_equal(p$size, 2)
expect_equal(p$colour, "red")
})

# Visual tests ------------------------------------------------------------

test_that("aspect ratio is honored", {