ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 23 Aug 2016 14:49:14 -0500How to export a 3D plot to a jpg/png file (OSX)https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/ 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,
MauroMon, 22 Aug 2016 06:29:09 -0500https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/Answer by paulmasson for <p>Hi everybody, I've got some problems with saving/exporting images. This is my code:</p>
<pre><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])
</code></pre>
<p>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</p>
https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/?answer=34563#post-id-34563I 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.Mon, 22 Aug 2016 15:59:40 -0500https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/?answer=34563#post-id-34563Answer by tmonteil for <p>Hi everybody, I've got some problems with saving/exporting images. This is my code:</p>
<pre><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])
</code></pre>
<p>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</p>
https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/?answer=34560#post-id-34560It 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 ?Mon, 22 Aug 2016 08:21:02 -0500https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/?answer=34560#post-id-34560Comment by paulmasson for <p>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 ?</p>
https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/?comment=34568#post-id-34568Looks like it's Safari. Saving the file works with Firefox. Will update my answer.Tue, 23 Aug 2016 14:49:14 -0500https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/?comment=34568#post-id-34568Comment by kcrisman for <p>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 ?</p>
https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/?comment=34564#post-id-34564I'd wonder about the browser as well, maybe it's only Safari that misbehaves?Mon, 22 Aug 2016 19:42:37 -0500https://ask.sagemath.org/question/34559/how-to-export-a-3d-plot-to-a-jpgpng-file-osx/?comment=34564#post-id-34564