Do you want it as a 2D surface, pre folding?
This code may help - it lets you arrange a number of 2D matrices and rotate as needed.
The problem with this of course is that the edges don’t always have adjacent 2D coordinates, as @Scruffynerf mentions.
Or as a 6 walls in 3D space, like the built in example?
You could run that 3D cube through some transformations and get polar coordinates - treating it as a sphere, and get a 2D output (like lat + long on a globe).