# NOT RUN {
library(ggplot2)
# First, you need a function to generate
# x and y coordinates for a single group
# of points.
x_square=function(start, end, A, B){
x=seq(start, end, 0.1)
data.frame(x=x, y=A*(x^2)+B)
}
# All the arguments of your function
# (here, start, end, A, B) should only accept
# vectors of length 1. And, the result of
# your function should be a data frame
# of x and y coordinates
# (here, coordinates of curves).
dat=ANYxy(myfun=x_square,
start=-1, end=1, A=c(1, 2), MoreArgs=list(B=1),
group=TRUE, todf=TRUE)
ggplot(dat)+geom_line(aes(x, y, group=g, color=factor(g)))
# }
Run the code above in your browser using DataLab