# How to make a gantt plot with Plots.jl

**URL:** <https://discourse.julialang.org/t/how-to-make-a-gantt-plot-with-plots-jl/95165>\
**Category:** General Usage\
**Tags:** question, plotting, plots\
**Created:** [February 24, 2023, 9:02pm UTC](https://discourse.julialang.org/t/how-to-make-a-gantt-plot-with-plots-jl/95165 "2023-02-24T21:02:28Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 25, 2023, 12:44am UTC](https://discourse.julialang.org/t/how-to-make-a-gantt-plot-with-plots-jl/95165/2 "2023-02-25T00:44:19Z")

</div>

Using Plots.jl:

```julia
using Plots, DataFrames

rect(w, h, x, y) = Shape(x .+ [0,w,w,0], y .+ [0,0,h,h])

df = DataFrame(label=["A","B"], start_time=[1.0,3.0], end_time=[4.0,5.0], color=[:blue,:green])
df.duration = df.end_time - df.start_time
r = [rect(t[1],1,t[2],t[3]) for t in zip(df.duration, df.start_time, 1:nrow(df))]

plot(r, c=permutedims(df.color), yticks=(1.5:(nrow(df) + 0.5), df.label), xlabel="Time")

```

 ![Plots_Gantt_chart](https://global.discourse-cdn.com/julialang/original/3X/5/5/554ec7d95245ff53bb7ba23044b10e9a1b530f28.png)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-make-a-gantt-plot-with-plots-jl/95165)._
