gpt4 book ai didi

删除 ggplot2 geom_pointrange 中的附加透明度

转载 作者:行者123 更新时间:2023-12-04 17:28:34 26 4
gpt4 key购买 nike

我正在生成效果大小和相关置信区间的数字,例如:

enter image description here

使用 ggplot2 的 geom_pointrange。我希望第二条点线是透明的,但透明度不是相加的(即只是一种纯色,而不是通过点显示为较暗的线)。

我应用自定义颜色:

+ scale_colour_manual(values=c("#66CD0050","#66CD00"))

谢谢你的任何建议。

最佳答案

thelatemail 的评论是针对这个问题的。使用 scale_color_manual调用定义颜色将生成请求的图像。请参阅下面的示例。

library(ggplot2)

dat <- data.frame(effect_size = c(-0.1, -0.1),
lcl = c(-0.5, -0.2),
ucl = c(0.3, -0.01),
sla = c("SLA1", "SLA2"))

ggplot(dat) +
theme_classic() +
aes(x = sla, y = effect_size, ymin = lcl, ymax = ucl, color = sla) +
geom_pointrange() +
geom_hline(yintercept = 0, linetype = 2) +
scale_color_manual(values = c("SLA1" = "#66CD00",
"SLA2" = "#cfefb0")) +
coord_flip()

packageVersion("ggplot2")
# [1] ‘2.2.1.9000’

enter image description here

关于删除 ggplot2 geom_pointrange 中的附加透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18777278/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com