[R] ggplot2: line plot with gaps in time axis

btcruiser brian_teravskis at cargill.com
Wed Sep 3 20:33:07 CEST 2008


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

> names(utildf)
[1] "Date_and_Time" "Utilization"   "Direction"    
> utildf
           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)

-- 
View this message in context: http://www.nabble.com/ggplot2%3A-line-plot-with-gaps-in-time-axis-tp19295209p19295209.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list