plot a 3d polyhedron with transparent background?

65 views
Skip to first unread message

Daniel Friedan

unread,
Jul 6, 2015, 12:54:30 PM7/6/15
to sage-s...@googlegroups.com
Is it possible to plot a 3d polyhedron with transparent background?

When I use .plot(transparent=True) on a 2d polyhedron, and save to a file, the background is transparent.

When I do the same for a 3d polyhedron, the background is white.

p2=Polyhedron(vertices=[[0,1],[1,0]])
p3=Polyhedron(vertices=[[0,1,1],[1,0,0]])
p2_plot = p2.plot(transparent=True)
p3_plot = p3.plot(transparent=True)
p2_plot.save(the_file2)   # saved image has transparent background
p3_plot.save(the_file3)   # saved image has white background

thanks,
Daniel

Nathann Cohen

unread,
Jul 7, 2015, 6:13:34 AM7/7/15
to sage-s...@googlegroups.com
When I do the same for a 3d polyhedron, the background is white.

Given that p3.show(whatever=15) does not raise an exception, I would say that 'transparent' is not supported for 3d plots and that your argument is ignored.

Nathann 

kcrisman

unread,
Jul 8, 2015, 10:37:59 AM7/8/15
to sage-s...@googlegroups.com, nathan...@gmail.com
When I do the same for a 3d polyhedron, the background is white.

Given that p3.show(whatever=15) does not raise an exception, I would say that 'transparent' is not supported for 3d plots and that your argument is ignored.

Yes, I believe that is the case.  There *is* the "opacity" keyword, e.g. opacity=0.5, which might do what you are looking for - well, I'm not sure what you are looking for exactly, but you can try it.

Daniel Friedan

unread,
Jul 10, 2015, 6:07:10 PM7/10/15
to sage-s...@googlegroups.com, nathan...@gmail.com

The "opacity" keyword controls the opacity of the polyhedron, not the background.

I was making an animation of the construction of a flat 1-cycle (a limit of 1-cycles in R^3).    The construction added tinier and tinier 1-cycles at each step.

I made the frames using Polyhedron.plot(), then .save(), then used os.system() to invoke ImageMagick to stitch the frames together as an animated gif.

I had to plot the entire 1-cycle for each frame.

It would have saved processing time and storage space if I could have saved only a plot of the 1-cycles added at each step of the construction, with a transparent background, then overlaid that plot on the previous plots using ImageMagick.  Overlaying doesn't work when the latest image has a white background.
Reply all
Reply to author
Forward
0 new messages