I'm a bit confused what you're trying to accomplish - the mix of annotate() and geom_text() is confusing. The following code works for me, and I think might be what you want:
ggplot(ins, aes(td, glucose)) + geom_point(colour = "red") + geom_line(colour = "blue") + annotate("text", x = texdat, y = 500, label = "Glucose", cex = 3) Hadley On Thu, Jul 30, 2015 at 10:23 AM, John Kane <jrkrid...@inbox.com> wrote: > I am trying to annotate a graph using geom_text() and I seem to be > misunderstanding how to use a date in the co-ordinates---or, at least, I > think that is the problem. Code is below. > > Can anyone give me a suggestion of where I am going wrong? > > Thanks, > John > > John Kane > Kingston ON Canada > ###=========================================== > ibrary(ggplot2) > library(lubridate) > ins <- structure(list(td = structure(c(1437804720, 1437824100, 1437836220, > 1437851580, 1437863460, 1437878640, 1437890640, 1437904800, 1437918240, > 1437926100, 1437941340, 1437951240), tzone = "UTC", class = c("POSIXct", > "POSIXt")), glucose = c(328L, 390L, 358L, 387L, 440L, 328L, 365L, > 450L, 467L, 477L, 408L, 457L), dose = c(NA, 0.5, NA, NA, 0.5, > NA, NA, 0.5, NA, NA, NA, 0.5)), .Names = c("td", "glucose", "dose" > ), row.names = c(NA, -12L), class = "data.frame") > > anon <- na.omit(ins) # extract shots > > texdat = ymd_hm("2015-07-26 20:09") > > glucose <- ggplot(ins, aes(td, glucose)) + geom_point(colour = "red") + > geom_line(colour = "blue") > p1 <- glucose + annotate("text", x = texdat, y = 500, label = anon[ ,3 ], > cex = 3) > p1 > > # Now the problem > p2 <- p1 + geom_text(x = texdat, y = 400 , size = 2, label= "Glucose") > p2 > ###============================================= > > ____________________________________________________________ > FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your > desktop! > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.