# Add reference lines to plot in VegaLite.jl

**URL:** <https://discourse.julialang.org/t/add-reference-lines-to-plot-in-vegalite-jl/80515>\
**Category:** Visualization\
**Tags:** vegalite\
**Created:** [May 5, 2022, 12:46am UTC](https://discourse.julialang.org/t/add-reference-lines-to-plot-in-vegalite-jl/80515 "2022-05-05T00:46:21Z")\
**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 5, 2022, 12:46am UTC](https://discourse.julialang.org/t/add-reference-lines-to-plot-in-vegalite-jl/80515/1 "2022-05-05T00:46:21Z")

</div>

I’m trying to add 2 reference horizontal lines to this plot, but my attempt doesn’t extend the lines to the y-axis, which is what I want. Any suggestions?

```julia
using DataFrames
using VegaLite

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

df |> @vlplot(x=:m, height=400, width=400) +
  @vlplot(:point, y=:ul) +
  @vlplot(:point, y=:ll) +
  @vlplot(mark={:line, color=:red}, y={datum=26}) +
  @vlplot(mark={:line, color=:black}, y={datum=0}) +
  @vlplot(:rule, y=:ul, y2=:ll)

```

---

<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 5, 2022, 6:26am UTC](https://discourse.julialang.org/t/add-reference-lines-to-plot-in-vegalite-jl/80515/2 "2022-05-05T06:26:45Z")

</div>

I managed to force the reference lines with

```julia
df |> @vlplot(x=:m, height=400, width=400) +
  @vlplot(:point, y=:ul) +
  @vlplot(:point, y=:ll) +
  @vlplot(mark={:line, color=:red}, y={datum=26}, x=[i for i in 0:0.1:5]) +
  @vlplot(mark={:line, color=:black}, y={datum=0}, x=[i for i in 0:0.1:5]) +
  @vlplot(:rule, y=:ul, y2=:ll)

```

But now the title of the x-axis disappears.

---

<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 9, 2022, 12:02am UTC](https://discourse.julialang.org/t/add-reference-lines-to-plot-in-vegalite-jl/80515/3 "2022-05-09T00:02:49Z")

</div>

Just did this:

```julia
df |> @vlplot(x=:m, height=400, width=400) +
    @vlplot(mark={:point, filled=true, color=:blue}, y=:ul) +
    @vlplot(mark={:point, filled=true, color=:blue}, y=:ll) +
    @vlplot(mark={:line, color=:red}, y={datum=26}, x={[i for i in 0.0:0.1:5], title="M"}) +
    @vlplot(mark={:line, color=:black}, y={datum=0}, x={[i for i in 0.0:0.1:5], title="M"}) +
    @vlplot(mark={:rule, color=:blue}, y=:ul, y2=:ll)

```
