i'm trying to make a gantt chart in ggplot2. i'm having troubles changing the colors and spacing of each segment in a geom_segment()
> head(g672)
mobility start endtime
1 active 0.00000 1.60157
3 active 1.60157 59.65837
5 active 59.65840 68.93415
7 immobile 68.93420 69.03430
9 active 69.03430 77.87629
11 immobile 77.87620 80.27855
I'm using geom_segment() to generate the chart:
ggplot(g672, aes(colour=mobility)) +
geom_segment(aes(x=start, xend=endtime, y=mobility, yend=mobility), size=15) +
xlab("Duration") +
theme_classic()
Which generates this chart:
I'd like to be able to do 2 things: 1) change the colors and 2) make the 2 bars appear closer to each other or even get both of them overlapping (these are mutually exclusive categories so if you're not doing one, you're doing the other).
cheers and thanks for any advice