r - Multiple splines on the same plot with ggplot2? -


i add other spline plot below, if geom_point() display points on first spline.

n <- 10 d <- data.frame(x = 1:n, y = rnorm(n)) ggplot(d,aes(x,y)) + geom_point() +    geom_line(data=data.frame(spline(d, n=n*10))) 

enter image description here

how can display dots on second line too?

assuming have data want in 2 data.frames, code work. makes spline before using ggplot.

n <- 10 d <- data.frame(x = 1:n, y = rnorm(n)) d2 <- data.frame(x = 1:n, y = rnorm(n)) dd <- rbind(cbind(d, case = "d"), cbind(d2, case = "d2")) ddsmooth <- plyr::ddply(dd, .(case), function(k) as.data.frame(spline(k, n = n * 10))) ggplot(dd,aes(x, y, group = case)) + geom_point() +    geom_line(aes(x, y, group  = case), data = ddsmooth) 

if data in different columns of data.frame, use reshape2::melt process it.


Comments

Popular posts from this blog

Why does Go error when trying to marshal this JSON? -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

apache - Restler setup not working -