Skip to content

Instantly share code, notes, and snippets.

@briandk
Created September 1, 2011 03:58
Show Gist options
  • Save briandk/1185420 to your computer and use it in GitHub Desktop.
Save briandk/1185420 to your computer and use it in GitHub Desktop.
Comparing ggsave and the default pdf rendering in R
# Making sure you have a fresh copy of granovaGG
remove.packages("granovaGG", lib = .libPaths())
library(devtools)
install_github(repo = "granovaGG", username = "briandk", branch = "dev")
library(granovaGG)
library(granova)
# Creating a 7-inch by 7-inch test plot
setwd("~/Desktop/testplots") # I created the testplots directory in advance
granovagg.1w(data = mpg$hwy, group = mpg$manufacturer)
ggsave("testplot1.pdf", width = 7, height = 7)
# NOTE: replace "path/to/file.pdf" with where you'd like to save the file on your system
# for example, I named this one "testplot1.pdf"
# Just make sure to include .pdf as a suffix, so ggsave knows you want PDF output
# Checking what your default quartz graphics dimensions are
par("din")
# Creating a test plot assuming a huge monitor
ggsave("testplot2.pdf", width = 15, height = 15)
# proving that the same effects happen to classic granova plots
pdf("testplot3.pdf", width = 7, height = 7)
granova.1w(data = mpg$hwy, group = mpg$manufacturer)
dev.off()
pdf("testplot4.pdf", width = 15, height = 15)
granova.1w(data = mpg$hwy, group = mpg$manufacturer)
dev.off()
@WilDoane
Copy link

WilDoane commented Sep 1, 2011

Don't forget the final
dev.off()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment