From ccf17f9e5c7e950881b1579bcd525d1ebf208fcd Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Sat, 15 Feb 2025 18:02:54 +0100 Subject: [PATCH 1/3] crux composition has background --- R/compose-crux.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/R/compose-crux.R b/R/compose-crux.R index 0753cbd..bea05dd 100644 --- a/R/compose-crux.R +++ b/R/compose-crux.R @@ -111,7 +111,8 @@ ComposeCrux <- ggproto( title_position = "legend.title.position", text_position = "legend.text.position", title = "legend.title", - margin = "legend.margin" + margin = "legend.margin", + background = "legend.background" ), setup_elements = function(params, elements, theme) { @@ -220,6 +221,12 @@ ComposeCrux <- ggproto( if (!is.null(elems$margin)) { gt <- gtable_add_padding(gt, elems$margin) } + if (!is.zero(elems$background)) { + gt <- gtable_add_grob( + gt, element_grob(elems$background), name = "background", + clip = "off", t = 1, r = -1, b = -1, l = 1, z = -Inf + ) + } } gt } From 01abd4fd587311e2a1bfc38efd713be8836dc51d Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Sat, 15 Feb 2025 18:03:30 +0100 Subject: [PATCH 2/3] update snapshots --- .../_snaps/compose-sandwich/horizontal-sandwich-flipped.svg | 1 + .../testthat/_snaps/compose-sandwich/horizontal-sandwich.svg | 1 + .../_snaps/compose-sandwich/vertical-sandwich-flipped.svg | 1 + tests/testthat/_snaps/compose-sandwich/vertical-sandwich.svg | 1 + tests/testthat/_snaps/guide-colbar/bottom-position.svg | 4 ++++ tests/testthat/_snaps/guide-colbar/left-position.svg | 4 ++++ tests/testthat/_snaps/guide-colbar/right-position.svg | 4 ++++ tests/testthat/_snaps/guide-colbar/top-position.svg | 4 ++++ tests/testthat/_snaps/guide-colsteps/bottom-position.svg | 4 ++++ tests/testthat/_snaps/guide-colsteps/left-position.svg | 4 ++++ tests/testthat/_snaps/guide-colsteps/right-position.svg | 4 ++++ tests/testthat/_snaps/guide-colsteps/top-position.svg | 4 ++++ 12 files changed, 36 insertions(+) diff --git a/tests/testthat/_snaps/compose-sandwich/horizontal-sandwich-flipped.svg b/tests/testthat/_snaps/compose-sandwich/horizontal-sandwich-flipped.svg index 1d07647..e842ea7 100644 --- a/tests/testthat/_snaps/compose-sandwich/horizontal-sandwich-flipped.svg +++ b/tests/testthat/_snaps/compose-sandwich/horizontal-sandwich-flipped.svg @@ -302,6 +302,7 @@ 7 displ hwy + cty diff --git a/tests/testthat/_snaps/compose-sandwich/horizontal-sandwich.svg b/tests/testthat/_snaps/compose-sandwich/horizontal-sandwich.svg index 8f6eafd..4958dd1 100644 --- a/tests/testthat/_snaps/compose-sandwich/horizontal-sandwich.svg +++ b/tests/testthat/_snaps/compose-sandwich/horizontal-sandwich.svg @@ -302,6 +302,7 @@ 7 displ hwy + cty diff --git a/tests/testthat/_snaps/compose-sandwich/vertical-sandwich-flipped.svg b/tests/testthat/_snaps/compose-sandwich/vertical-sandwich-flipped.svg index 783c6f5..5512b17 100644 --- a/tests/testthat/_snaps/compose-sandwich/vertical-sandwich-flipped.svg +++ b/tests/testthat/_snaps/compose-sandwich/vertical-sandwich-flipped.svg @@ -302,6 +302,7 @@ 7 displ hwy + cty diff --git a/tests/testthat/_snaps/compose-sandwich/vertical-sandwich.svg b/tests/testthat/_snaps/compose-sandwich/vertical-sandwich.svg index 4aeccaa..3b57c5e 100644 --- a/tests/testthat/_snaps/compose-sandwich/vertical-sandwich.svg +++ b/tests/testthat/_snaps/compose-sandwich/vertical-sandwich.svg @@ -302,6 +302,7 @@ 7 displ hwy + cty diff --git a/tests/testthat/_snaps/guide-colbar/bottom-position.svg b/tests/testthat/_snaps/guide-colbar/bottom-position.svg index 26bb778..816b875 100644 --- a/tests/testthat/_snaps/guide-colbar/bottom-position.svg +++ b/tests/testthat/_snaps/guide-colbar/bottom-position.svg @@ -102,6 +102,7 @@ 400 disp mpg + @@ -118,6 +119,7 @@ 6 7 8 + @@ -134,6 +136,7 @@ 6 7 8 + @@ -150,6 +153,7 @@ 6 7 8 + diff --git a/tests/testthat/_snaps/guide-colbar/left-position.svg b/tests/testthat/_snaps/guide-colbar/left-position.svg index 905f78c..ab6982b 100644 --- a/tests/testthat/_snaps/guide-colbar/left-position.svg +++ b/tests/testthat/_snaps/guide-colbar/left-position.svg @@ -102,6 +102,7 @@ 400 disp mpg + @@ -118,6 +119,7 @@ 6 7 8 + @@ -134,6 +136,7 @@ 6 7 8 + @@ -150,6 +153,7 @@ 6 7 8 + diff --git a/tests/testthat/_snaps/guide-colbar/right-position.svg b/tests/testthat/_snaps/guide-colbar/right-position.svg index 39c5e9e..e336c83 100644 --- a/tests/testthat/_snaps/guide-colbar/right-position.svg +++ b/tests/testthat/_snaps/guide-colbar/right-position.svg @@ -102,6 +102,7 @@ 400 disp mpg + @@ -118,6 +119,7 @@ 6 7 8 + @@ -134,6 +136,7 @@ 6 7 8 + @@ -150,6 +153,7 @@ 6 7 8 + diff --git a/tests/testthat/_snaps/guide-colbar/top-position.svg b/tests/testthat/_snaps/guide-colbar/top-position.svg index b4002c6..253cbe1 100644 --- a/tests/testthat/_snaps/guide-colbar/top-position.svg +++ b/tests/testthat/_snaps/guide-colbar/top-position.svg @@ -102,6 +102,7 @@ 400 disp mpg + @@ -118,6 +119,7 @@ 6 7 8 + @@ -134,6 +136,7 @@ 6 7 8 + @@ -150,6 +153,7 @@ 6 7 8 + diff --git a/tests/testthat/_snaps/guide-colsteps/bottom-position.svg b/tests/testthat/_snaps/guide-colsteps/bottom-position.svg index 39f4fd9..732fa3d 100644 --- a/tests/testthat/_snaps/guide-colsteps/bottom-position.svg +++ b/tests/testthat/_snaps/guide-colsteps/bottom-position.svg @@ -102,6 +102,7 @@ 400 disp mpg + @@ -122,6 +123,7 @@ 6 7 8 + @@ -143,6 +145,7 @@ 6 7 8 + @@ -164,6 +167,7 @@ 6 7 8 + diff --git a/tests/testthat/_snaps/guide-colsteps/left-position.svg b/tests/testthat/_snaps/guide-colsteps/left-position.svg index 77c5392..719d482 100644 --- a/tests/testthat/_snaps/guide-colsteps/left-position.svg +++ b/tests/testthat/_snaps/guide-colsteps/left-position.svg @@ -102,6 +102,7 @@ 400 disp mpg + @@ -122,6 +123,7 @@ 6 7 8 + @@ -143,6 +145,7 @@ 6 7 8 + @@ -164,6 +167,7 @@ 6 7 8 + diff --git a/tests/testthat/_snaps/guide-colsteps/right-position.svg b/tests/testthat/_snaps/guide-colsteps/right-position.svg index b36f764..fd8abd6 100644 --- a/tests/testthat/_snaps/guide-colsteps/right-position.svg +++ b/tests/testthat/_snaps/guide-colsteps/right-position.svg @@ -102,6 +102,7 @@ 400 disp mpg + @@ -122,6 +123,7 @@ 6 7 8 + @@ -143,6 +145,7 @@ 6 7 8 + @@ -164,6 +167,7 @@ 6 7 8 + diff --git a/tests/testthat/_snaps/guide-colsteps/top-position.svg b/tests/testthat/_snaps/guide-colsteps/top-position.svg index 848e924..e29e399 100644 --- a/tests/testthat/_snaps/guide-colsteps/top-position.svg +++ b/tests/testthat/_snaps/guide-colsteps/top-position.svg @@ -102,6 +102,7 @@ 400 disp mpg + @@ -122,6 +123,7 @@ 6 7 8 + @@ -143,6 +145,7 @@ 6 7 8 + @@ -164,6 +167,7 @@ 6 7 8 + From 187dde309b733af86d95ab40798e41ee0ad00d18 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Sat, 15 Feb 2025 18:05:00 +0100 Subject: [PATCH 3/3] add news bullet --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 12a29a4..e84390b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ * Fixed bug hindering `position = "inside"` placement (#42) * Fixed bug in `theme_guide(key.size, key.height, key.width)` (#41) +* Complete guides based on a crux composition now render the `legend.background` + element (#50) # legendry 0.2.0