本文介绍了geom_smooth()有哪些可用的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ggplot2中的geom_smooth().

在Hadley Wickham的书("ggplot2-用于数据分析的优雅图形")中,有一个示例(第51页),其中使用了method="lm".在在线手册中,没有提到method参数.我看到使用method='loess'的其他人在Google上的搜索结果(和此处的问题).

In Hadley Wickham's book ("ggplot2 - Elegant Graphics for Data Analysis") there is an example (page 51), where method="lm" is used. In the online manual there is no talk of the method argument. I see other Google results (and questions here) of people using method='loess'.

某处是否有详尽的清单来说明选项?

Is there a an exhaustive list somewhere that explains the options?

据我所见,'lm'画一条直线,'loess'画一条非常平滑的曲线.我认为还有其他人在参考点之间绘制了更多的锯齿线吗?

From what I can see, 'lm' draws a straight line, and 'loess' draws a very smooth curve. I assume there are others that draw more of a jagged line between reference points?

该示例中的se参数也不在帮助或在线文档中.

The se argument from the example also isn't in the help or online documentation.

FWIW这是我的代码.

FWIW here is my code.

p <- ggplot(output8, aes(age, myoutcome, group=id, colour=year_diag_cat2)) +
  geom_line() + scale_y_continuous(limits = c(lwr,upr))
p + geom_smooth(aes(group=year_diag_cat2), method="loess", size=2, se=F)

推荐答案

有时是在问一个使答案跳出来的问题.方法和其他参数在 ggplot2 Wiki stat_smooth页面中列出.

Sometimes it's asking the question that makes the answer jump out. The methods and extra arguments are listed on the ggplot2 wiki stat_smooth page.

geom_smooth()页面上提到了以下内容:

Which is alluded to on the geom_smooth() page with:

这不是我第一次在ggplot图形的示例中看到参数,而该函数不是专门针对该函数的.确实很难确定每个函数的范围,或者也许我还没有偶然发现一个神奇的显式列表,其中列出了在每个函数中将起作用和不起作用的内容.

It's not the first time I've seen arguments in examples for ggplot graphs that aren't specifically in the function. It does make it tough to work out the scope of each function, or maybe I am yet to stumble upon a magic explicit list that says what will and will not work within each function.

这篇关于geom_smooth()有哪些可用的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 21:06
查看更多