繁体   English   中英

geom_smooth不会绘制最佳拟合线

[英]geom_smooth does not plot line of best fit

我希望这个问题不会重复。 我试图在发布之前根据站点的要求找到答案,但是由于我太新了,所以帮助论坛对我来说太陌生了。

遵循Wickham的R用于数据可视化之后 ,我轻松地将geom_point用于集成数据集mpg:

平滑适合集成数据集

简单的参考代码:

ggplot(data = mpg)+
    geom_smooth(mapping = aes(x=displ, y=hwy))+
    geom_point(mapping = aes(x=displ, y=hwy))

受到这个很酷的情节的刺激,我尝试对一些个人研究数据进行相同的处理,这些数据描述了五个时间点(A,b,c,d,e而不是数值数据)上的inteferon-beta生产。

我使用了相同的代码,本质上是:

ggplot(data = ifnonly)+
    geom_smooth(mapping = aes(x=HOURS, y=IFNB))+
    geom_point(mapping = aes(x=HOURS, y=IFNB))

五个时间点的IFNb表达

不幸的是,该行不显示。 实际上,在添加geom_point函数之前,不会显示任何内容。 我在这里想念什么? 是否需要更复杂的代码,或者我可以在此函数和ggplot的将来使用中应用一些细微之处?

我认为您应该通过以下一行代码获得所需的输出

          library(ggplot2)
          ggplot(mtcars, aes(disp,mpg))+geom_smooth() # one line code where I have mentioned data is mtcars , and disp as x axis and mpg as y axis you could get following output  
    # please check this link for output 

没有geom_point的o / p

         library(ggplot2)
          ggplot(mtcars, aes(disp,mpg))+geom_smooth()+geom_point()

o / p与geom_point

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM