0
time_centroid
[1] "2004-04-02 06:22:15 UTC"
> time_end
[1] "2004-04-03 18:15:00 UTC"
> time_max
[1] "2004-04-02 04:05:00 UTC"

ggplot(df,aes(y=precip,x=time))+
  geom_line()+
  geom_vline(xintercept = as.numeric(time_max))+
  geom_vline(xintercept = as.numeric(time_end))+
  geom_vline(xintercept = as.numeric(time_centroid))

enter image description here

  1. How can I add inidividual labels (Max, End, Centroid) to the lines (Maybe at the top to stop overlapping with the graph).
  2. OR. Make the lines in different colors with external legend.

This is the dataframe:

structure(list(time = structure(c(1080868500, 1080868800, 1080869100, 
1080869400, 1080869700, 1080870000, 1080870300, 1080870600, 1080870900, 
1080871200, 1080871500, 1080871800, 1080872100, 1080872400, 1080872700, 
1080873000, 1080873300, 1080873600, 1080873900, 1080874200), class = c("POSIXct", 
"POSIXt"), tzone = "UTC"), precip = c(1.76, 1.76, 1.21, 0.78, 
0.59, 0.59, 0.62, 0.62, 0.81, 0.81, 1.14, 0.82, 0.87, 1.03, 0.98, 
0.77, 0.77, 0.45, 0.55, 0.82)), .Names = c("time", "precip"), row.names = 236752:236771, class = "data.frame")
maximusdooku
  • 5,242
  • 10
  • 54
  • 94
  • 1
    A nice example of labeling lines (albeit horizontal ones) is [here](http://stackoverflow.com/a/12876602/2461552). And [this question and answer](http://stackoverflow.com/questions/28885769/how-to-add-legend-for-vertical-lines-in-ggplot) show how to add multiple lines with a legend. – aosmith Oct 06 '16 at 21:57
  • Thanks! That works. – maximusdooku Oct 06 '16 at 22:11

0 Answers0