How to draw a smooth curve passing through some points

爱⌒轻易说出口 提交于 2019-12-09 09:25:43

问题


I have

plot(rnorm(120), rnorm(120), col="darkblue", pch=16, xlim=c(-3,3), ylim=c(-4,4))
points(rnorm(120,-1,1), rnorm(120,2,1), col="darkred", pch=16)
points(c(-1,-1.5,-3), c(4,2,0), pch=3, cex=3)

I want to delineate a part of a graph, by drawing a smooth curve passing through a set of points.I can define 3-4 set of points but i cannot define a function. I would like to do this in R (as opposed to GIMP) as I would like to submit as SVG. What I would like to achieve is the following

Is this possible? I know this is not a sophisticated graphing question but any base R solution will do.


回答1:


if I understood the question right, drawing a spline through control points should do the job:

xspline(c(-1,-1.5,-3), c(4,2,0), shape = -1)



来源:https://stackoverflow.com/questions/14303251/how-to-draw-a-smooth-curve-passing-through-some-points

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!