当尝试将geom_xspline
fromggalt
与ggarrange
from结合使用时ggpubr
,输出为空白,并且在使用 清除之前无法制作其他绘图dev.off()
。
在我的用例中,我希望geom_xspline
替换geom_line
我的 ggplot 对象中的一些存在。有人知道使用从其他 R 包添加的 geoms 的问题吗?
这是一些要比较的代码,实际上没有什么有趣的,只是为了给出一个可重现的示例:
初始工作代码 w/ogeom_xspline
library(ggplot2)
library(ggpubr)
myplot = ggplot(data = mtcars, aes(x = wt, y = mpg)) +
geom_line()
ggarrange(myplot, myplot) # Works and outputs fine
ggalt
打包失败的代码
library(ggalt)
library(ggplot2)
library(ggpubr)
myplot = ggplot(data = mtcars, aes(x = wt, y = mpg)) +
geom_xspline()
ggarrange(myplot, myplot) # Output becomes blank and freezes the plot panel
替代方法ggarrange
我没有尝试使用此链接中的函数
,grid_arrange_shared_legend
该函数使用grid
and gridExtra
。但是,我仍然很好奇为什么ggarrange
不起作用。
这是我的会话信息:
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggpubr_0.1.8 magrittr_1.5 ggplot2_3.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 pillar_1.3.0 compiler_3.5.1 RColorBrewer_1.1-2 plyr_1.8.4 bindr_0.1.1
[7] tools_3.5.1 extrafont_0.17 tibble_1.4.2 gtable_0.2.0 pkgconfig_2.0.1 rlang_0.2.1
[13] rstudioapi_0.7 yaml_2.2.0 bindrcpp_0.2.2 Rttf2pt1_1.3.7 withr_2.1.2 dplyr_0.7.6
[19] maps_3.3.0 grid_3.5.1 ggalt_0.4.0 tidyselect_0.2.4 cowplot_0.9.3 glue_1.3.0
[25] R6_2.2.2 purrr_0.2.5 extrafontdb_1.0 scales_1.0.0 MASS_7.3-50 assertthat_0.2.0
[31] proj4_1.0-8 colorspace_1.3-2 labeling_0.3 KernSmooth_2.23-15 ash_1.0-15 lazyeval_0.2.1
[37] munsell_0.5.0 crayon_1.3.4
快速添加,如果我将对象转换为 a ggplotGrob()
,它将与 一起使用ggarrange
,但当我尝试使用时它会失败common.legend = T
。