How to plot a cube in 3D in Plots.jl

You can not plot vertical surfaces using surface, you’d need mesh3d for this:

using Plots
xp = [0, 0, 0, 0, 1, 1, 1, 1];
yp = [0, 1, 0, 1, 0, 0, 1, 1];
zp = [0, 0, 1, 1, 1, 0, 0, 1];
connections = [(1,2,3), (4,2,3), (4,7,8), (7,5,6), (2,4,7), (1,6,2), (2,7,6), (7,8,5), (4,8,5), (4,5,3), (1,6,3), (6,3,5)];

mesh3d(xp,yp,zp; connections, xlabel="x", proj_type = :persp, linecolor=:black)
4 Likes