0

Here is a reprex:

require(cowplot)

plot.mpg <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) + 
geom_point(size=2.5)

plot.diamonds <- ggplot(diamonds, aes(clarity, fill = cut)) + 
geom_bar()+theme(axis.text.x = element_text(angle=70, vjust=0.5))

testing <- plot_grid(plot.mpg, plot.diamonds, labels = c('A', 'B'))

When I run the above lines a blank window opens up. How can I disable that ?

My sessionInfo is:

sessionInfo() R version 3.4.4 (2018-03-15) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

locale:
[1] LC_CTYPE=en_IN       LC_NUMERIC=C         LC_TIME=en_IN       
[4] LC_COLLATE=en_IN     LC_MONETARY=en_IN    LC_MESSAGES=en_IN   
[7] LC_PAPER=en_IN       LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=en_IN LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] cowplot_0.9.1 ggplot2_2.2.1

loaded via a namespace (and not attached):
[1] labeling_0.3     colorspace_1.3-2 scales_0.5.0     compiler_3.4.4  
[5] lazyeval_0.2.1   plyr_1.8.4       gtable_0.2.0     tibble_1.3.4    
[9] Rcpp_0.12.15     grid_3.4.4       digest_0.6.13    rlang_0.2.0     
[13] munsell_0.4.3   

I downloaded the tar ball - cowplot_0.9.2.tar.gz from CRAN and installed it. I still have the same problem :

My sessionInfo is:

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

locale:
[1] LC_CTYPE=en_IN       LC_NUMERIC=C         LC_TIME=en_IN       
[4] LC_COLLATE=en_IN     LC_MONETARY=en_IN    LC_MESSAGES=en_IN   
[7] LC_PAPER=en_IN       LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=en_IN LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] cowplot_0.9.2      ggplot2_2.2.1.9000

loaded via a namespace (and not attached):
[1] Rcpp_0.12.16      viridisLite_0.3.0 digest_0.6.15     withr_2.1.2      
[5] grid_3.4.4        plyr_1.8.4        gtable_0.2.0   scales_0.5.0.9000
[9] pillar_1.2.2      rlang_0.2.0.9001  lazyeval_0.2.1    labeling_0.3     
[13] munsell_0.4.3     compiler_3.4.4    colorspace_1.3-2  tibble_1.4.2     
> 
user2338823
  • 501
  • 1
  • 3
  • 16
  • I just ran your code, & did not get a blank window. Does this phenomenon persist if you restart R & run everything in a clean environment? – Z.Lin May 07 '18 at 08:24
  • Yes I started a fresh R session and pasted the above code in it. Still get a blank window. I have Ubuntu 14.04. – user2338823 May 07 '18 at 08:41
  • What software are you using? I've now tried this in both RStudio & RGui. RGui produces the blank window--though the code responsible for that is all the way inside `plot_to_gtable`, & I don't think it can be turned off in `plot_grid`... – Z.Lin May 07 '18 at 08:56
  • I am using R from a Terminal in Ubuntu. – user2338823 May 07 '18 at 09:04
  • This should be fixed as of cowplot 0.9.2. What is your output of `sessionInfo()`? – Claus Wilke May 07 '18 at 15:35
  • Dear Claus, please see sessionInfo() in my edit. – user2338823 May 08 '18 at 04:24

1 Answers1

0

From your session info, I can see that you’re running cowplot version 0.9.1. This version has the problem of blank windows popping up under certain conditions. If you upgrade to 0.9.2 (the current version on CRAN) the problem should go away.

Claus Wilke
  • 16,992
  • 7
  • 53
  • 104
  • Dear Claus, I upgraded but I still see the blank window. I have added my new sessionInfo() in the new edit. – user2338823 May 08 '18 at 06:14
  • Hm, not sure what's happening. If you're feeling adventurous, you could try out the github version (`devtools::install_github("wilkelab/cowplot"`), as the code in question has changed a lot between 0.9.2 and master. However, this will require R 3.5.0. I would also recommend updating ggplot2 to the very latest development code. – Claus Wilke May 08 '18 at 14:30