Sphere surface and axes artefact in Makie.jl

I am trying to plot points on the Bloch sphere using GLMakie, but I get white lines around the lines I use to draw the sphere:

Is there anything I can do to fix this? The script I used to generate the plot is below. I use lines! to draw contours of the sphere, and surface! to draw the transparent sphere.

using GLMakie

function bloch_sphere()
    fig = Figure()
    ax = Axis3(fig[1, 1], aspect = :data, azimuth = pi/6, elevation = pi/8)
    horizontal_circle = [Point3f(cospi(x), sinpi(x), 0) for x in LinRange(0,2,100)]
    vertical_circle = [Point3f(cospi(x), 0, sinpi(x)) for x in LinRange(0,2,100)]
    n = 50
    sx = zeros(n,n)
    sy = zeros(n,n)
    sz = zeros(n,n)
    φs = LinRange(0, 2pi, n)
    θs = LinRange(0, pi, n)
    for i in 1:n
        for j in 1:n
            sx[i,j] = cos(φs[i])*sin(θs[j])
            sy[i,j] = sin(φs[i])*sin(θs[j])
            sz[i,j] = cos(θs[j])
        end
    end
    surface!(ax, sx, sy, sz, color=fill(:gray, n, n), alpha=0.5, transparency=true,
            invert_normals=true)
    lines!(ax, horizontal_circle, color=:black)
    lines!(ax, vertical_circle, color=:black)
    lines!(ax, [Point3f(-1,0,0), Point3f(1,0,0)], color=:black)
    lines!(ax, [Point3f(0,-1,0), Point3f(0,1,0)], color=:black)

    limits!(ax, -1.1, 1.1, -1.1, 1.1, -1.1, 1.1)

    fig
end

fig = bloch_sphere()
1 Like

apply transparency also to lines.

1 Like

This section is also relevant

1 Like

That works great, thanks!

Thanks, that also fixes my problem (with more detail for other cases / solutions as well).