Skip to content

Commit

Permalink
Fix #369
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Sep 3, 2024
1 parent a092f30 commit 7ccff04
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Imports:
utils,
graphics,
rlang (>= 1.0.0),
cli
cli,
farver
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
URL: https://patchwork.data-imaginist.com, https://github.com/thomasp85/patchwork
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export(wrap_ggplot_grob)
export(wrap_plots)
import(cli)
import(rlang)
importFrom(farver,get_channel)
importFrom(farver,set_channel)
importFrom(ggplot2,aes)
importFrom(ggplot2,calc_element)
importFrom(ggplot2,element_blank)
Expand Down
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* `free()` now better aligns plots in horizontal direction
* Plot backgrounds are now always placed beneath all other elements in the
patchwork (#370)
* Axis titles can now reliably be collected even with faceted plots (#367 and
#369)
* Axis titles can now reliably be collected even with faceted plots (#367)
* Native support for gt objects
* Empty patches no longer breaks up axis title collection (#375)
* `wrap_ggplot_grob()` now respects auto-tagging (#363)
Expand All @@ -19,6 +18,9 @@
patchwork objects (#381)
* The default arguments in `plot_annotation()` and `plot_layout()` are now
`waiver()` allowing the use of `NULL` to remove an already set value (#198)
* Guide and axis merging is slightly more robust when it comes to merging if
different graphical parameters that means the same are used (e.g. "black" and
"#000000") (#369)

# patchwork 1.2.0

Expand Down
13 changes: 13 additions & 0 deletions R/guides.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ unname_vp <- function(x) {
}
#' @importFrom grid is.grob is.unit absolute.size
#' @importFrom gtable is.gtable
#' @importFrom farver set_channel get_channel
unname_grob <- function(x) {
if (is.gtable(x)) {
x$name <- ''
Expand All @@ -32,6 +33,18 @@ unname_grob <- function(x) {
}
unit_elements <- vapply(x, is.unit, logical(1))
x[unit_elements] <- lapply(.subset(x, unit_elements), absolute.size)
if (!is.null(x$gp)) {
if (is.character(x$gp$col)) x$gp$col <- set_channel(x$gp$col, "r", get_channel(x$gp$col, "r"))
if (is.character(x$gp$fill)) x$gp$fill <- set_channel(x$gp$fill, "r", get_channel(x$gp$fill, "r"))
if (is.numeric(x$gp$lty)) x$gp$lty <- c("blank", "solid", "dashed", "dotted", "dotdash", "longdash", "twodash")[x$gp$lty + 1]
if (is.character(x$gp$lty)) {
rename <- match(x$gp$lty, c("44", "13", "1343", "73", "2262"))
matched <- !is.na(rename)
x$gp$lty[matched] <- c("dashed", "dotted", "dotdash", "longdash", "twodash")[rename[matched]]
}
if (is.numeric(x$gp$lineend)) x$gp$lineend <- c("round", "butt", "square")[x$gp$lineend]
if (is.numeric(x$gp$linejoin)) x$gp$linejoin <- c("round", "mitre", "bevel")[x$gp$linejoin]
}
x
}
collapse_guides <- function(guides) {
Expand Down
21 changes: 11 additions & 10 deletions man/plot_layout.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7ccff04

Please sign in to comment.