Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a smooth curve passing through some points

Tags:

plot

r

curve

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

enter image description here

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

like image 642
ECII Avatar asked Jan 13 '13 12:01

ECII


People also ask

Is used to draw a smooth curve passing through a number of points?

French curve is free form template make of acrylic and is used to draw a smooth curve passing through a number of points. The outer profile of the French curve is adjusted such the smooth curve passes through more than three points and a curve passing through these lines are drawn.


1 Answers

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)

Should look like that:

like image 81
Andrey Dyachenko Avatar answered Sep 25 '22 01:09

Andrey Dyachenko