Search code examples
plotjuliargl

Julia equivalent for rgl R package?


I would like to know whether there exists in Julia something which would be rougly equivalent to the rgl package in R language; i.e., a library allowing for a dynamic/interactive representation of 3D plots, 3D surfaces, etc.

A bit of context: if you're studying, for example, morphometrics, you regularly end up with files in PLY format, or another format produced by 3D scanners. In R, you can for instance visualize (in an interactive way) easily a 3D surface acquired by such a scanner (here, a set of molars):

enter image description here

Do we have currently a similar feature in Julia? If so, which library should I use?

Thanks!


Solution

  • Makie.jl, specifically via either the GLMakie.jl or WebGLMakie.jl backends, is a good option for interactive plots. For instance, the following example from the BeautifulMakie gallery

    using GLMakie
    let
        x = y =  LinRange(-2, 2, 51)
        z = (-x .* exp.(-x .^ 2 .- (y') .^ 2)) .* 4
        zmin, zmax = minimum(z), maximum(z)
        cmap = :viridis
        fig = Figure(resolution = (900,900))
        ax = Axis3(fig, aspect = :data, perspectiveness = 0.5, elevation = π/9,
            xzpanelcolor= (:black, 0.75), yzpanelcolor= (:black,0.75),
            zgridcolor = :grey, ygridcolor = :grey,xgridcolor = :grey)
        surface!(ax, x, y, z, colormap = cmap, colorrange = (zmin, zmax))
        xm, ym, zm = minimum(ax.finallimits[])
        contour!(ax, x, y, z, levels = 20, colormap = cmap, linewidth = 2,
            colorrange=(zmin, zmax), transformation = (:xy, zm))
        wireframe!(ax, x, y, z, overdraw = true, transparency = true,
            color = (:black, 0.1))
        fig[1,1] = ax
        fig
    end
    

    opens an interactive window that can be rotated at will with the cursor.

    Interacting with Makie plot window

    I am not familiar with the PLY format however, so cannot comment on that aspect of the question.