I'm plotting the hour of the day that some event happened. However, I'm using Shiny, and I'd like to set the ylim of the graphics beforehand. Here's what I tryed so far
#my data
structure(list(Data = structure(c(15971, 15972, 15973, 15974,
15975, 15978, 15971, 15972, 15973, 15974, 15975, 15978), class = "Date"),
Nome = c("dummyName", "dummyName", "dummyName", "dummyName",
"dummyName", "dummyName", "dummyName", "dummyName", "dummyName",
"dummyName", "dummyName", "dummyName"), hora = structure(c(1382013987,
1382014626, 1382015134, 1382014112, 1382013981, 1382013761,
1382044587, 1382044676, 1382044398, 1382044961, 1382047646,
1382044149), class = c("POSIXct", "POSIXt"), tzone = ""),
tipo = c("entrada", "entrada", "entrada", "entrada", "entrada",
"entrada", "saida", "saida", "saida", "saida", "saida", "saida"
), minHora = structure(c(1378090800, 1378090800, 1378090800,
1378090800, 1378090800, 1378090800, 1378090800, 1378090800,
1378090800, 1378090800, 1378090800, 1378090800), class = c("POSIXct",
"POSIXt")), maxhora = structure(c(1378177140, 1378177140,
1378177140, 1378177140, 1378177140, 1378177140, 1378177140,
1378177140, 1378177140, 1378177140, 1378177140, 1378177140
), class = c("POSIXct", "POSIXt"))), .Names = c("Data", "Nome",
"hora", "tipo", "minHora", "maxhora"), class = c("data.table",
"data.frame"), row.names = c(NA, -12L), .internal.selfref = <pointer: 0x003524a0>)
# code to render my plot
p5 <- ggplot(myDf, aes(Data, hora)) +
geom_line(aes(group=tipo))
p5
However, I'd like that the graphic started the ylim on somevalue (say 00:00:00 or 06:00:00) and ended at another (maybe fixed) value. I tryed to use scale_y_datetime, like this:
myDf$minHora <- as.POSIXct(paste(min(myDf$Data), "06:00:00"), format="%Y-%m-%d %H:%M:%S")
myDf$maxhora <- as.POSIXct(paste(min(myDf$Data), "23:59:00"), format="%Y-%m-%d %H:%M:%S")
p5 + scale_y_datetime(limits=c(min(minHora) , max(maxhora) ))
It's almost what I want. The only problem is the name of the month (october) next to the hour. I really don't like the month next to the hour.
ps.: I'm using ggplot within shiny. It probably doesn't make any difference.