R 如何从ggplot2图例中删除线条美学?
我有一个绘图,我想为点使用不同的颜色,但根据所有点绘制线性回归:R 如何从ggplot2图例中删除线条美学?,r,ggplot2,legend,R,Ggplot2,Legend,我有一个绘图,我想为点使用不同的颜色,但根据所有点绘制线性回归: library(ggplot2) set.seed(1) df <- data.frame(x=rnorm(100), y=rnorm(100), group=factor(rep(1:2,each=50))) ggplot(df,aes(x=x,y=y,color=group)) + stat_smooth(aes(group=1), meth
library(ggplot2)
set.seed(1)
df <- data.frame(x=rnorm(100),
y=rnorm(100),
group=factor(rep(1:2,each=50)))
ggplot(df,aes(x=x,y=y,color=group)) +
stat_smooth(aes(group=1), method="lm", fill=NA) +
geom_point() + theme_bw()
库(ggplot2)
种子(1)
df您只需将show.legend=FALSE
添加到stat\u smooth
:
ggplot(df, aes(x = x, y = y, color = group, group = 1)) +
geom_smooth(method = "lm", se = FALSE, show.legend = FALSE) +
geom_point() +
theme_bw()