Ask Your Question
1

How to save graphics into an image in sagemath online?

asked 2014-10-11 01:32:32 +0100

Jorge gravatar image

updated 2015-01-17 17:49:21 +0100

FrédéricC gravatar image

I am running sage cloud with a windows computer and I want to save graphics into an image. I found the following documentation:

sage: c = circle((1,1), 1, color='red')
sage: filename = os.path.join(SAGE_TMP, 'test.png')
sage: c.save(filename, xmin=-1, xmax=3, ymin=-1, ymax=3)

However it save nothing on my system or on the online folder. I suspect that this works when you have sagemath installed on the computer. How can I save on my system or on the online folder?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2014-10-11 02:21:04 +0100

dazedANDconfused gravatar image

updated 2014-10-11 02:28:11 +0100

In SageMath Cloud select "New". Type the name you want and click on "Sage Worksheet". The Sage worksheet opens up. Copy/paste the following code into your worksheet.

c = circle((1,1), 1, color='red')
c.save('test.png', xmin=-1, xmax=3, ymin=-1, ymax=3)

Click on "Save" and then click on "Run". It looks like nothing has really happened but if you click on "Files" you will see test.pgn.

If you click on the name of the picture (test.pgn) it will open in your browser. You can right click on the image and save it to your computer. Another option (instead of clicking on the picture name) is to click on the rectangle furthest left (on the same line as test.pgn) then a box opens up giving you options such as download, move,trash. Press download and it should go to your computer. If not there's a link to click, in which case you download as mentioned above (through right-click and Save as).

edit flag offensive delete link more

Comments

I had the same question and tried this. It worked (sort of) but the resulting image had been changed in strange ways, and also there is no option to rotate/zoom to the view you want. The picture I got from screenshot was much better quality. It's hard to believe this is not built into Sagemath- how does anyone use Sagemath for making high-quality illustrations for a paper or a book?

al gravatar imageal ( 2018-02-02 12:20:37 +0100 )edit

Not clear what you mean when you talk about "changed in strange ways". What's the strange behavior you are talking about? The option to zoom/rotate is for 3d images. Try typing G = dodecahedron(color='darkseagreen',opacity=0.2) G.show() After pressing enter, right click on the image. It will give you the options of zooming and rotating. When the image is how you want right click and export to a jpg file or some other image file. I've been able to get high quality images (such as fractals) by saving the image to pdf. You can also force the data through LaTeX using the sagetex package along with tikz/pgfplots to produce high quality illustrations.

dazedANDconfused gravatar imagedazedANDconfused ( 2018-02-02 21:23:03 +0100 )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

Stats

Asked: 2014-10-11 01:32:32 +0100

Seen: 2,742 times

Last updated: Oct 11 '14