How to plot a 3D grid in Makie

It’s super easy to visualize a 3D grid with scatter!:

using Makie
using WGLMakie

r = -2:2
fig = Figure()
ax = LScene(fig[1, 1], show_axis=false)
scatter!(ax, [Point3f(x,y,z) for x in r for y in r for z in r])

…but, how do I create a 3D grid of lines, rather than using scatter!?

You mean something like the following?

using Meshes, MeshViz
import GLMakie as Mke

grid = CartesianGrid(10, 10, 10)

viz(grid, showfacets = true)

grid = RectilinearGrid(0:1:10, 0:2:10, 0:3:10)

viz(grid, color = 1:nelements(grid))

Sort of, just without the surfaces of the cubes. I figured out how to accomplish something that works using arrows!.

You can set the transparency to only show the line segments:

viz(grid, showfacets = true, alpha = 0.0)

1 Like