[英]How can I add a title to a list of plots based on values of the listed df's?
Here's that illustrates the obstacle I'm facing.这说明了我面临的障碍。
library(tidyverse)
co2_list <- CO2 %>%
group_split(Type)
reprex_fun <- function(x){
x %>%
ggplot(aes(conc, uptake)) +
geom_point() +
facet_wrap(~Plant, ncol = 2)
}
lapply(co2_list, reprex_fun)
Since the listed dataframes are based on the Type value, How can I add the corresponding title with the type, to the plots I just made?由于列出的数据框是基于 Type 值的,我怎样才能将相应的标题与类型添加到我刚刚制作的图中?
You can also try labs
, similar to ggtitle
:您也可以尝试
labs
,类似于ggtitle
:
#Data
data("CO2")
#Plot
co2_list <- CO2 %>%
group_split(Type)
#Function
reprex_fun <- function(x){
x %>%
ggplot(aes(conc, uptake)) +
geom_point() +
labs(title = unique(x$Type))+
facet_wrap(~Plant, ncol = 2)
}
#Plots
lapply(co2_list, reprex_fun)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.