【发布时间】:2021-08-18 14:14:11
【问题描述】:
我有一个生成 8 个 ggplot/ggiraph 地图的功能。我想按照它们生成的顺序对数字从 8 到 16 进行编号。我试图构建一个用于标记数字的函数,但无济于事。
#Snippet of Map Function
demozipfx <- function(x) {
out <- ggplot(data = x) +
geom_sf_interactive(aes(geometry = geometry), fill = "grey80", color = "white") +
geom_sf_interactive(aes(fill = as.numeric(rate), tooltip= tooltip),
data_id= zip),
colour = "white")+
geom_sf(
data = county.simp,
fill = NA,
color= "grey20",
lwd = 1) +
scale_fill_viridis_c_interactive(
name = "% Population Fully\nVaccinated",
aesthetics = "fill",
option = "D",
direction = -1,
na.value = "grey80",
labels = percent) +
labs(title = title)) +
theme(plot.title = element_text(hjust = 0.5))
return(out)
}
#output
zipdemomaps.l <- lapply(zip.demo.mapdat, demozipfx)
zipdemomaps <- ggiraph(ggobj= plot_grid(plotlist= zipdemomaps.l[1:8], nrow=4), width_svg = 12, height_svg = 20)
【问题讨论】:
标签: r function ggplot2 tags figure