Reputation: 69
I don't know how to put four plots(y=3^x, y=(1/3)^x, y=(3/2)^x, y=e^x) into a same coordinates. I typed:
a = function(x){y=3^x}
b = function{y=(1/3)^x}
c = function{y=(3/2)^x}
d = function(x){exp(x)}
plot(-4:4, a, b, c, d)
but it did not work. How can I fix this?
Upvotes: 0
Views: 105
Reputation: 1422
Use the add=TRUE
option, Also you have your second and third functions written wrong (they take no parameters). So you have:
a = function(x){y=3^x}
b = function(x){y=(1/3)^x}
c = function(x){y=(3/2)^x}
d = function(x){exp(x)}
and you plot using:
plot(a , -4 , 4)
plot(b , -4 , 4, add=TRUE)
plot(c , -4 , 4, add=TRUE)
plot(d , -4 , 4, add=TRUE)
Upvotes: 1