请看附件,我想把覆盖的区域涂R1
成粉红色,怎么涂polygon
?
x = seq(-0.25, 2, by=0.01)
y1=x
y2=x^2
plot(x, y1,type="l",frame.plot=FALSE,axes=FALSE,xlab="",ylab="")
lines(x,y2,type="l",col="red")
xx1<-c(0,x[x<1 & x>0 ],1)
yy1<-c(0,x[x<1 & x>0 ],0)
polygon(xx1,yy1,col="yellow")
xx1<-c(0,x[x<1 & x>0 ],1)
yy2<-c(0,(x[x<1 & x>0 ])^2,0)
polygon(xx1,yy2,col="blue")
## write some text
text(1.1,1,labels="y=x",col="black")
text(0.8,1,labels="y=x^2",col="red")
text(0.7,0.2,labels="R3",col="black")
text(0.4,0.35,labels="R2",col="black")
text(0.2,0.5,labels="R1",col="black")
## draw axes lines with arrows
arrows(min(x), 0, max(x), 0)
arrows(0, min(x), 0, max(x))
## add axes ticks
axis(1,at=c(0,0.5,1,1.5),pos=0)
axis(2,at=c(0,0.5,1,1.5),pos=0)