Trouble plotting multiple spheres in GLMakie

I would like to plot a sphere inside another sphere. I’m using a wireframe to easily see the intersection in the spheres (if any exist), but I’m open to mesh solutions as well. The code compiles, but it won’t visualize; rather, I get this message instead: Combined{Makie.wireframe,Tuple{Array{Float64,2},Array{Float64,2},Array{Float64,2}}}.
I’m fairly new to Makie so any help would be appreciated.
P.S.: I know the spheres won’t intersect as I have them described, I just wanted to get them on the same graph before I tried moving them around.

using GLMakie


θ,ϕ = collect(0:π/24:2π), collect(0:π/24:π)
r = 900;
c = 400;
x = [r*sin(Φ)*cos(Θ) for Φ ∈ ϕ, Θ ∈ θ];
y = [r*sin(Φ)*sin(Θ) for Φ ∈ ϕ, Θ ∈ θ];
z = [r*cos(Φ) for Φ ∈ ϕ, Θ ∈ θ];

fig = Figure(resolution = (600,400))
ax = Axis(fig[1,1], xlabel="x-label", ylabel = "y-label", zlabel = "z-label", Title = "Title")
wireframe(x,y,z, axis = (type=Axis3,), color=:blue)


x1 = [c*sin(Φ)*cos(Θ) for Φ ∈ ϕ, Θ ∈ θ];
y1 = [c*sin(Φ)*sin(Θ) for Φ ∈ ϕ, Θ ∈ θ];
z1 = [c*cos(Φ) for Φ ∈ ϕ, Θ ∈ θ];
wireframe!(ax,x1,y1,z1, axis = (type=Axis3,), color =:green)




you are missing a few !, also, once you define an axis3 you don’t call it again. Here, the working example:

using GLMakie

θ,ϕ = collect(0:π/24:2π), collect(0:π/24:π)
r = 900;
c = 400;
x = [r*sin(Φ)*cos(Θ) for Φ ∈ ϕ, Θ ∈ θ];
y = [r*sin(Φ)*sin(Θ) for Φ ∈ ϕ, Θ ∈ θ];
z = [r*cos(Φ) for Φ ∈ ϕ, Θ ∈ θ];

x1 = [c*sin(Φ)*cos(Θ) for Φ ∈ ϕ, Θ ∈ θ];
y1 = [c*sin(Φ)*sin(Θ) for Φ ∈ ϕ, Θ ∈ θ];
z1 = [c*cos(Φ) for Φ ∈ ϕ, Θ ∈ θ];

fig = Figure(resolution = (600,400))
ax = Axis3(fig[1,1], xlabel="x-label", ylabel = "y-label", zlabel = "z-label")
wireframe!(ax, x,y,z, color=:blue, transparency = true)
wireframe!(ax, x1,y1,z1, color =:green, transparency=true)
fig

also, I would recommend using transparency=true for a better output effect. The title arg is not supported.

3 Likes

Thank you!