# What is the syntax for vline() in Plots.jl?

**URL:** <https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718>\
**Category:** Visualization\
**Tags:** question, plotting, plots\
**Created:** [January 27, 2017, 4:16pm UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718 "2017-01-27T16:16:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 27, 2017, 4:16pm UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718/1 "2017-01-27T16:16:54Z")

</div>

There is no documentation and reading the source code didn’t help much.

---

<div class="post-metadata">

**Author:** ![tbreloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbreloff/32/68_2.png) [@tbreloff](https://discourse.julialang.org/u/tbreloff)\
**Post date:** [January 27, 2017, 6:56pm UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718/2 "2017-01-27T18:56:50Z")

</div>

`vline`, `scatter`, `heatmap`, etc all just pass through to the `plot` function. You can imagine it looks like:

```julia
vline(args...; kw...) = plot(args...; kw..., seriestype = :vline)

```

There’s nothing special about them… they’re just a convenience.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 27, 2017, 7:06pm UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718/3 "2017-01-27T19:06:52Z")

</div>

@tbreloff and so if I want to have a bunch of vertical lines at x1, x2 and x3, what is the syntax?

It may be trivial to you, the person who has written the code, but as a user, I still have no clue of what to pass as `args`. Should it be a list [x1,x2,x3]? How to control the height of the lines? Etc.

---

<div class="post-metadata">

**Author:** ![tbreloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbreloff/32/68_2.png) [@tbreloff](https://discourse.julialang.org/u/tbreloff)\
**Post date:** [January 27, 2017, 8:49pm UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718/4 "2017-01-27T20:49:21Z")

</div>

A list `[x1,x2,x3]` should be fine. If you want to be more precise with how you draw vertical lines, just do it yourself with the normal `:path` seriestype and separate each line segment with a NaN.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 1, 2017, 7:26am UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718/5 "2017-05-01T07:26:14Z")

</div>

For future reference, the command is:

```julia
vline([1,2,3]) # vertical lines at x = 1, 2 and 3.

```

Notice that you have to pass a 1x1 array if you are interested in a single vertical line (e.g. `vline([2])`).

---

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [May 1, 2017, 10:43am UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718/6 "2017-05-01T10:43:50Z")

</div>

Remember, you can also add more lines using the ! variants of the functions, you don’t have to create them all at once.

---

<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:** [August 1, 2018, 3:58pm UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718/7 "2018-08-01T15:58:17Z")

</div>

Hello, and what about wanting to have a specific symbol on the x axis at the point of the vertical line?  
I did try something like this but it doesn’t work:

`plot!([17], seriestype = :vline, xtick="θ")`

(and bdw, would it be possible to get it latex-formatted, e.g. for “\bar θ” ?)

---

<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:** [August 2, 2018, 9:29am UTC](https://discourse.julialang.org/t/what-is-the-syntax-for-vline-in-plots-jl/1718/8 "2018-08-02T09:29:27Z")

</div>

I solved for Latex, but not for the tick on the x axis.  
The best I could fins is using `annotate!(x,0,text())`, but that’s a bit ugly, as I can’t go e.g. to -1 in the y axis:

```julia
using Plots, StatPlots, DataFrames
pyplot()
df = DataFrame(a = 1:10, b = 10*rand(10), c = 10 * rand(10))
f = Plots.font("DejaVu Sans", 10)
@df df plot(:a, [:b :c], label=["fitted prices" "obs prices"], xtickfont=f, ytickfont=f, legendfont=f, guidefont=f, titlefont=f) # x = :a, y = [:b :c]. Notice this is two columns!
plot!([5], seriestype="vline")
annotate!(5, 0, text("\$\\bar \\delta \$",f, :left))
plot!([7], seriestype="vline")
annotate!(7, 0, text("\$\\bar \\gamma \$",f, :left))

```

Produces:

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