我希望有一些帮助,以修改条纹透明度/阴影的颜色,在全球森林绘图包。请看下面的图片(“亮”表示我需要亮的条纹)。修改以下代码的最佳方法是什么?
非常感谢你的指点!
# Load and attach the packages
library(ggforestplot)
library (ggplot2)
library(tidyverse)
# Reproducible dataset
df <- ggforestplot::df_linear_associations %>% filter( trait == "BMI", dplyr::row_number() <= 30)
# Draw a forestplot
ggforestplot::forestplot(
df = df,
name = name,
estimate = beta,
se = se)+
geom_point(shape = 15, size = 5) +
geom_stripes( odd ="#00000000", even = "#00000000") +
theme(legend.position="none",
panel.background = element_rect(fill = "transparent",colour = NA),
plot.background = element_rect(fill = "transparent",colour = NA))
发布于 2022-04-05 04:06:09
问题是ggforestplot::forestplot
已经为odd
和even
添加了一个带有硬编码默认值的geom_stripes
层。添加另一个geom_stripes
将不会对这个底层条纹层产生影响,并且只会导致点、垂直线、.的过度绘制。要调整透明度,您可以(而且TBMK需要)黑入内部部件:
# Load and attach the packages
library(ggforestplot)
library(ggplot2)
library(tidyverse)
# Reproducible dataset
df <- ggforestplot::df_linear_associations %>% filter( trait == "BMI", dplyr::row_number() <= 30)
# Draw a forestplot
p <- ggforestplot::forestplot(
df = df,
name = name,
estimate = beta,
se = se) +
geom_point(shape = 15, size = 5) +
theme(legend.position="none",
panel.background = element_rect(fill = "transparent"))
p$layers[[1]]$aes_params$odd <- "#00000000"
p
https://stackoverflow.com/questions/71745719
复制相似问题