Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何从ggplot2图例中删除线条美学?_R_Ggplot2_Legend - Fatal编程技术网

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()