Created
October 2, 2017 12:32
-
-
Save tjmahr/1dd36d78ecb3cff10baf01817a56e895 to your computer and use it in GitHub Desktop.
ggpreview - preview ggsave output in system image viewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
# preview a file that would be created by ggsave() | |
ggpreview <- function(...) { | |
fname <- tempfile(fileext = ".png") | |
ggsave(filename = fname, ...) | |
system2("open", fname) | |
invisible(NULL) | |
} | |
ggplot(mtcars) + | |
aes(x = wt, y = mpg) + | |
geom_point() | |
ggpreview(width = 3, height = 3, units = "in") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment