Package for visualizing wireframe cube

Hi all,
What I am looking for is a package to draw a wireframe cube and to draw segment connecting two 3d points.

Thanks.

Makie can do it.

# to display the plot
using GLMakie

scene=wireframe(FRect3D(Point3f0(-1,-1,-1), Point3f0(2,2,2)))
scatterlines!([0,sqrt(2)], [0,sqrt(2)],[0,sqrt(2)])

# to save the plot to a file
using CairoMakie
CairoMakie.activate!()
save("plot.png", scene)

plot

4 Likes

Thank you Contradict for your solution it seems good and easy.

I didn’t know CairoMakie supported 3D plots! The homepage says only 2D plots are supported…

As far as I see CairoMakie is only used to save a .png file, not for creating the 3D plot…

After some more experimentation, I’m not sure how this all works.

The call to save works fine without using CairoMakie.

In addition, I can create and save the plot only using CairoMakie (no visualization of course), but I haven’t figured out how to adjust the viewpoint.

Just found that the Backends & Output docs actually mention limited support for 3D in CairoMakie:

CairoMakie as a 2D engine has no concept of z-clipping, therefore its 3D capabilities are quite limited. The z-values of 3D plots will have no effect and will be projected flat onto the canvas. Z-layering is approximated by sorting all plot objects by their z translation value before drawing, after that by parent scene and then insertion order. Therefore, if you want to draw something on top of something else, but it ends up below, try translating it forward via translate!(obj, 0, 0, some_positive_z_value) .

1 Like