# Orienting and Saving 3D Plots

Hi !

I am very new to using Sage, I've started only a few weeks ago. I hope my inability to answer anyone's questions won't ruin my "karma" ! Anyway, here is my first question:

I've been experimenting with plotting 3D objects, so far. Right now, I am plotting simple cubes scattered in space. With great satisfaction, I've noticed I could initialize the point of view of my 3D plot by specifying:

orientation(0,0,0,0)

That initializes to X being horizontal, Y vertical, and Z orthogonal to the screen. Then, I specify:

G.rotate([1,0,0],pi/4).show(aspect_ratio=[1,1,1],frame=False)

and get a point of view I really like. My goal is to generate a bunch of .png files of my cubes from different points of view, and I was hoping to use this rotate() functionality with a [ for i in range(n)] type statement. Therefore, I'd really like SAGE to write a bunch of .png files without me generating images one by one and saving manually. So I tried using the save() function, like so:

G.rotate([1,0,0],pi/4).save("MyImage.png",aspect_ratio=[1,1,1],frame=False)

Here is my problem: when I use the save() function, my previous orientation(0,0,0,0) statement is completely overridden, and the resulting MyImage.png I get is rotated according to rotate([1,0,0],pi/4), but not from the intented X being horizontal, Y vertical, and Z orthogonal to the screen configuration, rather, from the default point of view show() gives me, if I do not specify orientation(0,0,0,0).

Why is it so, and how can I fix this ?

Thank you very much, Turiel.

edit retag close merge delete

Welcome to Ask Sage! Thank you for your question!

( 2018-04-27 11:34:45 -0500 )edit

Sort by ยป oldest newest most voted

Hi !

As eric_g suggested, this issue has been fixed for Windows 10 in SageMath 8.2 ! I ran my code exactly the same way I wrote it weeks ago, and now the .png image generated with the save function using the same arguments I used in the show function looks exactly the same as what's in the Notebook.

Thank you very much, Turiel

more

Good to hear!

( 2018-05-17 07:18:02 -0500 )edit

With SageMath 8.1, the following works for me (i.e. the png figure has the same orientation as that displayed in the Jmol window):

sage: G = cube()
sage: G.rotate([1,0,0], pi/4).show(aspect_ratio=[1,1,1], orientation=(0,0,0,0), frame=False)
Launched jmol viewer for Graphics3d Object
sage: G.rotate([1,0,0], pi/4).save("MyImage.png", aspect_ratio=[1,1,1], orientation=(0,0,0,0), frame=False)

more

I have copy pasted exactly your code, I have SageMath 8.1 as well, but I still have the same problem ! And I am using exactly your code !

I have no idea why this is happening.

( 2018-04-28 15:07:19 -0500 )edit

Which operating system are you using? Windows?

( 2018-04-29 04:48:15 -0500 )edit

Yes, I am using Windows 10

( 2018-04-29 06:08:06 -0500 )edit
1

OK, there have been a number of issues with Jmol and Windows, which have been fixed recently (see e.g. ticket #25025. These fixes will become effective in SageMath 8.2, to be released very soon (hopefully within a few days). So I would advice to upgrade to SageMath 8.2, when it becomes available, and then try again.

( 2018-04-29 11:36:57 -0500 )edit

Alright, I will wait patiently and let you know how it goes when SageMath 8.2 comes out.

( 2018-04-29 13:41:52 -0500 )edit