1

I have two questions about my Gantt-chart I'm plotting via Ggplot2's geom_segment function:

First of all, the time-axis is scaled based on the data points, which means sometimes one step counts for 1:15 hours and the other for like 15 minutes. How do I get a constant 00:00 - 24:00 scaled timeline?

Second, when a task starts at 23:50 and its has a duration of 30 minutes, which makes the ending time 00:20, it is plotted from 00:20 - 23:50 (almost a whole day) instead of 23:50 till the end of the x-axis (which should be 24:00). Because the data then reaches the next day and I'm plotting for only one day, the time after 24:00 is not required to be plotted.

This is the code I'm using now:

ggplot(GanttArrNBStairs1208) + 
    geom_segment(aes(x=Arr_GSE_Start, xend = Arr_GSE_End, 
                     y=`Arrival Trip Number`, yend=`Arrival Trip Number`, 
                     colour=LDA_Pier_Final), 
                 size = 1) + 
    theme(axis.text.x = element_text(angle = 90, hjust = 1))    

Here is a picture of my chart: Gantt Chart via geom_segment

Community
  • 1
  • 1
Sem
  • 11
  • 2
  • 1
    To fix the x-axis, you'll need to format your times as datetimes (see `?as.POSIXct`) or a time class (see `?hms::hms`). To get a fuller answer, edit with some data [to make your example reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – alistaire Jun 17 '18 at 22:13
  • Thanks, this answered both questions, since it now recognises the next day as well. – Sem Jun 18 '18 at 09:05

0 Answers0