# Makie.jl: How to plot a 3D sphere?

**URL:** <https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302>\
**Category:** General Usage\
**Tags:** question, plotting\
**Created:** [June 14, 2019, 11:19am UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302 "2019-06-14T11:19:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![machakann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/machakann/32/3914_2.png) [@machakann](https://discourse.julialang.org/u/machakann)\
**Post date:** [June 14, 2019, 11:19am UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302/1 "2019-06-14T11:19:04Z")

</div>

Hi, I just started to learn [Makie.jl](https://github.com/JuliaPlots/Makie.jl) package and am facing a problem. I would like to make a 3D plot with `scatter()` function. When I tried to plot two spheres, I got what I expected.

```julia
using Makie

x = [0, 1]
y = [0, 1]
z = [0, 1]
scatter(x, y, z)

```

![Makie_two_sphere](https://global.discourse-cdn.com/julialang/original/3X/f/1/f163e52b7e62cd13f5ae586a938cc147b179319b.png)

However, when I tried to plot only one sphere, I got a 2D plot instead of a 3D plot.

```julia
using Makie

x = [0]
y = [0]
z = [0]
scatter(x, y, z)

```

![Makie_one_sphere](https://global.discourse-cdn.com/julialang/original/3X/8/2/82f31555e57473020b6a9de5fc24c518ca1c48a3.png)

Is there any way to plot only one sphere in a 3D plot?

---

<div class="post-metadata">

**Author:** ![Noel\_Araujo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noel_araujo/32/4862_2.png) [@Noel\_Araujo](https://discourse.julialang.org/u/Noel_Araujo)\
**Post date:** [June 14, 2019, 12:06pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302/2 "2019-06-14T12:06:37Z")

</div>

If the first solution works, use it 🙂

```julia
x = [0, 1]
y = [0, 1]
z = [0, 1]

scatter(x, y, z, markersize=[0.2,0.0])

```

 ![sphere%20alone](https://global.discourse-cdn.com/julialang/original/3X/b/2/b265ad5559291f4c64b3e166f43b03579a2bfcd6.png)  
I’ve tried to change `alpha` to get the same effect, but somehow did not work 😧

---

<div class="post-metadata">

**Author:** ![machakann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/machakann/32/3914_2.png) [@machakann](https://discourse.julialang.org/u/machakann)\
**Post date:** [June 14, 2019, 2:14pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302/3 "2019-06-14T14:14:01Z")

</div>

I see, zero-radius sphere! So clever.  
Thanks!

---

<div class="post-metadata">

**Author:** ![cserteGT3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/csertegt3/32/8283_2.png) [@cserteGT3](https://discourse.julialang.org/u/cserteGT3)\
**Post date:** [June 14, 2019, 2:45pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302/4 "2019-06-14T14:45:56Z")

</div>

Are you sure you want to `scatter()` the sphere?  
You can do the following too ([source](https://simondanisch.github.io/ReferenceImages/gallery//sphere_mesh/index.html)):

```julia
#using AbstractPlotting
using Makie
mesh(Sphere(Point3f0(0), 1f0), color = :blue)

```

Few months ago keyword `alpha` wasn’t implemented yet, but here’s a workaround:

> [@Plotting a transparent planes/boxes with Makie](https://discourse.julialang.org/t/plotting-a-transparent-planes-boxes-with-makie/21875/2):
>
> The bug is, that the alpha keyword isn’t implemented yet smiley But you can use plot(..., color = (:blue, 0.1), transparency = true), or any other transparent Colors.Colorant

Thought I did not tested it for scatter markers.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [June 14, 2019, 2:48pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302/5 "2019-06-14T14:48:22Z")

</div>

You can use:

```julia
scatter(x, y, z, camera = cam3d!)

```

---

<div class="post-metadata">

**Author:** ![machakann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/machakann/32/3914_2.png) [@machakann](https://discourse.julialang.org/u/machakann)\
**Post date:** [June 15, 2019, 12:55am UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302/6 "2019-06-15T00:55:28Z")

</div>

Thank you, it looks beautiful. Is this different from `meshscatter` function?

---

<div class="post-metadata">

**Author:** ![machakann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/machakann/32/3914_2.png) [@machakann](https://discourse.julialang.org/u/machakann)\
**Post date:** [June 15, 2019, 12:57am UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-3d-sphere/25302/7 "2019-06-15T00:57:56Z")

</div>

This is elegant way to force my plot as a 3D plot! Thank you.
