问题
I am trying to plot a shaded area under a curve but however the shaded area is over the curve. Can anyone tell me what's wrong with my code?
x=seq(0,30)
y1=exp(-0.1*x)
plot(x,y1,type="l",lwd=2,col="chocolate1")
polygon(x,y1, density = 5, angle = 45,col="chocolate1")
回答1:
you probably want something like this:
polygon(c(min(x),x),c(min(y1),y1), density = 5, angle = 45,col="chocolate1")
来源:https://stackoverflow.com/questions/35987909/shaded-area-under-curve-r