1

通过ggplot2 + ggExtra + cowplot组合图形时,我找不到不绘制外框的方法。我不确定我必须在哪里告诉 R,但怀疑问题出在 ggExtra 上。这是一个例子:

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个图表

任何提示将不胜感激!

4

1 回答 1

2
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

于 2018-04-26T05:53:13.867 回答