Skip to content

Instantly share code, notes, and snippets.

@econandrew
Created December 13, 2017 23:08
Show Gist options
  • Save econandrew/4fd9d61397b467ffbfd4d4d4ba6fb5f6 to your computer and use it in GitHub Desktop.
Save econandrew/4fd9d61397b467ffbfd4d4d4ba6fb5f6 to your computer and use it in GitHub Desktop.
library(ggplot2)
p <- ggplot(mtcars, aes(cyl, mpg)) + geom_point()
res <- 300
fn <- "test.png"
# Default png()
png(fn, res = res)
print(p)
dev.off()
system(paste0('identify -format "%x x %y" ', fn))
# quartz
png(fn, type = "quartz", res = res)
print(p)
dev.off()
system(paste0('identify -format "%x x %y" ', fn))
# cairo
png(fn, type = "cairo", res = res)
print(p)
dev.off()
system(paste0('identify -format "%x x %y" ', fn))
# cairo-png
png(fn, type = "cairo-png", res = res)
print(p)
dev.off()
system(paste0('identify -format "%x x %y" ', fn))
# CairoPNG
Cairo::CairoPNG(fn, res = res)
print(p)
dev.off()
system(paste0('identify -format "%x x %y" ', fn))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment