Ask Your Question

3d plot, slow

asked 2018-03-22 19:47:01 +0200

Daniel L gravatar image

I have some graphical objects (spheres and planes) and I'm trying to create a nice picture to export as a .png (other options?). The problem I'm having is that the interactive mode (right clicking on the graphic) is so slow that the menu options freeze up. I'd like to preview the image (rotate it around, zoom, etc.) before saving so that I can make sure I've got the right picture. What is a more efficient/ faster way to create and export a 3d picture? Thanks!


E1 = implicit_plot3d(x^2+y^2+z^2==1/4, (x,-1/2,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'gray', opacity = 0.6)

E2 = implicit_plot3d((x-1)^2+y^2+z^2==1/4, (x,-1/2,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'gray')

E3 = implicit_plot3d((x-1/2)^2+(y-sqrt(3)/2)^2+z^2==1/4, (x,-1/2,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'gray')

E4 = implicit_plot3d(z == -1/2, (x,-1,4), (y,-1,4), (z,-0.6,0.5), color = 'gray', opacity = 0.2)

E6 = implicit_plot3d((x+1/2)^2+(y-sqrt(3)/2)^2+z^2==1/4, (x,-1,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'gray')

S1 = implicit_plot3d((x-1)^2+y^2+(z-1/2)^2==1, (x,-1,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'blue', opacity = 0.2)

S2 = implicit_plot3d((x+1/2)^2+(y-sqrt(3)/2)^2+(z+1/2)^2==1, (x,-1,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'blue', opacity = 0.2)

show(E1+E2+E3+E6+M1+S1+S2, aspect_ratio = 1, frame = false)

Also, if I try

t = E1+E2+E3+E6+M1+S1+S2'spheres.png', aspect_ratio = 1, frame = false) then the picture is quite distorted. Is aspect_ratio not what I want for 3d plots?

edit retag flag offensive close merge delete


Also, is there a way to crank up the resolution so the spheres don't look pixelated?

Daniel L gravatar imageDaniel L ( 2018-03-22 21:52:29 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-03-23 10:29:27 +0200

Sébastien gravatar image

First, you may look at the documentation which list the kind of arguments you can try:

sage: S = sphere()

The variable M1 is not defined in the question so show(E1+E2+E3+E6+M1+S1+S2, aspect_ratio = 1, frame = false) returns NameError: name 'M1' is not defined on my computer. Removing M1 from the sum, I am able to run show in about 1s (running on a recent computer with Ubuntu 16.04):

sage: %time show(E1+E2+E3+E6+S1+S2, aspect_ratio=1, frame=False)
Launched jmol viewer for Graphics3d Object
CPU times: user 172 ms, sys: 16 ms, total: 188 ms
Wall time: 1.01 s

image description

Then, using zoom and figsize arguments I get for Jmol viewer:

sage: t = E1+E2+E3+E6+S1+S2 # +M1
sage: %time'spheres-jmol.png', aspect_ratio=1, frame=False, zoom=1.5, figsize=20, viewer='jmol')
CPU times: user 164 ms, sys: 8 ms, total: 172 ms
Wall time: 1.36 s

image description

and for Tachyon viewer:

sage: %time'spheres-tachyon.png', aspect_ratio=1, frame=False, zoom=1.4, figsize=10, viewer='tachyon')
CPU times: user 64 ms, sys: 8 ms, total: 72 ms
Wall time: 2.23 s

image description

You may want to test the other viewers (see the documentation I have mentionned above).

edit flag offensive delete link more


Great, thanks for the help!

Daniel L gravatar imageDaniel L ( 2018-04-02 05:13:06 +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


Asked: 2018-03-22 19:47:01 +0200

Seen: 647 times

Last updated: Mar 23 '18