gpt4 book ai didi

r - 避免图例中的彩色框

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

如何避免图例中的彩色框?我只是希望它是 Line1Line2没有盒子。

library(ggplot2)
ggplot(diamonds, aes(x=depth)) +
geom_density(aes(color = "Line1"))+
geom_function(fun=function(x)
dnorm(x,
mean=mean(diamonds$depth),
sd=sd(diamonds$depth)),
aes(color="Line2"))+
scale_color_manual(" ", values=c(Line1="green", Line2="red"))
谢谢!

最佳答案

这可以通过添加选项 show.legend = FALSE 来实现。至 geom_density :

library(ggplot2)
ggplot(diamonds, aes(x=depth)) +
geom_density(aes(color = "Line1"), show.legend = FALSE)+
geom_function(fun=function(x)
dnorm(x,
mean=mean(diamonds$depth),
sd=sd(diamonds$depth)),
aes(color="Line2"))+
scale_color_manual(" ", values=c(Line1="green", Line2="red"))

关于r - 避免图例中的彩色框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64372128/

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