File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,22 @@ pkgFun <- function(fun, pkg="ggplot2") {
195
195
# ## Extract guides to hide from a ggplot.
196
196
legends2hide <- function (p ){
197
197
plistextra <- ggplot2 :: ggplot_build(p )
198
+
199
+ if (" get_guide_data" %in% getNamespaceExports(" ggplot2" )) {
200
+ # Using clunky get here to avoid R cmd check warnings in earlier versions
201
+ # of ggplot2
202
+ get_guide_data <- get(" get_guide_data" , envir = asNamespace(" ggplot2" ))
203
+ for (aes in c(" colour" , " fill" )) {
204
+ guide_data <- get_guide_data(plistextra , aes )
205
+ if (! is.null(guide_data )) {
206
+ hide <- colnames(guide_data )
207
+ hide <- hide [! grepl(" ^\\ ." , hide )]
208
+ return (list (colour = aes , hide = hide , data = guide_data ))
209
+ }
210
+ }
211
+ return ()
212
+ }
213
+
198
214
plot <- plistextra $ plot
199
215
scales = plot $ scales
200
216
layers = plot $ layers
You can’t perform that action at this time.
0 commit comments