I want to show graphically how the summation of two different sin curves looks like. So, I am trying to make a single graph that shows two different sin function and their sum. So, three curves on one graph.
How can I do it with ggplot layers?
I am defing two sin functions (y and z)
x <- seq(0, 16*pi, 0.01)
y <- 2*sin(3*(x-1))
z <- sin(x)
summing up the two curves:
t <- y + z
I can see the three separately with:
plot(x,y,type="l")
plot(x,z,type="l")
plot(x,t,type="l")
But how can I plot the three functions?
I tried this but it does not work
ggplot(x,
qplot(y,x,geom="path", xlab="time", ylab="Sine wave") +
qplot(z,x,geom="path", xlab="time", ylab="Sine wave"))