1

I would like to plot the shaded region between y=sin(x) and y=0 over x in [0, pi] in R. Can you give some examples?

By shaded, I mean the region can be colored and better be half-transparent.

Thanks and regards!

Tim
  • 1
  • 141
  • 372
  • 590
  • What's the shaded region? We can't see whatever you're looking at. – Gabe Dec 06 '10 at 17:58
  • By shaded, I mean the region can be colored and better be half-transparent. – Tim Dec 06 '10 at 17:59
  • 3
    That's a repeat -- I once explained the same to JD -- see eg here http://stackoverflow.com/questions/3494593/r-shading-a-kernel-density-plot-between-two-points – Dirk Eddelbuettel Dec 06 '10 at 18:13

1 Answers1

6

see ?polygon :

x <- seq(0,pi,length.out=100)
y <- sin(x)

plot(x,y,type="l")
polygon(x,y,col="grey")
Joris Meys
  • 106,551
  • 31
  • 221
  • 263
  • 3
    Correct. See also here http://stackoverflow.com/questions/3494593/r-shading-a-kernel-density-plot-between-two-points and I think I even had an answer where it was between tow curves. – Dirk Eddelbuettel Dec 06 '10 at 18:15
  • @Dirk : thx for the pointer, I wasn't aware. voted to close the question. – Joris Meys Dec 06 '10 at 18:17