# Help with range plot with VegaLite.jl

**URL:** https://discourse.julialang.org/t/help-with-range-plot-with-vegalite-jl/80462
**Category:** Visualization
**Tags:** vegalite
**Created:** [May 4, 2022, 5:46am UTC](https://discourse.julialang.org/t/help-with-range-plot-with-vegalite-jl/80462 "2022-05-04T05:46:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)
#### Post date: [May 4, 2022, 5:46am UTC](https://discourse.julialang.org/t/help-with-range-plot-with-vegalite-jl/80462/1 "2022-05-04T05:46:08Z")

</div>

I’m having trouble creating a range plot with `VegaLite.jl` (similar to this [How to create a range plot - Datawrapper Academy](https://academy.datawrapper.de/article/111-how-to-create-a-range-plot), but with the ranges orientated vertically). I just need a simple line connecting `ul` to `ll` for each value of `m`, but I can’t even plot both `ul` and `ll` in the same “canvas”.

```julia
using DataFrames
using VegaLite

df = DataFrame(m = 1:5, ll=21:25, ul=:31:35)

df |> @vlplot(
    height=400,
    width=400,
    :point,
    x=:m,
    y=:ul
) +
@vlplot(
    height=400,
    width=400,
    :point,
    x=:m,
    y=:ll
)

```

The online documentation shows some examples where they calculate `ul` and `ll` from raw data, as opposed to the “summarized” example I present here.

---

<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: [May 4, 2022, 7:46am UTC](https://discourse.julialang.org/t/help-with-range-plot-with-vegalite-jl/80462/2 "2022-05-04T07:46:44Z")

</div>

I think this should do the trick:

```julia
df |> @vlplot(x=:m, height=400, width=400) +
  @vlplot(:point, y=:ul) +
  @vlplot(:point, y=:ll) +
  @vlplot(:rule, y=:ul, y2=:ll)

```

I pulled the common properties for all layers into a first call to `@vlplot` that doesn’t have any mark. So this first call does _not_ turn into a layer, this becomes the “parent” spec.

---

<div class="post-metadata">

### Author: ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)
#### Post date: [May 4, 2022, 8:20am UTC](https://discourse.julialang.org/t/help-with-range-plot-with-vegalite-jl/80462/3 "2022-05-04T08:20:24Z")

</div>

I am now trying to add a horizontal line at `y=25`, but this doesn’t render it

```julia
df |> @vlplot(x=:m, height=400, width=400) +
  @vlplot(:point, y=:ul) +
  @vlplot(:point, y=:ll) +
  @vlplot(:rule, y=:ul, y2=:ll) +
  @vlplot(:rule, data={values=[{}]}, y={datum=13.22, type="quantitative"})

```
