諸惡莫做,眾善奉行,自淨其意!
全部博文(28)
分类: 大数据
2014-12-20 10:32:07
R画函数图像可以用curve和plot等函数。
curve函数:
> curve(sin, -3, 3, col="red")
> curve(dnorm, -3.5, 3.5, main="Std. Normal Density", col="green")
> f <- function(x) exp(-abs(x)) * sin(2 * pi * x)
> curve(f, -5, +5, main="Dampened Sine Wave", col="blue")
plot函数
> p0<-function(x) 1/4+3/4*exp(-4*x/3)
> p1<-function(x) 1/4-1/4*exp(-4*x/3)
> plot(p0,0,3,col='red',xlab='d=3λt',ylab='transition probability')
> plot(p1,0,3,col='blue',xlab='d=3λt',ylab='transition probability',main='probability of T to C',ylim=c(0,1))
要想将两个图片合并时,可以用添加add=TRUE选项,但两个函数的x和y轴的范围必须一致
> plot(p0,0,3,col='red',xlab='d=3λt',ylab='transition probability',main='probability of T to C',ylim=c(0,1))
> plot(p1,0,3,col='blue',xlab='d=3λt',ylab='transition probability',main='probability of T to C',ylim=c(0,1),add=T)