Ask Your Question
1

How to export a 3D plot to a jpg/png file (OSX)

asked 2016-08-22 13:29:09 +0100

maurosirigu gravatar image

updated 2017-01-08 12:23:24 +0100

FrédéricC gravatar image

Hi everybody, I've got some problems with saving/exporting images. This is my code:

var ('x y z')

#Define a 3d curve as the intersection of 2 surfaces 
#(but not explicit in z so we must use implicit plots)

# Let's plot
xmin=-3; xmax=3; ymin=-1; ymax=5; zmin=-3; zmax=3;

# Axes
Ax=line3d(([xmin,0,0],[xmax,0,0]), thickness=2, color='red')
Ay=line3d(([0,ymin,0],[0,ymax,0]), thickness=2, color='blue')
Az=line3d(([0,0,zmin],[0,0,zmax]), thickness=2, color='green')

# Surfaces
S1=implicit_plot3d(y==x^2+z^2,(x,xmin,xmax),(y,ymin,ymax),(z,zmin,zmax), opacity=0.4, color='yellow')
S2=implicit_plot3d(z==y/2,(x,xmin,xmax),(y,ymin,ymax),(z,zmin,zmax), opacity=0.4, color='purple')

show(S1+S2+Ax+Ay+Az, aspect_ratio=[1,1,1])

I just wanted to execute the code, rotate the plot right from the graphics and export the image as a png file. This should by done by right-clicking on the plot and chosing export to png from the menu... Unfortunately, the output is a blank screen with just the string "Invalid JSmol request: saveFile" Any suggestion, please? I'm working with the OS X version, and I'm a total newbie... Thanks in advice, Mauro

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2016-08-22 15:21:02 +0100

tmonteil gravatar image

updated 2016-08-22 15:22:16 +0100

It works for me on Debian GNU/Linux. I modified the title of your post to attract OSX users ;) What web browser are you using ? Could you try with firefox and chromium ?

edit flag offensive delete link more

Comments

I'd wonder about the browser as well, maybe it's only Safari that misbehaves?

kcrisman gravatar imagekcrisman ( 2016-08-23 02:42:37 +0100 )edit
1

Looks like it's Safari. Saving the file works with Firefox. Will update my answer.

paulmasson gravatar imagepaulmasson ( 2016-08-23 21:49:14 +0100 )edit
0

answered 2016-08-22 22:59:40 +0100

updated 2016-08-23 21:56:50 +0100

I can confirm that the error occurs on OS X / Safari when trying to save a JSmol image from a Sage notebook. Sage notebooks are no longer actively developed so that error won't go away any time soon.

If you want to use a notebook anyway, try using a different browser. The location of the notebooks by default is http://localhost:8080/home/admin/, and you'll need the password you created when you first started a notebook. Saving images works for me with Firefox as the browser displaying the notebook.

There is another type of notebook, a Jupyter notebook, but the JSmol context menu doesn't appear to function properly for that notebook type in Safari or Firefox so that's not much help.

One workaround is to not start the notebook, but enter your code at the Sage command line. That launches the Java version Jmol. Saving images from the Java version works for me on OS X El Capitan.

Another option is to go to http://sagecell.sagemath.org and enter your code there. Saving JSmol images works there as well, because that functionality has recently been updated.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-08-22 13:29:09 +0100

Seen: 1,019 times

Last updated: Aug 23 '16