当包没有此功能时如何在 R 中调整 bodymap 的线宽

How to adjust line width of a bodymap in R when package doesn't have this function

我正在使用 CHOIRBM 软件包 (https://github.com/emcramer/CHOIRBM) 并制作了一张 body 地图来查看 body 中的患病率和疼痛。我想改变 body 地图本身的线条粗细,但包裹似乎没有该选项。该软件包是在 ggplot 软件包之上构建的,因此我想知道是否有某种我不知道的 ggplot 命令可以执行此操作。 这是代码。请注意,id= body 的区域,Percent= 疼痛的百分比,以及 group= body 的前面或后面。包裹要求以这种方式标记物品。这就是地图的样子:

painF %>% filter(value == 1) %>% select(id, Percent, group) %>%                
plot_female_choirbm(value="Percent") +
scale_fill_gradient(low="white", high="red", limits=c(0,10)) +
theme(legend.position = "bottom") +
labs(fill = "Prevelance of pain (%)")+                                
ggtitle(" " , subtitle="Female")+
theme(plot.subtitle=element_text(face="bold", hjust=0.5))

似乎没有直接的方法可以做到这一点,但您可以间接地做到这一点,因为它最终是在 geom_polygon 的基础上构建的。先存图:

p <- plot_female_choirbm(values, "value")  +
scale_fill_gradient(low="white", high="red", limits=c(0,10)) +
theme(legend.position = "bottom") +
labs(fill = "Prevelance of pain (%)")+                                
ggtitle(" " , subtitle="Female")+
theme(plot.subtitle=element_text(face="bold", hjust=0.5))

p

现在覆盖多边形图层的尺寸美学:

p$plot_env$p$layers[[1]]$aes_params$size <- 0.5

p

请注意,多边形可能不再完全重叠。


从 GitHub 示例生成的数据

library(CHOIRBM)

# generate some random example data
set.seed(123)
ids <- as.character(c(seq.int(101, 136, 1), seq.int(201, 238, 1)))
values <- data.frame(
  id = ids
  , value = runif(length(ids), 0, 10)
  , ucolors = rainbow(length(ids))
  , group = ifelse(as.numeric(ids) < 200, "Front", "Back")
)