简体   繁体   English

R:使用ggplot2 + ggExtra + cowplot进行绘制时删除边框

[英]R: Remove border when plotting with ggplot2 + ggExtra + cowplot

I couldn't find the way not to plot the outer frame when combining graphs through ggplot2 + ggExtra + cowplot. 通过ggplot2 + ggExtra + cowplot组合图形时,我找不到不绘制外部框架的方法。 I am not sure where I have to tell R, but suspect the issue to lie in ggExtra. 我不确定我必须在哪里告诉R,但是怀疑问题出在ggExtra。 Here is an example: 这是一个例子:

require(ggplot2)
require(cowplot)
require(ggExtra)

# Creat a graph
A <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) +     geom_point(size = 2.5)

# Add marginal histogram
B <- ggExtra::ggMarginal(A,type = 'histogram', margins = 'x', size = 9)

# Combine through cowplot
combo <- plot_grid(B,B,labels=c("A","B"))
plot(combo) # looks fine

# Re-combine through cowplot
plot_grid(B,combo,ncol=1,rel_heights = c(2,3)) # that's where I got an unwanted nasty frame around 'combo'

即下面的2个图表

Any hint would be greatly appreciated! 任何提示将不胜感激!

p <- plot_grid(B,combo,ncol=1,rel_heights = c(2,3))
p <- p + panel_border(remove = TRUE)

https://rdrr.io/cran/cowplot/man/panel_border.html https://rdrr.io/cran/cowplot/man/panel_border.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM