Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tdhock/directlabels
Browse files Browse the repository at this point in the history
  • Loading branch information
tdhock committed Jan 21, 2024
2 parents 74f3824 + 8d9df2b commit c1824df
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions R/ggplot2.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ pkgFun <- function(fun, pkg="ggplot2") {
### Extract guides to hide from a ggplot.
legends2hide <- function(p){
plistextra <- ggplot2::ggplot_build(p)

if ("get_guide_data" %in% getNamespaceExports("ggplot2")) {
# Using clunky get here to avoid R cmd check warnings in earlier versions
# of ggplot2
get_guide_data <- get("get_guide_data", envir = asNamespace("ggplot2"))
for (aes in c("colour", "fill")) {
guide_data <- get_guide_data(plistextra, aes)
if (!is.null(guide_data)) {
hide <- colnames(guide_data)
hide <- hide[!grepl("^\\.", hide)]
return(list(colour = aes, hide = hide, data = guide_data))
}
}
return()
}

plot <- plistextra$plot
scales = plot$scales
layers = plot$layers
Expand Down

0 comments on commit c1824df

Please sign in to comment.