请参阅附件,我想将覆盖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)
答案 0 :(得分:1)
只需在三角形(0, 0) -- (0, 1) -- (1, 1)
中着色?
polygon(c(0, 0, 1), c(0, 1, 1), col='pink')