Skip to content

Commit a0a0652

Browse files
authored
Add room around guide title (#2195)
* Add room around guide title (@baptiste) * Update visual test SVGs * Update hgap and vgap in guide-colorbar.r to match guide-legend.r * New visual test SVGs to reflect modified legends in guide-colorbar.r
1 parent d601ea5 commit a0a0652

File tree

67 files changed

+2322
-2322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2322
-2322
lines changed

R/guide-colorbar.r

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,6 @@ guide_gengrob.colorbar <- function(guide, theme) {
255255
barlength.c <- switch(guide$direction, "horizontal" = barwidth.c, "vertical" = barheight.c)
256256
nbreak <- nrow(guide$key)
257257

258-
# gap between keys etc
259-
hgap <- c(convertWidth(unit(0.3, "lines"), "mm"))
260-
vgap <- hgap
261-
262258
grob.bar <-
263259
if (guide$raster) {
264260
image <- switch(guide$direction, horizontal = t(guide$bar$colour), vertical = rev(guide$bar$colour))
@@ -301,6 +297,10 @@ guide_gengrob.colorbar <- function(guide, theme) {
301297
title_height <- convertHeight(grobHeight(grob.title), "mm")
302298
title_height.c <- c(title_height)
303299

300+
# gap between keys etc
301+
hgap <- width_cm(theme$legend.spacing.x %||% unit(0.3, "line"))
302+
vgap <- height_cm(theme$legend.spacing.y %||% 0.5 * unit(title_height, "cm"))
303+
304304
# label
305305
label.theme <- guide$label.theme %||% calc_element("legend.text", theme)
306306
grob.label <- {

R/guide-legend.r

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,6 @@ guide_gengrob.legend <- function(guide, theme) {
298298

299299
nbreak <- nrow(guide$key)
300300

301-
# gap between keys etc
302-
hgap <- width_cm(unit(0.3, "lines"))
303-
vgap <- hgap
304-
305301
grob.title <- ggname("guide.title",
306302
element_grob(
307303
guide$title.theme %||% calc_element("legend.title", theme),
@@ -315,6 +311,10 @@ guide_gengrob.legend <- function(guide, theme) {
315311

316312
title_width <- width_cm(grob.title)
317313
title_height <- height_cm(grob.title)
314+
315+
# gap between keys etc
316+
hgap <- width_cm(theme$legend.spacing.x %||% unit(0.3, "line"))
317+
vgap <- height_cm(theme$legend.spacing.y %||% 0.5 * unit(title_height, "cm"))
318318

319319
# Labels
320320
if (!guide$label || is.null(guide$key$.label)) {

R/utilities-grid.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ width_cm <- function(x) {
2626
}
2727
height_cm <- function(x) {
2828
if (is.grob(x)) {
29-
convertWidth(grobHeight(x), "cm", TRUE)
29+
convertHeight(grobHeight(x), "cm", TRUE)
3030
} else if (is.unit(x)) {
3131
convertHeight(x, "cm", TRUE)
3232
} else if (is.list(x)) {

tests/figs/coord-polar/rays-circular-arcs-and-spiral-arcs.svg

Lines changed: 330 additions & 330 deletions
Loading

tests/figs/geom-boxplot/outlier-colours.svg

Lines changed: 20 additions & 20 deletions
Loading

tests/figs/geom-dotplot/bin-y-dodged-coord-flip.svg

Lines changed: 11 additions & 11 deletions
Loading

tests/figs/geom-dotplot/bin-y-dodged.svg

Lines changed: 11 additions & 11 deletions
Loading

0 commit comments

Comments
 (0)