Skip to content

Make legend.box.background work for theme_void() #2725

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

Merged
merged 3 commits into from
Jul 9, 2018
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: 2 additions & 2 deletions R/guides-.r
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ guides_build <- function(ggrobs, theme) {
yjust <- just[2]

# setting that is different for vertical and horizontal guide-boxes.
if (theme$legend.box == "horizontal") {
if (identical(theme$legend.box, "horizontal")) {
# Set justification for each legend
for (i in seq_along(ggrobs)) {
ggrobs[[i]] <- editGrob(ggrobs[[i]],
Expand All @@ -263,7 +263,7 @@ guides_build <- function(ggrobs, theme) {
# add space between the guide-boxes
guides <- gtable_add_col_space(guides, theme$legend.spacing.x)

} else if (theme$legend.box == "vertical") {
} else { # theme$legend.box == "vertical"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the test in the first block to use identical()? That's safer if theme$legend.box is somehow not a length-1 vector. (I'm surprised the user of NULL doesn't cause a warning, TBH)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

# Set justification for each legend
for (i in seq_along(ggrobs)) {
ggrobs[[i]] <- editGrob(ggrobs[[i]],
Expand Down
1 change: 1 addition & 0 deletions R/theme-defaults.r
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ theme_void <- function(base_size = 11, base_family = "",
axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks.length = unit(0, "pt"),
legend.box = NULL,
legend.key.size = unit(1.2, "lines"),
legend.position = "right",
legend.text = element_text(size = rel(0.8)),
Expand Down