# Help required for drawing a chart

**URL:** https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694
**Category:** New to Julia
**Created:** [October 9, 2019, 7:56pm UTC](https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694 "2019-10-09T19:56:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)
#### Post date: [October 9, 2019, 7:56pm UTC](https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694/1 "2019-10-09T19:56:18Z")

</div>

I’ve the below table of data:

```bash
2×7 DataFrame
│ Row │ Customer │ M0 │ M1 │ M2 │ M3 │ ... │ Mn │
│ │ String │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │
├─────┼──────────┼─────────┼──────────┼───────┼───────┼───────┼───────┤
│ 1 │ x │ 8 │ 7 │ 9 │ 2 │ . │ 3 │
│ 2 │ y │ 6 │ 3 │ 4 │ 2 │ . │ 7 │

```

That is generted from the below:

```julia
using CSV, Query, DataFrames
df = CSV.read("deliveries.csv"; header=true, delim=',')

deliveries = by(
    sdf -> mapcols(sum, sdf[:, 3:end]),
    df, 
    :Customer
)
println(deliveries)

```

I’m trying to use `using Gadfly` any other option is ok for me, to draw the chart, so that each row (customer) is a series, so I’ll be having a multiple time serials lines.

---

<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: [October 9, 2019, 8:13pm UTC](https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694/2 "2019-10-09T20:13:57Z")

</div>

There’s this example in the Gadfly docs:  
[http://gadflyjl.org/dev/man/plotting/#Wide-formatted-data-1](http://gadflyjl.org/dev/man/plotting/#Wide-formatted-data-1)

---

<div class="post-metadata">

### Author: ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)
#### Post date: [October 9, 2019, 8:25pm UTC](https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694/3 "2019-10-09T20:25:43Z")

</div>

> [@Mattriks](#):
>
> There’s this example

Thanks,  
It worked with me as:

```julia
using Gadfly

data = stack(deliveries, [:M0, :M1, :M2, :M3, .... :Mn])

plot(data, x=:Customer, y=:value, color=:variable, Geom.line)

```

Is there a way to avoid writting this long line:

```julia
data = stack(deliveries, [:M0, :M1, :M2, :M3, .... :Mn])

```

---

<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: [October 9, 2019, 8:38pm UTC](https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694/4 "2019-10-09T20:38:17Z")

</div>

```julia
using DataFrames
?stack

```

Note the help string contains both `stack` and `melt`. Also see the [DataFrames docs](http://juliadata.github.io/DataFrames.jl/stable/man/reshaping_and_pivoting/#Reshaping-and-Pivoting-Data-1)

---

<div class="post-metadata">

### Author: ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)
#### Post date: [October 9, 2019, 8:49pm UTC](https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694/5 "2019-10-09T20:49:57Z")

</div>

Thanks, I got it as:

```julia
data = stack(deliveries, 2:60)

```

Any idea why I could not get it as:

```julia
data = stack(deliveries, 2:end)

```

---

<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: [October 9, 2019, 8:59pm UTC](https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694/6 "2019-10-09T20:59:21Z")

</div>

```julia
?end

```

I think `end` only works when used inside brackets.  
Did you try:

```julia
melt(deliveries, 1)

```

---

<div class="post-metadata">

### Author: ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)
#### Post date: [October 9, 2019, 9:17pm UTC](https://discourse.julialang.org/t/help-required-for-drawing-a-chart/29694/7 "2019-10-09T21:17:34Z")

</div>

> [@Mattriks](#):
>
> melt(deliveries, 1)

Thanks a lot, got it done by this
