|
发表于 2012-9-29 10:47:52
|
显示全部楼层
ggplot2可以完成这个任务,做过类似的图。 library(ggplot2)
下边是别人教程里的代码,你看看吧!
intercept <- sin(4)-slope*4
x <- seq(from=0,to=2*pi,by=0.01)
y <- sin(x)
p <- ggplot(data.frame(x,y),aes(x,y))
p + geom_area(fill=alpha('blue',0.3))+
geom_abline(intercept=intercept,slope=slope,linetype=2)+
scale_x_continuous(breaks=c(0,pi,2*pi),
labels=c('0',expression(pi),expression(2*pi)))+
geom_text(parse=T,aes(x=pi/2,y=0.3,label='integral(sin(x)*
dx, 0, pi)'))+
geom_line()+
geom_point(aes(x=4,y=sin(4)),size=5,colour=alpha('red',0.5
))
|
|