Skip to content

Instantly share code, notes, and snippets.

@jonovik
Forked from dpashouwer/gg_to_clipboard
Last active June 29, 2023 13:29
Show Gist options
  • Save jonovik/0cb7d5bd5755b0c86dab2e705290f294 to your computer and use it in GitHub Desktop.
Save jonovik/0cb7d5bd5755b0c86dab2e705290f294 to your computer and use it in GitHub Desktop.
Copy ggplot to clipboard
# pacman::p_load(tidyverse)
gg_to_clipboard <- function(plot = last_plot(), width = 1000, height = 600, pointsize = 40){
win.graph(width = width, height = height, pointsize = pointsize)
plot %>% print()
savePlot("clipboard", type = "wmf")
dev.off()
}
# ggplot(data = mtcars, aes(x = mpg)) + geom_histogram()
# gg_to_clipboard()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment