4

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!

Philopolis
  • 515
  • 4
  • 13
  • The Julia home page https://julialang.org/ currently shows some 3D graphs. I don't know how interactive they are, or whether there's PLY support. – user2554330 Jan 04 '22 at 10:28

1 Answers1

1

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.

cbk
  • 4,225
  • 6
  • 27
  • 1
    Thanks! For future reference, it looks like `GLMakie` has other interesting (although non-interactive) functions for that purpose; see for instance https://makie.juliaplots.org/v0.15.1/examples/plotting_functions/mesh/ – Philopolis Jan 07 '22 at 09:33