首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用ggforestplot/geom_stripes控制条纹透明度?

如何使用ggforestplot/geom_stripes控制条纹透明度?
EN

Stack Overflow用户
提问于 2022-04-05 02:29:46
回答 1查看 220关注 0票数 0

我希望有一些帮助,以修改条纹透明度/阴影的颜色,在全球森林绘图包。请看下面的图片(“亮”表示我需要亮的条纹)。修改以下代码的最佳方法是什么?

非常感谢你的指点!

代码语言:javascript
运行
复制
# 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))
EN

Stack Overflow用户

发布于 2022-04-05 04:06:09

问题是ggforestplot::forestplot已经为oddeven添加了一个带有硬编码默认值的geom_stripes层。添加另一个geom_stripes将不会对这个底层条纹层产生影响,并且只会导致点、垂直线、.的过度绘制。要调整透明度,您可以(而且TBMK需要)黑入内部部件:

代码语言:javascript
运行
复制
# 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

票数 3
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71745719

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档