如何为每个组应用geom_smooth()? [英] How to apply geom_smooth() for every group?

查看:110
本文介绍了如何为每个组应用geom_smooth()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为每个组申请geom_smooth()?

在程序中使用 facet_wrap()
如此绘制每个组图。

我想整合图并获得一个图。

  ggplot(data = iris,aes(x = Sepal.Length,y = Petal.Length))+ 
geom_point(aes(color = Species))+
geom_smooth(method =nls ,公式= y〜a * x + b,se = F,
method.args = list(start = list(a = 0.1,b = 0.1)))+
facet_wrap(〜Species)


解决方案

您必须将所有变量放入ggplot
$ g $ p $ ggplot(data = iris,aes(x = Sepal。长度,y = Petal.Length,color = Species))+
geom_point()+
geom_smooth(method =nls,formula = y〜a * x + b,se = F,
method.args = list(start = list(a = 0.1,b = 0.1)))


How to apply geom_smooth() for every group ?

under program is use facet_wrap(), so plot every group 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)

解决方案

You have to put all your variable in ggplot aes():

ggplot(data = iris, aes(x = Sepal.Length,  y = Petal.Length, color = Species)) +
  geom_point() +
  geom_smooth(method = "nls", formula = y ~ a * x + b, se = F,
              method.args = list(start = list(a = 0.1, b = 0.1)))

这篇关于如何为每个组应用geom_smooth()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆