logo

How to Insert Vertical and Horizontal Lines in Figures in Julia 📂Julia

How to Insert Vertical and Horizontal Lines in Figures in Julia

Overview

To draw vertical and horizontal lines, use the vline!() and hline!() functions respectively.

Code

@time using Plots

plot(rand(100))
hline!([0.5], linewidth = 2)
vline!([25, 75], linewidth = 2)
png("result")

The positions where lines are drawn should be passed as an array. If the array contains multiple elements, multiple lines will be drawn at once.

result.png

Environment

  • OS: Windows
  • julia: v1.6.3