# How to draw Gantt chart using Plots

**URL:** https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729
**Category:** General Usage
**Tags:** question, plotting
**Created:** [September 9, 2018, 12:32pm UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729 "2018-09-09T12:32:09Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![alkorang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alkorang/32/4243_2.png) [@alkorang](https://discourse.julialang.org/u/alkorang)
#### Post date: [September 9, 2018, 12:32pm UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/1 "2018-09-09T12:32:10Z")

</div>

Hello,

I want to draw Gantt chart (someone told it broken bar chart) to represent a task timeline like below.  
But I cannot find any information how to draw this chart using `Plots`.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/f/bfe14bb684aa8052da483b80dc79c887446bb526.png)

Is there any way to draw this kind of chart using `Plots`?

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [September 9, 2018, 12:52pm UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/2 "2018-09-09T12:52:04Z")

</div>

Did you try the search bar: [Search results for 'gantt' - JuliaLang](https://discourse.julialang.org/search?q=gantt)

---

<div class="post-metadata">

### Author: ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)
#### Post date: [September 9, 2018, 3:30pm UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/3 "2018-09-09T15:30:37Z")

</div>

Take a look at VegaLite.jl, and the bar chart examples, it might be possible to do it that way: [http://fredo-dedup.github.io/VegaLite.jl/stable/examples/examples\_barchartshistograms.html](http://fredo-dedup.github.io/VegaLite.jl/stable/examples/examples_barchartshistograms.html).

---

<div class="post-metadata">

### Author: ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)
#### Post date: [September 9, 2018, 3:52pm UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/4 "2018-09-09T15:52:31Z")

</div>

> [@davidanthoff](#):
>
> it might be possible to do it that way:

There seem to be even an example:  
[http://fredo-dedup.github.io/VegaLite.jl/stable/examples/examples\_barchartshistograms.html#Gantt-Chart-(Ranged-Bar-Marks)-1](http://fredo-dedup.github.io/VegaLite.jl/stable/examples/examples_barchartshistograms.html#Gantt-Chart-(Ranged-Bar-Marks)-1)

---

<div class="post-metadata">

### Author: ![alkorang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alkorang/32/4243_2.png) [@alkorang](https://discourse.julialang.org/u/alkorang)
#### Post date: [September 10, 2018, 2:25am UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/5 "2018-09-10T02:25:02Z")

</div>

Thank you for your replies!

> [@Mattriks](#):
>
> Did you try the search bar: [https://discourse.julialang.org/search?q=gantt](https://discourse.julialang.org/search?q=gantt)

Of course, I tried and see your solution using `Gadfly`. 🙂  
I just wondered there is another way to draw this using `Plots`.

> [@davidanthoff](#):
>
> Take a look at VegaLite.jl,

> [@Tero\_Frondelius](#):
>
> There seem to be even an example:

This `VegaLite` looks good!

I first wanted to use `Plots` because it has many backend supports, but maybe I should switch to other packages.

Unfortunately `Gadfly` is not working with Julia 1.0 right now.  
`VegaLite` works nicely with Julia 1.0, though.

```julia
using VegaLite

@vlplot(
    :bar,
    data={
        values=[
            {worker="1",start=1,stop=3,type="A"},
            {worker="2",start=2,stop=6,type="B"},
            {worker="3",start=3,stop=7,type="B"},
            {worker="2",start=7,stop=9,type="C"}
        ]
    },
    enc={
        y="worker:o",
        x="start:q",
        x2="stop:q",
        color={
            "type:n",
            scale={range=["#EA98D2", "#659CCA", "#000000"]}
        }
    }
)

```

result:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/a/1a62f27bd3e6a37594915e6ee7ded72d38be2ed9.png)

By the way, could you tell me why `Plots` dropped `Gadfly` backend support?

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [September 10, 2018, 2:48am UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/6 "2018-09-10T02:48:15Z")

</div>

For Gadfly vs Plots see [here](https://github.com/GiovineItalia/Gadfly.jl/issues/1144#issuecomment-388225727) 🙂

There’s a PR [here](https://github.com/GiovineItalia/Gadfly.jl/pull/1189) for Julia 1.0 support, should be merged soon.

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [September 10, 2018, 10:14am UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/7 "2018-09-10T10:14:04Z")

</div>

Actually on that link I can read “I will leave the history of Gadfly vs Plots for others to explain!”… so really it’s a bit frustrating to see so many plotting packages instead of a well-established “reference” one, like ggplot2 in R or matplotlib in python…

---

<div class="post-metadata">

### Author: ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)
#### Post date: [September 10, 2018, 3:00pm UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/8 "2018-09-10T15:00:32Z")

</div>

> [@sylvaticus](#):
>
> so really it’s a bit frustrating to see so many plotting packages instead of a well-established “reference” one, like ggplot2

I disagree - the approaches taken by Plots, VegaLite and gadfly are all quite different. I prefer Plots, but others prefer the others. Im often annoyed going back to R because I find ggplot unintuitive and have to Google anytime I want to do anything. But other people really like it.

Why would it be better to force everyone into the same way of doing things?

---

<div class="post-metadata">

### Author: ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)
#### Post date: [September 10, 2018, 8:08pm UTC](https://discourse.julialang.org/t/how-to-draw-gantt-chart-using-plots/14729/9 "2018-09-10T20:08:18Z")

</div>

Here is a slightly more concise version for [VegaLite.jl](https://github.com/fredo-dedup/VegaLite.jl):

```julia
using VegaLite, DataFrames

df = DataFrame(worker=[1,2,3,2], start=[1,2,3,7], stop=[3,6,7,9], type=["A","B","B","C"])

df |> @vlplot(
    :bar,
    y="worker:n",
    x=:start,
    x2=:stop,
    color={:type, scale={range=["#EA98D2", "#659CCA", "#000000"]}}
)

```
