# Plot smile face

**URL:** <https://discourse.julialang.org/t/plot-smile-face/118089>\
**Category:** General Usage\
**Tags:** question, plotting, plots\
**Created:** [August 12, 2024, 11:21am UTC](https://discourse.julialang.org/t/plot-smile-face/118089 "2024-08-12T11:21:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![khaledharizb](https://avatars.discourse-cdn.com/v4/letter/k/57b2e6/32.png) [@khaledharizb](https://discourse.julialang.org/u/khaledharizb)\
**Post date:** [August 12, 2024, 11:21am UTC](https://discourse.julialang.org/t/plot-smile-face/118089/1 "2024-08-12T11:21:34Z")

</div>

I tried to plot a smile face with julia, the code I’ve used as follows

```julia
function face()
t = range(0, 2pi, 200)
r1=0.2;
r2=0.5;
R=1;
y=[0, 0]' .+ hcat(R*cos.(t),R*sin.(t)) # big circle
y1=[-0.3, 0.3]' .+ hcat(r1*cos.(t),r1*sin.(t)) # left small circle
y2=[0.3, 0.3]' .+ hcat(r1*cos.(t),r1*sin.(t)) # right small circle

t = range(-π+π/5, -π/5, 200)
y3= hcat(r2*cos.(t),r2*sin.(t)) # parabola
Y=[y;y1;y2;y3]
return plot(Y[:,1],Y[:,2],aspect_ratio=1,lc=:black, linestyle=:dot,lw = 2)
end

```

However, the result with `face()` gives

 ![Capture](https://global.discourse-cdn.com/julialang/original/3X/2/2/223b43f64016ef1dac16cecbea9d62d845be69f5.png)

Could anyone show me the issue?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 12, 2024, 11:32am UTC](https://discourse.julialang.org/t/plot-smile-face/118089/2 "2024-08-12T11:32:28Z")

</div>

You propbably just want to plot all four series separately, i.e.

```julia
julia> p = plot(; aspect_ratio = 1)

julia> for x ∈ [y, y1, y2, y3]
           plot!(p, x[:, 1], x[:, 2], color = "black", ls = :dot, label = "")
       end

julia> current()

```

![image](https://global.discourse-cdn.com/julialang/original/3X/2/7/27c473ea03029929b3624b748f38aa3aa17098bf.png)

---

<div class="post-metadata">

**Author:** ![khaledharizb](https://avatars.discourse-cdn.com/v4/letter/k/57b2e6/32.png) [@khaledharizb](https://discourse.julialang.org/u/khaledharizb)\
**Post date:** [August 12, 2024, 11:40am UTC](https://discourse.julialang.org/t/plot-smile-face/118089/3 "2024-08-12T11:40:33Z")

</div>

Thanks for your reply, but why didn’t work with the first code.

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [August 12, 2024, 11:46am UTC](https://discourse.julialang.org/t/plot-smile-face/118089/4 "2024-08-12T11:46:01Z")

</div>

The `plot` just connects all the points in a row, it doesn’t know when a different curve begins or ends.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 12, 2024, 11:55am UTC](https://discourse.julialang.org/t/plot-smile-face/118089/5 "2024-08-12T11:55:41Z")

</div>

You can introduce breaks along the line using `NaN`s, so you can also just change the line of code merging segments like this:

```julia
Y = [y; NaN NaN; y1; NaN NaN; y2; NaN NaN; y3]

```
