如何使用牛皮图创建图形而不激活空白窗口

时间:2018-05-07 07:25:38

标签: r ggplot2 cowplot

这是一个代表:

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

当我运行上面的行时,会打开一个空白窗口。我怎么能禁用它?

我的sessionInfo是:

  

sessionInfo()       R版本3.4.4(2018-03-15)       平台:x86_64-pc-linux-gnu(64位)       运行于: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   

我从CRAN下载了tar ball - cowplot_0.9.2.tar.gz并安装了它。我仍然有同样的问题:

我的sessionInfo是:

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

1 个答案:

答案 0 :(得分:0)

从您的会话信息中,我可以看到您正在运行cowplot版本0.9.1。此版本存在在特定条件下弹出空白窗口的问题。如果升级到0.9.2(CRAN上的当前版本),问题就会消失。