Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

3d plot, slow

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!

var('x,y,z')

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

t.save('spheres.png', aspect_ratio = 1, frame = false) then the picture is quite distorted. Is aspect_ratio not what I want for 3d plots?