Ask Your Question
1

Can sage draw simplicial complexes?

asked 2021-02-22 23:20:51 +0200

dispo gravatar image

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.

Thanks in advance!

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-02-23 01:47:10 +0200

updated 2021-02-23 01:48:39 +0200

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.

edit flag offensive delete link more

Comments

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 )

dispo gravatar imagedispo ( 2021-02-24 09:13:11 +0200 )edit

That sounds great, I hope you do submit something.

John Palmieri gravatar imageJohn Palmieri ( 2021-02-24 18:44:50 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-02-22 23:20:51 +0200

Seen: 93 times

Last updated: Feb 23