Skip to content

Commit 7be4c89

Browse files
committed
Set expansion properties for legend title/text.
Fixes #1502
1 parent f8e9708 commit 7be4c89

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggplot2 2.0.0.9000
22

3+
* The theme can now modify the margins of legend title and text (#1502).
4+
35
* `scale_size()` warns when used with categorical data.
46

57
* `scale_size()`, `scale_colour()`, and `scale_fill()` gain date and date-time

R/guide-legend.r

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ guide_gengrob.legend <- function(guide, theme) {
300300
guide$title.theme %||% calc_element("legend.title", theme),
301301
label = guide$title,
302302
hjust = guide$title.hjust %||% theme$legend.title.align %||% 0,
303-
vjust = guide$title.vjust %||% 0.5
303+
vjust = guide$title.vjust %||% 0.5,
304+
expand_x = TRUE,
305+
expand_y = TRUE
304306
)
305307
)
306308

@@ -321,7 +323,8 @@ guide_gengrob.legend <- function(guide, theme) {
321323

322324
grob.labels <- lapply(guide$key$.label, function(label, ...) {
323325
g <- element_grob(element = label.theme, label = label,
324-
x = x, y = y, hjust = hjust, vjust = vjust)
326+
x = x, y = y, hjust = hjust, vjust = vjust,
327+
expand_x = TRUE, expand_y = TRUE)
325328
ggname("guide.label", g)
326329
})
327330
}

0 commit comments

Comments
 (0)