Skip to content

Commit

Permalink
fix error for the development version of ggplot2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Jan 8, 2025
1 parent 487d7eb commit a2c822a
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions R/ggplot-helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,40 @@ element_grob.ggalign_element_polygon <- function(element,
colour = NULL,
linewidth = NULL,
linetype = NULL, ...) {
gp <- gpar(
lwd = ggfun("len0_null")(linewidth * .pt),
col = colour,
fill = fill,
lty = linetype
gp <- try_fetch(
gpar(
lwd = ggfun("len0_null")(linewidth * .pt),
col = colour,
fill = fill,
lty = linetype
),
error = function(cnd) {
ggplot2::gg_par(
lwd = linewidth, col = colour, fill = fill, lty = linetype
)
}
)
element_gp <- gpar(
lwd = ggfun("len0_null")(element$linewidth * .pt),
col = element$colour,
fill = fill_alpha(element$fill, element$alpha %||% NA),
lty = element$linetype,
lineend = element$lineend,
linejoin = element$linejoin,
linemitre = element$linemitre
element_gp <- try_fetch(
gpar(
lwd = ggfun("len0_null")(element$linewidth * .pt),
col = element$colour,
fill = fill_alpha(element$fill, element$alpha %||% NA),
lty = element$linetype,
lineend = element$lineend,
linejoin = element$linejoin,
linemitre = element$linemitre
),
error = function(cnd) {
ggplot2::gg_par(
lwd = element$linewidth,
col = element$colour,
fill = fill_alpha(element$fill, element$alpha %||% NA),
lty = element$linetype,
lineend = element$lineend,
linejoin = element$linejoin,
linemitre = element$linemitre
)
}
)
grid::polygonGrob(
x = x, y = y,
Expand Down

0 comments on commit a2c822a

Please sign in to comment.