How can I apply geom_smooth()
for every group ?
The code below uses facet_wrap()
, so plots every group in a separate graph.
I would like to integrate the graph, and get one graph.
ggplot(data = iris, aes(x = Sepal.Length, y = Petal.Length)) +
geom_point(aes(color = Species)) +
geom_smooth(method = "nls", formula = y ~ a * x + b, se = F,
method.args = list(start = list(a = 0.1, b = 0.1))) +
facet_wrap(~ Species)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…