# Can sage draw simplicial complexes?

I understand it's asking a lot to draw complexes in dimensions $>3$, but for (fairly simple) 2 dimensional complexes, it seems reasonable that some plotting algorithm should exist. Even looking at, say, simplicial_complexes.Torus(), it doesn't seem like there's a plot or show method. The docs1 don't seem to have any information either.

Since the things I'm trying to draw are fairly simple, I would be wiling to plot the $1$-skeleton (which sage can do) and then fill in the $2$-cells myself, but I'm not even sure how to go about doing that. Obviously if there is a pre-existing method or library for this, that would be the best possible solution.

1: I don't have the karma to post links, but I'm referencing doc.sagemath.org/html/en/reference/homology/sage/homology/simplicial_complex.html

edit retag close merge delete

Sort by » oldest newest most voted

It's a good question, and we would welcome any contributions in this direction.

Sage can only plot the 1-skeleton right now, and it does this by using the graph theory component of Sage. So if you wanted to fill in the 2-cells, you would need to access the coordinates of the vertices in the plot of the graph and then plot the corresponding triangles. I think this is the way to proceed:

T = simplicial_complexes.Torus() # for example
G = T.graph()
P = G.plot(save_pos=True)
G.get_pos()  # this will return the positions of the vertices


Unfortunately the vertices are forced to be in two dimensions, and I don't see an option like save_pos for G.plot3d(). So it may be hard to get meaningful shading on the triangles.

Another option (which would be more work but might be better in the long run) would be to implement a save_pos option for G.plot3d() and then use that for plotting the triangles.

more

Thanks for the answer! I'll have to look into writing my own, then... If it's decently robust, maybe I'll look into submitting a pull request (or however sage handles code submission... I'll look into it once I actually have code in hand :P )

( 2021-02-24 09:13:11 +0100 )edit

That sounds great, I hope you do submit something.

( 2021-02-24 18:44:50 +0100 )edit