briandk / granovaGG

Bob Pruzek and Jim Helmreich's implementation of Elemental Graphics for Analysis of Variance
Other
15 stars 4 forks source link

PDF outputs appear different on different systems #109

Closed briandk closed 13 years ago

briandk commented 13 years ago

@rmpruzek's PDFs for granovagg.1w look different than mine do.

WilDoane commented 13 years ago
  1. Are the versions of R the same?
  2. Are the versions of gglopt2 the same?
  3. Are the fonts the same family in the generated graphics? (e.g., times vs. times new roman could cause a font-metrics difference)
  4. Are the operating systems the same version?
  5. Are the R > Format > Fonts > Show Fonts settings the same (and does ggplot2 rely on these settings)?
  6. Are the R > Preferences > Quartz settings the same (and does ggplot2 rely on these settings)?
  7. other possible causes...?

-Wil

William Doane http://DrDoane.com

On 2011 Sep 01, at 00:03, briandk wrote:

@rmpruzek's PDFs for granovagg.1w look different than mine do.

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109

briandk commented 13 years ago

I'm going to try some tests on my linux box.

briandk commented 13 years ago

Here's the test code I'd like people to try. If possible, email me your results for testplot1.pdf and testplot2.pdf

https://gist.github.com/1185420

WilDoane commented 13 years ago

So that everyone can see at least one other version, here are my 2 plots:

http://DrDoane.com/screenshots/testplot1-20110901-001528.pdf

http://DrDoane.com/screenshots/testplot2-doane-20110901-001642.pdf

-Wil

William Doane http://DrDoane.com

On 2011 Sep 01, at 00:13, briandk wrote:

Here's the test code I'd like people to try. If possible, email me your results for testplot1.pdf and testplot2.pdf

https://gist.github.com/1185420

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1964751

rmpruzek commented 13 years ago

Wil, I see no difference in yours other than jittering (as in my case). b


From: WilDoane reply@reply.github.com To: rmpruzek@yahoo.com Sent: Thursday, September 1, 2011 12:17 AM Subject: Re: [granovaGG] PDF outputs appear different on different systems (#109)

So that everyone can see at least one other version, here are my 2 plots:

http://DrDoane.com/screenshots/testplot1-20110901-001528.pdf

http://DrDoane.com/screenshots/testplot2-doane-20110901-001642.pdf

-Wil

William Doane http://DrDoane.com

On 2011 Sep 01, at 00:13, briandk wrote:

Here's the test code I'd like people to try. If possible, email me your results for testplot1.pdf and testplot2.pdf

https://gist.github.com/1185420

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1964751

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1964779

rmpruzek commented 13 years ago

W, B, I'm using R ver. 2.13.0, ggplot2 0.8.9, and default R fonts (?). I'm running OS 10.6.8 (not yet Lion), and I've never changed defaults for Fonts or Quartz (AKAICR). b


From: WilDoane reply@reply.github.com To: rmpruzek@yahoo.com Sent: Thursday, September 1, 2011 12:08 AM Subject: Re: [granovaGG] PDF outputs appear different on different systems (#109)

  1. Are the versions of R the same?
  2. Are the versions of gglopt2 the same?
  3. Are the fonts the same family in the generated graphics? (e.g., times vs. times new roman could cause a font-metrics difference)
  4. Are the operating systems the same version?
  5. Are the R > Format > Fonts > Show Fonts settings the same (and does ggplot2 rely on these settings)?
  6. Are the R > Preferences > Quartz settings the same (and does ggplot2 rely on these settings)?
  7. other possible causes...?

-Wil

William Doane http://DrDoane.com

On 2011 Sep 01, at 00:03, briandk wrote:

@rmpruzek's PDFs for granovagg.1w look different than mine do.

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1964730

WilDoane commented 13 years ago

You're correct, Bob... there is no significant difference in my 2 graphics.

The problem seems to be that ggplot2 is sensitive to the window size at the time of rendering to a file. Brian and I are doing some tests right now with different window sizes and it's showing pronounced differences. More details as we get some samples.

-Wil

William Doane http://DrDoane.com

On 2011 Sep 01, at 00:41, rmpruzek wrote:

Wil, I see no difference in yours other than jittering (as in my case). b


From: WilDoane reply@reply.github.com To: rmpruzek@yahoo.com Sent: Thursday, September 1, 2011 12:17 AM Subject: Re: [granovaGG] PDF outputs appear different on different systems (#109)

So that everyone can see at least one other version, here are my 2 plots:

http://DrDoane.com/screenshots/testplot1-20110901-001528.pdf

http://DrDoane.com/screenshots/testplot2-doane-20110901-001642.pdf

-Wil

William Doane http://DrDoane.com

On 2011 Sep 01, at 00:13, briandk wrote:

Here's the test code I'd like people to try. If possible, email me your results for testplot1.pdf and testplot2.pdf

https://gist.github.com/1185420

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1964751

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1964779

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1964884

rmpruzek commented 13 years ago

Brian, I've done it, both ggsave and pdf for testplt1 and testplt2. The same ... so it seems. b (But not what I got before (which seemed like a zoom out from this).) b ps. I'm calling it a night. Thanks for your work.


From: briandk reply@reply.github.com To: rmpruzek@yahoo.com Sent: Thursday, September 1, 2011 12:13 AM Subject: Re: [granovaGG] PDF outputs appear different on different systems (#109)

Here's the test code I'd like people to try. If possible, email me your results for testplot1.pdf and testplot2.pdf

https://gist.github.com/1185420

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1964751

briandk commented 13 years ago

@rmpruzek - Wil and I figured out that it's a subtle issue related to R graphics. In short, any of R's default graphical outputs (pdf() and jpeg(), for example) accept height and width arguments. The values for height and width matter for the output.

It also turns out that when you call ggsave() without explicitly providing height and width arguments, it assumes the height and width you want are the height and width of your R graphics window. Since you (I believe) have a much larger monitor than Wil and I do, your ggsave() calls are using larger dimensions by default.

With the code demonstration below, I can conclusively prove three things:

  1. This is an R graphics problem, not a granovaGG problem
  2. I can replicate the same effects you're seeing on classic granova graphics too
  3. There is an easy solution: explicitly pass width and height arguments to ggsave(), pdf(), and other graphics device calls.

The entire source code I used is included via a link at the bottom of this post. For now, let me lead you through:

WARNING: If you're going to run this code, make a test plots directory

I made a folder called testplots on my desktop BEFORE running the R code.

1. Start clean and load the packages

# 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)

2. Compare a 7-inch by 7-inch test plot to a 15-inch by 15-inch one

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)

# 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)

The output looks like this, with testplot1.pdf on the left and testplot2.pdf on the right:

Side by side comparison of granovagg.1w produced with two different sets of height/width arguments

3. Verify that the same effects can be seen on classic granova output

# 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()

Side by side comparison of granova.1w plots produces with two different sets of height/width arguments

The source code to produce these images

Is available here: https://gist.github.com/1185420

rmpruzek commented 13 years ago

Brian, This is informative, and appears to resolve the key issues. Nice to have it. Again, you (w/ Wil) have shown what I like most to see in students and colleagues: growth and developed skill that solves problems! Because this post is really quite important in my view, I'd like to see it posted (where?) on github, and sent to the team. Best, bob


From: briandk reply@reply.github.com To: rmpruzek@yahoo.com Sent: Thursday, September 1, 2011 2:18 AM Subject: Re: [granovaGG] PDF outputs appear different on different systems (#109)

@rmpruzek - Wil and I figured out that it's a subtle issue related to R graphics. In short, any of R's default graphical outputs (pdf() and jpeg(), for example) accept height and width arguments. The values for height and width matter for the output.

It also turns out that when you call ggsave() without explicitly providing height and width arguments, it assumes the height and width you want are the height and width of your R graphics window. Since you (I believe) have a much larger monitor than Wil and I do, your ggsave() calls are using larger dimensions by default.

With the code demonstration below, I can conclusively prove three things:

  1. This is an R graphics problem, not a granovaGG problem
  2. I can replicate the same effects you're seeing on classic granova graphics too
  3. There is an easy solution: explicitly pass width and height arguments to ggsave() and pdf() calls.

The entire source code I used is included via a link at the bottom of this post. For now, let me lead you through:

WARNING: If you're going to run this code, make a test plots directory

I made a folder called testplots on my desktop BEFORE running the R code.

1. Start clean and load the packages

# 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)

2. Compare a 7-inch by 7-inch test plot to a 15-inch by 15-inch one

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)

# 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)

The output looks like this, with testplot1.pdf on the left and testplot2.pdf on the right:

Side by side comparison of granovagg.1w produced with two different sets of height/width arguments

3. Verify that the same effects can be seen on classic granova output

# 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()

Side by side comparison of granova.1w plots produces with two different sets of height/width arguments

The source code to produce these images

Is available here: https://gist.github.com/1185420

Reply to this email directly or view it on GitHub: https://github.com/briandk/granovaGG/issues/109#issuecomment-1965312

briandk commented 13 years ago

In light of my discussion and @rmpruzek's comments, I'm closing this issue.