在边框外添加注释或标题

问题描述 投票:0回答:1

在此示例中,我为三个图添加了边框:

library(ggplot2)
library(patchwork)
theme_border <- theme_gray() + 
  theme(plot.background = element_rect(fill = NA, colour = 'black',
                                       size = 1, linetype = "dashed"))

ggplot() + 
ggplot() + 
ggplot() + 
    plot_layout(ncol=1, guides = "collect") + 
    plot_annotation(title = "Pred Sp", theme = theme_border)

创建于 2024-04-18,使用 reprex v2.0.2

剧情标题在里面。是否可以将其放置在边界之外?另外,可以画圆角边框吗?

r ggplot2 patchwork
1个回答
0
投票

我们可以使用

patchwork::wrap_elements()
创建带边框的图,然后添加标题。

我不知道如何使边框角变圆(简单)。

library(ggplot2)
library(patchwork)

theme_border <- theme_gray() + 
  theme(plot.background = element_rect(fill = NA, colour = 'black', 
                                       linewidth= 1, linetype = "dashed"))

wrap_elements(ggplot() +
              ggplot() +
              ggplot() +
                plot_layout(ncol=1, guides = "collect")+
                plot_annotation(theme = theme_border)) +
  plot_annotation(title = "Pred Sp")

创建于 2024-04-18,使用 reprex v2.0.2

© www.soinside.com 2019 - 2024. All rights reserved.