Plot a line between two points

Hi everyone! I’m trying to plot a line segment between two points, for example (1,2) and (2,3). I did

plot([1.0 2.0],[2.0 3.0], linewidth=2,legend=:false)

However, nothing showed up. I’m using Julia 1.6.7.

1 Like

Never mind. I added a comma and the line showed up.

1 Like

Provide vectors instead of matrix:

julia> [1.0 2.0]
1×2 Matrix{Float64}:
 1.0  2.0

julia> [1.0, 2.0]
2-element Vector{Float64}:
 1.0
 2.0

julia> plot([1.0, 2.0],[2.0, 3.0], linewidth=2,legend=:false)

image

1 Like

I don’t mind :wink:

Thanks!

1 Like