# Why I can't connect 2 complex dots using plot(\[z1\],\[z2\]...)?

**URL:** <https://discourse.julialang.org/t/why-i-cant-connect-2-complex-dots-using-plot-z1-z2/86986>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [September 9, 2022, 12:48pm UTC](https://discourse.julialang.org/t/why-i-cant-connect-2-complex-dots-using-plot-z1-z2/86986 "2022-09-09T12:48:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [September 9, 2022, 12:48pm UTC](https://discourse.julialang.org/t/why-i-cant-connect-2-complex-dots-using-plot-z1-z2/86986/1 "2022-09-09T12:48:28Z")

</div>

Hi all,

I try this code:

```julia
using Plots, LaTeXStrings

z1 = 4+2im
z2 = 4-2im
z3 = z1+z2
z4 = z1-z2

plot([z1], framestyle = :zerolines, label=L"z = 4 + 2i"; st=:scatter, legend=:outerright)
plot!([z2], label=L"z = 4 - 2i"; st=:scatter)
plot!([z3], label=L"z + \bar{z} = \ 2a"; st=:scatter)
plot!([z4], label=L"z - \bar{z} = \ 2ib"; st=:scatter)
    
# vertical green line connecting the dots

plot!([0,4],[4,2], label="", linecolor=:green, linestyle=:dash)
plot!([8,4],[0,2], label="", linecolor=:green, linestyle=:dash)
plot!([8,4],[0,-2], label="", linecolor=:green, linestyle=:dash)
plot!([0,4],[0,2], label="", linecolor=:green, linestyle=:dash)
plot!([0,4],[0,-2], label="", linecolor=:green, linestyle=:dash)

```

it plots nicely, but I wonder why I can’t use:

```julia
plot!([z1],[z2], label="", linecolor=:green, linestyle=:dash)

```

error:  
**MethodError: no method matching isless(::Float64, ::ComplexF64)**

instead of the old plot a line code…

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [September 9, 2022, 1:39pm UTC](https://discourse.julialang.org/t/why-i-cant-connect-2-complex-dots-using-plot-z1-z2/86986/2 "2022-09-09T13:39:03Z")

</div>

Maybe you want this notation instead:

```julia
scatter([z1, z2])
plot!([z1, z2], label="", linecolor=:green, linestyle=:dash)

```

(edited: is this what you want?)

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [September 9, 2022, 1:49pm UTC](https://discourse.julialang.org/t/why-i-cant-connect-2-complex-dots-using-plot-z1-z2/86986/3 "2022-09-09T13:49:23Z")

</div>

Yes, basically they plot the same but to write this code:

```julia
plot!([z1, z2], label="", linecolor=:green, linestyle=:dash)

```

is more convenient and efficient. Thanks

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [September 9, 2022, 1:54pm UTC](https://discourse.julialang.org/t/why-i-cant-connect-2-complex-dots-using-plot-z1-z2/86986/4 "2022-09-09T13:54:32Z")

</div>

You can concatenate the lines using `plot!([z4, z3, z1, z2, 0im, z4])` (in the correct order, to have a single plot command build the complete line (or scatter).
