Skip to content

Instantly share code, notes, and snippets.

@sainathadapa
Forked from wch/pngtest.r
Created April 20, 2014 14:42
Show Gist options
  • Save sainathadapa/11115803 to your computer and use it in GitHub Desktop.
Save sainathadapa/11115803 to your computer and use it in GitHub Desktop.
# 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