在用ggtext
和group_split
(〜ggplot ...)创建图时,我正在努力使用map
。如何传递值而不是名称。下面一个代表。非常感谢!
library(tidyverse)
library(ggtext)
library(patchwork)
list_plot <- mtcars %>%
group_split(gear) %>%
map(~ggplot(.)+
labs(title=paste("Number of gears:",
unique(.x$gear)))+
geom_bar(aes(x=carb),
stat="count")+
theme(plot.title = element_markdown())
)
patchwork::wrap_plots(list_plot)+
plot_layout(ncol=1)
list_plot <- mtcars %>%
group_split(gear) %>%
map(~ggplot(.)+
labs(title=paste("Number of gears: <span style='color:orange'> unique(.x$gear) </span>"))+
geom_bar(aes(x=carb),
stat="count")+
theme(plot.title = element_markdown())
)
patchwork::wrap_plots(list_plot)+
plot_layout(ncol=1)
由reprex package(v0.3.0)于2019-11-05创建