仅绘制拟合的样条线而不绘制数据点

use*_*270 0 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) # add the fitted spline line.
Run Code Online (Sandbox Code Playgroud)

但是,我不想绘制tree_number和jaccard,而是我只想在绘图中绘制拟合的样条线,我该怎么办?

csg*_*pie 5

您可以使用关联的绘图功能:

plot(smoothingSpline, type="l") 
Run Code Online (Sandbox Code Playgroud)

或者您可以显式提取xy值并绘制它们

plot(smoothingSpline$x, smoothingSpline$y, type="l")
Run Code Online (Sandbox Code Playgroud)

  • `abline(H = 0.8)` (2认同)