1
藉此例如:如何獲取ggplot2 :: geom_smooth曲線後面的數據?
ggplot(iris,aes(Sepal.Width,Sepal.Length)) + geom_smooth()
如何獲取用於繪製這個藍色曲線x
和y
?
這個案例將自動計算出loess
,我的實際案例自動計算爲gam
。
我想:
- 與
gam
功能 - 重現它探索劇情對象
,並沒有與任何
藉此例如:如何獲取ggplot2 :: geom_smooth曲線後面的數據?
ggplot(iris,aes(Sepal.Width,Sepal.Length)) + geom_smooth()
如何獲取用於繪製這個藍色曲線x
和y
?
這個案例將自動計算出loess
,我的實際案例自動計算爲gam
。
我想:
gam
功能,並沒有與任何
成功,據我瞭解的問題,試試這種方法:
library(gam)
library(broom)
mod <- gam(Sepal.Length ~ Sepal.Width, data = iris)
ggplot(iris, aes(Sepal.Width,Sepal.Length)) + geom_point() +
geom_line(data = augment(mod, type.predict = "response"),
aes(y = .fitted), color = "blue")
舉例說明你所使用的數據的gam模型,其中包含gam函數? – Mateusz1981
你看過這裏 - https://stackoverflow.com/questions/9789871/method-to-extract-stat-smooth-line-fit –
是的,它確實是一個重複,非常感謝! –