ggplot2中的多项式方程可视化

时间:2015-12-02 14:18:16

标签: r ggplot2

我有这段代码:

df_logannuali <- data.frame("x" =log_annuali2[,1],"y"=log_annuali2[,2])
p <-ggplot(df_logannuali, aes(x, y))
p <- p + geom_point(alpha=2/10,shape=21,fill="blue",colour="black",size=3)+stat_smooth(method="lm", se=TRUE,formula=y ~ poly(x, 5, raw=TRUE),colour="red") 
p+labs(x="Tempo (anni)",y="Sbarcato (log.t.)",title="(17) Sbarcato annuale TS")+ theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"))

结果是:

enter image description here

所以现在,我如何获得多项式方程的值,如下例所示:

y = 560x^2+358x^3....-589x^5 

如果可以在图表上绘制它们? 谢谢

0 个答案:

没有答案