Gantt style time line plot (in base R)

后端 未结 3 1505
一向
一向 2020-12-01 06:10

I have a dataframe that looks like this:

       person n start end
1         sam 6     0   6
2        greg 5     6  11
3     teacher 4    11  15
4         sa         


        
3条回答
  •  日久生厌
    2020-12-01 06:40

    You say you want a base R solution, but you don't say why. Since this is one line of code in ggplot, I show this anyway.

    library(ggplot2)
    ggplot(dat, aes(colour=person)) + 
        geom_segment(aes(x=start, xend=end, y=person, yend=person), size=3) +
        xlab("Duration")
    

    enter image description here

提交回复
热议问题