0

I have made the folowing graph with my data using the overlapPlot() function in R.

I would like to add to shaded areas within the graph showing sunrise and sunset. Sunrise is between 6-7 and sunset between 18-19.

To do this I thought I could use the polygon() function. However I am not sure how to code the polygon function to do this. Any help would be appreciated.

enter image description here

jbaums
  • 27,115
  • 5
  • 79
  • 119
Guest
  • 17
  • 7
  • 1
    Did you look at `?polygon`? – jbaums Jun 27 '15 at 08:45
  • 1
    Please provide a reproducible example (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and show us what you have tried so far. – RHA Jun 27 '15 at 14:41

1 Answers1

1

I used the following code:

#SUNRISE
    cord.x <- c(5.52)
    cord.y <- c(0)

    cord.x <- c(cord.x,5.52) 
    cord.y <- c(cord.y,4)

    cord.x <- c(cord.x,8.37,8.37)
    cord.y <- c(cord.y,4,0)
    polygon(cord.x,cord.y,col=adjustcolor("blue",alpha.f=0.4),border=NA)

#SUNSET
    cord.x <- c(-5.56)
    cord.y <- c(0)

    cord.x <- c(cord.x,-5.56) 
    cord.y <- c(cord.y,4)

    cord.x <- c(cord.x,-8.48,-8.48)
    cord.y <- c(cord.y,4,0)
    polygon(cord.x,cord.y,col=adjustcolor("blue",alpha.f=0.3),border=NA)
Guest
  • 17
  • 7