R 仅打印拟合的样条线,不打印数据点
我检查了我的参考资料,在我看来,要用x和y拟合数据集,许多教程需要首先绘制x和y,然后绘制拟合线。正常程序如下所示:R 仅打印拟合的样条线,不打印数据点,r,spline,R,Spline,我检查了我的参考资料,在我看来,要用x和y拟合数据集,许多教程需要首先绘制x和y,然后绘制拟合线。正常程序如下所示: ## Calculate the fitted line smoothingSpline = smooth.spline(tree_number[2:100], jaccard[1:99], spar=0.35) plot(tree_number[2:100],jaccard[1:99]) #plot the data points lines(smoothingSpline)
## Calculate the fitted line
smoothingSpline = smooth.spline(tree_number[2:100], jaccard[1:99], spar=0.35)
plot(tree_number[2:100],jaccard[1:99]) #plot the data points
lines(smoothingSpline) # add the fitted spline line.
但是,我不想绘制tree_编号和jaccard,而是只想在绘图中绘制拟合的样条线,我该怎么做 为什么不直接绘制SmoothingSpline,type=l?这将允许您添加拟合样条线,而无需首先绘制数据点。您可以使用关联的绘图功能:
plot(smoothingSpline, type="l")
或者,可以显式提取x和y值并绘制它们
plot(smoothingSpline$x, smoothingSpline$y, type="l")
谢谢如何将水平线likey=0.8添加到此绘图