Skip to content

how to smooth a line in a graph

3 messages · Rado Bonk, Martina Pavlicova, Roger D. Peng

#
Hi R-users,

I have a line graph made by plot(). The line is very similar to
hyperbola, and consists of 5 points. How can I make it look smooth?

Thanks,

Rado
#
See ?spline

Hope that helps.

Martina Pavlicova
--------------------------------------------------------------------------
Department of Statistics             Office Phone: (614) 292-1567
1958 Neil Avenue, 304E Cockins Hall  FAX: (614) 292-2096
The Ohio State University            E-mail: pavlicov at stat.ohio-state.edu
Columbus, OH 43210-1247              www.stat.ohio-state.edu/~pavlicov
On 29 May 2003, Rado Bonk wrote:

            
#
You may be interested in spline().  For example:

x <- 1:5
y <- c(1,3,4, 2.5,2)
plot(x, y)
sp <- spline(x, y, n = 50)
lines(sp)

-roger
Rado Bonk wrote: