R 向ggplot 2添加平滑器
我使用以下代码使用ggplot2在r中创建了一个绘图:R 向ggplot 2添加平滑器,r,ggplot2,R,Ggplot2,我使用以下代码使用ggplot2在r中创建了一个绘图: g <- ggplot(newdata, aes(MVPAper, FMI) + geom_smooth(method = 'lm')) g您不需要同时使用geom\u smooth()和stat\u smooth()。试试这个: library(tidyverse) df <- diamonds %>% filter(price < 10000, carat < 2.5) g <- ggp
g <- ggplot(newdata, aes(MVPAper, FMI) +
geom_smooth(method = 'lm'))
g您不需要同时使用geom\u smooth()
和stat\u smooth()
。试试这个:
library(tidyverse)
df <- diamonds %>% filter(price < 10000, carat < 2.5)
g <- ggplot(df, aes(carat, price, color = cut))
g +
geom_point() +
geom_smooth(method = 'lm') +
facet_grid(cut ~ .) +
theme_bw()
库(tidyverse)
df%过滤器(价格<10000,克拉<2.5)
g应添加一个可复制的示例:
library(tidyverse)
df <- diamonds %>% filter(price < 10000, carat < 2.5)
g <- ggplot(df, aes(carat, price, color = cut))
g +
geom_point() +
geom_smooth(method = 'lm') +
facet_grid(cut ~ .) +
theme_bw()