我已经设法使用grid.arrange创建一个2x2的绘图:
library(gridExtra)
grid.arrange(p1,p3,p2,p4, ncol=2, nrow=2, top = "Daily QC: Blue")
Run Code Online (Sandbox Code Playgroud)
这个多重图的主要标题非常小.有没有办法更改标题文字大小和字体.
默认对齐方式是使ggplot标题与plot.background元素左对齐。其他人指出,您可以使用plot.title = element_text(hjust = 0.5)来居中标题。
但是,我想使标题在整个面板中居中,而不是只与情节相对。过去,我通过修改hjust来推动标题以使其居中显示,从而实现了这一点,但是的值hjust取决于标题的长度,这使得在批量生产图形时进行设置非常繁琐。
是否可以始终将ggplot的标题元素设置为在panel.background中居中?
library(reprex)
library(tidyverse)
data(mtcars)
mtcars %>%
rownames_to_column(var = "model") %>%
top_n(8,wt) %>%
ggplot(aes(x =model, y = wt))+
geom_col()+
coord_flip()+
labs(title="This title is left-aligned to the plot")
Run Code Online (Sandbox Code Playgroud)

mtcars %>%
rownames_to_column(var = "model") %>%
top_n(8,wt) %>%
ggplot(aes(x =model, y = wt))+
geom_col()+
coord_flip()+
labs(title="This title is center-aligned to the plot width.")+
theme(plot.title = element_text(hjust = 0.5))
Run Code Online (Sandbox Code Playgroud)

mtcars %>%
rownames_to_column(var = "model") %>%
top_n(8,wt) %>%
ggplot(aes(x =model, y = …Run Code Online (Sandbox Code Playgroud)