Skip to content
Prev 154928 / 398506 Next

ggplot2: line plot with gaps in time axis

Hello, I'm trying to plot data that has gaps in the timeline because my data
only has the business day in it. When I do a line plot I get the data and
then a blank area where a line goes the tail of the last data point  to the
head of the next data point. Is there a way I can do a line plot where the
gaps are not plotted?

Thanks in advance, 

Brian
[1] "Date_and_Time" "Utilization"   "Direction"
Date_and_Time Utilization Direction
1    2008-08-25 05:00:00    5.862601   Inbound
2    2008-08-25 05:05:00   10.025328   Inbound
3    2008-08-25 05:10:00    5.794900   Inbound
4    2008-08-25 05:15:00    9.862726   Inbound
5    2008-08-25 05:20:00    4.150328   Inbound
6    2008-08-25 05:25:00    5.559362   Inbound
[...]

# startDateTime and stopDateTime is user entered
Start <- as.numeric(as.POSIXct(startDateTime))
End <- as.numeric(as.POSIXct(stopDateTime))
Period<-as.numeric(seq.POSIXt(as.POSIXct(Start,origin="1970-1-1"),
as.POSIXct(End,origin="1970-1-1"), by="DSTday"))
Labels<-as.Date(seq.POSIXt(as.POSIXct(Start,origin="1970-1-1"),
as.POSIXct(End,origin="1970-1-1"), by="DSTday"))
dt <-
qplot(as.numeric(utildf$Date_and_Time),Utilization,data=utildf,colour=Direction,geom="segment")
dt + scale_x_continuous(breaks=Period,label=Labels)