Ask Your Question
1

Orienting and Saving 3D Plots

asked 2018-04-27 11:21:59 -0600

Turiel gravatar image

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

Comments

Welcome to Ask Sage! Thank you for your question!

slelievre gravatar imageslelievre ( 2018-04-27 11:34:45 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2018-05-14 03:56:39 -0600

Turiel gravatar image

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

edit flag offensive delete link more

Comments

Good to hear!

eric_g gravatar imageeric_g ( 2018-05-17 07:18:02 -0600 )edit
0

answered 2018-04-28 12:10:01 -0600

eric_g gravatar image

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)
edit flag offensive delete link more

Comments

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.

Turiel gravatar imageTuriel ( 2018-04-28 15:07:19 -0600 )edit

Which operating system are you using? Windows?

eric_g gravatar imageeric_g ( 2018-04-29 04:48:15 -0600 )edit

Yes, I am using Windows 10

Turiel gravatar imageTuriel ( 2018-04-29 06:08:06 -0600 )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.

eric_g gravatar imageeric_g ( 2018-04-29 11:36:57 -0600 )edit

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

Turiel gravatar imageTuriel ( 2018-04-29 13:41:52 -0600 )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

2 followers

Stats

Asked: 2018-04-27 11:18:47 -0600

Seen: 105 times

Last updated: May 14