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

Hi, I just started to learn 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.

using Makie

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

Makie_two_sphere

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

using Makie

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

Makie_one_sphere

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

1 Like

If the first solution works, use it :slight_smile:

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

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


I’ve tried to change alpha to get the same effect, but somehow did not work :anguished:

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

Are you sure you want to scatter() the sphere?
You can do the following too (source):

#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:

Thought I did not tested it for scatter markers.

You can use:

scatter(x, y, z, camera = cam3d!)
2 Likes

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

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