Skip to content

Commit

Permalink
Fix missing theme elements (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Apr 27, 2024
1 parent 77c1b67 commit 06bc900
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion R/compose-crux.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ ComposeCrux <- ggproto(
position = elems$title_position,
with(elems$title, rotate_just(angle, hjust, vjust))
)
gt <- gtable_add_padding(gt, elems$margin)
if (!is.null(elems$margin)) {
gt <- gtable_add_padding(gt, elems$margin)
}
}
gt
}
Expand Down
8 changes: 4 additions & 4 deletions R/utils-text.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
setup_legend_text <- function(theme, direction = "vertical") {
position <- calc_element("legend.text.position", theme)
position <- position %||% switch(direction, horizontal = "bottom", vertical = "right")
gap <- calc_element("legend.key.spacing", theme)
margin <- calc_element("text", theme)$margin
gap <- calc_element("legend.key.spacing", theme) %||% unit(0, "pt")
margin <- calc_element("text", theme)$margin %||% margin()
margin <- position_margin(position, margin, gap)
text <- theme(
text = switch(
Expand All @@ -20,8 +20,8 @@ setup_legend_text <- function(theme, direction = "vertical") {
setup_legend_title <- function(theme, direction = "vertical") {
position <- calc_element("legend.title.position", theme)
position <- position %||% switch(direction, horizontal = "left", vertical = "top")
gap <- calc_element("legend.key.spacing", theme)
margin <- calc_element("text", theme)$margin
gap <- calc_element("legend.key.spacing", theme) %||% unit(0, "pt")
margin <- calc_element("text", theme)$margin %||% margin()
margin <- position_margin(position, margin, gap)
title <- theme(text = element_text(hjust = 0, vjust = 0.5, margin = margin))
calc_element("legend.title", theme + title)
Expand Down

0 comments on commit 06bc900

Please sign in to comment.