Created
April 25, 2016 20:36
-
-
Save infotroph/c68fc7a3f8594473361f87e2a348ddf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Demo of intermittent plotting failures. | |
# Apparent requirements: | |
# * Interactive session (I'm in R.app using Quartz graphics) | |
# * Arranging multiple figures using gridExtra::arrangeGrob | |
# * Very different figure complexities | |
# (i.e one plot big enough to have a rendering lag, one that renders much faster.) | |
# * No graphics device open at beginning of arrangeGrob call | |
# Gentle reader, can you reproduce this on your machine? | |
# Can you help me identify where the problem is? | |
set.seed(34565) | |
library(ggplot2) | |
library(gridExtra) | |
library(grid) | |
p1 = ggplot(diamonds, aes(x, price))+geom_point() | |
p2 = ggplot(mtcars, aes(wt, mpg))+geom_point() | |
# Examples that usually fail: | |
# grid.draw exits with no error, but p1 is only partially drawn | |
graphics.off() | |
pp=arrangeGrob(p1, p2) | |
grid.draw(pp) | |
graphics.off() | |
pp=arrangeGrob(p1, p2) | |
Sys.sleep(1e-3) | |
grid.draw(pp) | |
# Usually succeeds | |
graphics.off() | |
pp=arrangeGrob(p1, p2) | |
Sys.sleep(1) | |
grid.draw(pp) | |
# Always succeeds | |
dev.new() | |
pp=arrangeGrob(p1, p2) | |
grid.draw(pp) | |
# "Always" succeeds (thought I saw it fail a few times early in debugging, but now can't reproduce) | |
graphics.off() | |
grid.arrange(p1, p2) | |
sessionInfo() | |
# R version 3.2.4 (2016-03-10) | |
# Platform: x86_64-apple-darwin13.4.0 (64-bit) | |
# Running under: OS X 10.11.3 (El Capitan) | |
# | |
# locale: | |
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 | |
# | |
# attached base packages: | |
# [1] grid stats graphics grDevices utils datasets methods | |
# [8] base | |
# | |
# other attached packages: | |
# [1] gridExtra_2.2.1 ggplot2_2.1.0 | |
# | |
# loaded via a namespace (and not attached): | |
# [1] labeling_0.3 colorspace_1.2-6 scales_0.4.0 plyr_1.8.3 | |
# [5] tools_3.2.4 gtable_0.2.0 Rcpp_0.12.4 munsell_0.4.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Saw email on R-Sig-Mac.
Updated to R 3.3.0 this morning and it still happening. So AFAIK whatever is causing it hasn't been fixed.