Ada*_*m_G 2 r ggplot2 gridextra ggpubr
我正在使用ggarrange和annotate_figure并排显示两个图。在我的实际代码中,每个子图都有不同的标题,但在整个图的顶部需要一个通用的标题和副标题。
我知道如何在顶部添加文本,但是如何添加两行,每行具有不同的字体(例如顶部标题应该大/粗体,第二行/副标题应该更小并且是常规字体)?
这是我制作标题的方法。text_grob有没有办法在 中添加 a top?
library(tidyverse)
library(ggpubr)
df <- data.frame()
plot1 <- ggplot(df) + geom_point() + xlim(0, 10) + ylim(0, 100)
plot2 <- ggplot(df) + geom_point() + xlim(0, 10) + ylim(0, 100)
all.plots <- ggarrange(plot1, plot2)
annotate_figure(all.plots,
top=text_grob("Antibiotic Effectiveness"))
Run Code Online (Sandbox Code Playgroud)
您可以使用plotmath 为text_grob 创建表达式。参见?plotmath。
library(tidyverse)
library(ggpubr)
df <- data.frame(x=runif(10,0,10), y=runif(10,0,100))
plot1 <- ggplot(df) + geom_point(aes(x=x, y=y)) + xlim(0, 10) + ylim(0, 100)
plot2 <- ggplot(df) + geom_point(aes(x=x, y=y)) + xlim(0, 10) + ylim(0, 100)
all.plots <- ggarrange(plot1, plot2)
# construct plotmath expression
title <- expression(atop(bold("Figure 1:"), scriptstyle("This is the caption")))
annotate_figure(all.plots,
top=text_grob(title))
Run Code Online (Sandbox Code Playgroud)

由reprex 包(v0.3.0)于 2019-10-02 创建
| 归档时间: |
|
| 查看次数: |
4935 次 |
| 最近记录: |