# Plots circle in 3D space

**URL:** https://discourse.julialang.org/t/plots-circle-in-3d-space/64121
**Category:** New to Julia
**Tags:** plots
**Created:** [July 6, 2021, 3:19am UTC](https://discourse.julialang.org/t/plots-circle-in-3d-space/64121 "2021-07-06T03:19:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![iHany](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihany/32/18151_2.png) [@iHany](https://discourse.julialang.org/u/iHany)
#### Post date: [July 6, 2021, 3:19am UTC](https://discourse.julialang.org/t/plots-circle-in-3d-space/64121/1 "2021-07-06T03:19:47Z")

</div>

Hi,  
I’m trying to draw a circle in 3D space.

Example code is:

```julia
using Plots
using LinearAlgebra
using Transducers

function _test()
    fig = plot()
    p = zeros(3)
    l = 0.3
    body_U = [0, 0, 1]
    plot!(fig, circle_shape(p + l*[1, 0, 0], l/2.5, body_U);
          st=:surface, opacity=0.25, c=:green,
         )
end

"""
c: centre
r: radius
h: direction of normal vector
"""
function circle_shape(c, r, h)
    normal_vec1 = nothing
    while true
        rand_vec = rand(3)
        normal_vec1 = cross(h, rand_vec)
        if norm(normal_vec1) > 0
            normal_vec1 = normal_vec1 / norm(normal_vec1)
            break
        end
    end
    normal_vec2 = cross(h, normal_vec1)
    normal_vec2 = normal_vec2 / norm(normal_vec2)
    θs = LinRange(0, 2*π-1e-2, 500)
    circle = θs |> Map(θ -> c + r*cos(θ)*normal_vec1 + r*sin(θ)*normal_vec2) |> collect
    circle_E = circle |> Map(p -> p[2]) |> collect
    circle_N = circle |> Map(p -> p[1]) |> collect
    circle_U = circle |> Map(p -> -p[3]) |> collect
    circle_E, circle_N, circle_U
end

```

But it looks like a cylinder as  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/4/e402a404a2d9a4552a567267742ae7a3f8e6f312.jpeg)

What did I do something wrong?

[Note] the result when I don’t specify the `seriestype`:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/5/e56b3f5a7f4f18e3f9b051a3eabddefe2602cd16.jpeg)

---

<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: [July 6, 2021, 8:13am UTC](https://discourse.julialang.org/t/plots-circle-in-3d-space/64121/2 "2021-07-06T08:13:55Z")

</div>

Results seem to look good when specifying `st=:line`?  
 ![Plots_gr_oriented_disk](https://global.discourse-cdn.com/julialang/original/3X/b/9/b98c91fe9f7bcfba5510a020c50534b5a2b2b266.png)

---

<div class="post-metadata">

### Author: ![iHany](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihany/32/18151_2.png) [@iHany](https://discourse.julialang.org/u/iHany)
#### Post date: [July 7, 2021, 12:49am UTC](https://discourse.julialang.org/t/plots-circle-in-3d-space/64121/3 "2021-07-07T00:49:24Z")

</div>

I’m gonna try it. Thanks!

EDIT: it works very well!
