Skip to content

Commit

Permalink
fix namespace issues
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Dec 9, 2017
1 parent a2fda96 commit a47fb5d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions R/plot_to_gtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ plot_to_gtable <- function(plot){
else {
# we convert the captured plot or output plot into a grob
# to be safe, we have to save and restore the current graphics device
cur_dev <- dev.cur()
cur_dev <- grDevices::dev.cur()
tree <- grid::grid.grabExpr(gridGraphics::grid.echo(plot))
dev.set(cur_dev)
grDevices::dev.set(cur_dev)

u <- grid::unit(1, "null")
gt <- gtable::gtable_col(NULL, list(tree), u, u)
Expand All @@ -40,15 +40,15 @@ plot_to_gtable <- function(plot){
## so to be absolutely sure, we also save the previous device and then restore it.

# save currently active device
cur_dev <- dev.cur()
cur_dev <- grDevices::dev.cur()
# open NULL pdf device
grDevices::pdf(NULL)
# convert plot to grob
plot <- ggplot2::ggplotGrob(plot)
# close pdf device
grDevices::dev.off()
# restore previously active device
dev.set(cur_dev)
grDevices::dev.set(cur_dev)

plot
}
Expand Down
2 changes: 1 addition & 1 deletion R/save.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ggsave <- function(filename, plot = ggplot2::last_plot(), device = NULL, path =
# match ggsave_args to args provided
args <- as.list(match.call())
args[[1]] <- NULL # remove the function call
args <- args[na.omit(match(ggsave_args, names(args)))] # remove other args
args <- args[stats::na.omit(match(ggsave_args, names(args)))] # remove other args

args_dotdotdot <- list(...)

Expand Down
2 changes: 0 additions & 2 deletions R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
# switch the default theme to theme_cowplot
ggplot2::theme_set(theme_cowplot())
}

.pt <- 1 / 0.352777778 # from ggplot2, file aaa-constants.r
2 changes: 1 addition & 1 deletion man/ggsave.Rd

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

0 comments on commit a47fb5d

Please sign in to comment.