Skip to content

Instantly share code, notes, and snippets.

@wch
Created November 8, 2012 02:53
Show Gist options
  • Save wch/4036319 to your computer and use it in GitHub Desktop.
Save wch/4036319 to your computer and use it in GitHub Desktop.
png tests on Linux
# On ubuntu, this is needed to compile Cairo:
# sudo apt-get install libcairo2-dev
# sudo apt-get install libxt-dev
# install.packages('Cairo')
library(ggplot2)
# Regular png
png('test1-png.png')
ggplot(mtcars, aes(wt, mpg)) + geom_point()
dev.off()
# png, attempting to use cairo device
png('test2-cairo.png', type="cairo")
ggplot(mtcars, aes(wt, mpg)) + geom_point()
dev.off()
# With Cario library
library(Cairo)
CairoPNG('test3-CairoPNG.png')
ggplot(mtcars, aes(wt, mpg)) + geom_point()
dev.off()
# This successfully antialiases points
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment