gpt4 book ai didi

r - ggplot图例键颜色和透明度

转载 作者:行者123 更新时间:2023-12-04 01:47:44 24 4
gpt4 key购买 nike

我正在绘制多条线,它们是透明的。但是,我不希望图例颜色具有任何透明度。我尝试了 override.aes 但没有成功。
这类似于 question ,但本质上相反。

目前我有这个

# plot all the lines
plt <- ggplot(dt_plot,aes(x = x, y = mean_change, color = model)) +
geom_line(aes(group = interaction(model, boot)), alpha = 0.3) +
xlab('houses/acre') +
ylab('change in % prevalance') +
scale_colour_manual(values=cbbPalette) +
theme_few() +
theme(text=element_text(size=10),legend.title = element_blank()) +
guides(fill = guide_legend(override.aes= list(alpha = 1)))

transparent lines and transparent legend colors

干杯

最佳答案

除了一个小问题外,您的方法非常好:您需要

guides(color = guide_legend(override.aes = list(alpha = 1)))

相反,因为 geom_line 没有 fill 美学。

关于r - ggplot图例键颜色和透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54580202/

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