Skip to content

Commit

Permalink
save vp to grob directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Dec 10, 2024
1 parent af35b0d commit 07946cc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
3 changes: 2 additions & 1 deletion R/alignpatch-inset.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ inset <- function(plot, ..., align = "panel", on_top = TRUE,
add_class(grob, "patch_inset")
}

#' @importFrom grid editGrob
#' @importFrom rlang arg_match0
make_inset <- function(plot, ..., align, on_top, clip, vp,
call = caller_call()) {
Expand All @@ -34,8 +35,8 @@ make_inset <- function(plot, ..., align, on_top, clip, vp,
}
attr(grob, "align") <- align
attr(grob, "clip") <- if (clip) "on" else "off"
attr(grob, "vp") <- vp
attr(grob, "on_top") <- on_top
if (!is.null(vp)) grob <- editGrob(grob, vp = vp)
grob
}

Expand Down
9 changes: 0 additions & 9 deletions R/alignpatch-wrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@ add_wrapped_grob <- function(gt, grob, on_top, i) {
gt$layout$z[layout$z >= z] <- layout$z[layout$z >= z] + 1L
}

# if we set the viewport, the grob must be a gtable object
if (!is.null(vp <- attr(grob, "vp"))) {
if (is.gtable(grob)) {
grob$vp <- vp
} else {
container <- gtable(unit(1L, "null"), unit(1L, "null"), vp = vp)
grob <- gtable_add_grob(container, list(grob), 1L, 1L, clip = FALSE)
}
}
# add the grob to the gtable
if (align == "full") {
gt <- gtable_add_grob(gt,
Expand Down

0 comments on commit 07946cc

Please sign in to comment.