Ask Your Question

publish 3d plots to web?

asked 2010-11-23 06:40:54 -0500

Kate Stange gravatar image

updated 2010-11-23 07:39:03 -0500

I'd like to post the output of a 3d plot to the web. For example, after plotting a surface, a Jmol output is produced, which my browser renders in the notebook. I'd like this Jmol plot to be output as a file that could be uploaded to a server and embedded in a webpage (where it can still be manipulated with the mouse, etc.). Is there a way to do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2010-11-28 07:24:44 -0500

niles gravatar image

updated 2010-12-01 05:31:55 -0500

This isn't a complete answer, but may get you or someone else started, depending on how hard you want to work:

As far as I can tell, there are basically two things you need to be able to do to display the output on a separate page. First, figure out how to load the JMol application on that page. I think this involves finding and loading a bunch of javascript files, and is probably described on the JMol Website. Second, figure out how to find the data file Sage produces to be plotted with JMol, and also load that into your webpage. To that end, I would suggest looking at the source code for your notebook page, and search for some lines like the following (I'd suggest searching for "jmol?" on the page):

<div class="cell_output_html_wrap" id="cell_output_html_112">
  <div><script>jmol_applet(500, "/home/admin/10/cells/112/sage0-size500.jmol?1290969964");</script></div>

The path specified is relative to the location of your sage notebook files. This is printed right after you start the notebook server -- the default is ".sage/sage_notebook" in your home directory:

sage: notebook()
The notebook files are stored in: sage_notebook.sagenb

Once you've found the relevant data file and copied it somewhere your page can load it, you might be finished by just using something like the <script> block above . . . except that I don't see jmol_applet as part of the JMol documentation -- the closest-looking function I've seen is jmolApplet. So if jmol_applet is defined in one of the other javascript libraries loaded in the sage notebook, then you'll have to load that library and all of its dependencies too, or figure out how to use one of the other JMol commands to load and display your data file. Looking again at the source of the notebook page with your 3d plot may give you a good idea of which javascript files to use.

Good luck, and please let us know if you make some progress on this, or find out a better way to do it!


I just noticed that if you try to plot something from the command line, sage opens up a JMol java applet which has useful options and menus like File > Export > Export to Web Page. This saves the data in a place of your choosing, but you still have to point it to the JMol .jar files.

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


Asked: 2010-11-23 06:40:54 -0500

Seen: 488 times

Last updated: Dec 01 '10