簡體   English   中英

ggplot圖例鍵顏色和透明度

[英]ggplot legend key color and transparency

我正在繪制多條線,它們是透明的。 但是,我不希望圖例顏色具有任何透明度。 我嘗試了override.aes但沒有成功。 這與this 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)))

透明線條和透明圖例顏色

干杯

除了一個小問題外,您的方法非常好:您需要

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

相反,因為geom_line沒有fill美感。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM