Embedding 3d plots in a blog

5 views
Skip to first unread message

Janzo

unread,
Mar 22, 2008, 8:14:42 AM3/22/08
to sage-edu
Hi.
I'm trying to embed a 3d plot in my wordpress blog, I have found a
little howto in http://www.openscience.org/blog/?p=208

But I don't know how to get the code of a Jmol applet than a 3d plot
generates.

Do you know how to get the code?
thanks.

David Joyner

unread,
Mar 22, 2008, 8:31:38 AM3/22/08
to sage...@googlegroups.com

I think it is under file -> export->"export image or script",
then you get a pop up window. I think jpg is the only choice currently
available,
but I don't remember for sure.

> thanks.
>
> >
>

William Stein

unread,
Mar 22, 2008, 11:28:44 AM3/22/08
to sage...@googlegroups.com, sage-support

I think the original poster (Janzo) wants a dynamically rotatable Jmol
java applet embedded right in his webpage, rather than a static
jpg image. If you just want a static image, you can take a screen shot,
or use viewer='tachyon' as an option to the plot3d or show command
in Sage.

It is definitely possible to have the Jmol applet embedded right in a
blog post -- in fact, that's exactly how I first learned about Jmol.
Look at the last example here:
http://www.openscience.org/blog/
Look at the discussion here:
http://groups.google.com/group/sage-devel/browse_thread/thread/b0dd0a6788db2471/ecbe425e6ab9a625?lnk=gst&q=chemists+rock#ecbe425e6ab9a625

This might help.

William

Janzo

unread,
Mar 22, 2008, 1:45:19 PM3/22/08
to sage-edu
Thanks David but William is right. I have seen that blog (exactly the
post for embed wordpress with jmol is that http://www.openscience.org/blog/?p=208)
but what I can't do is to get the jmol applet, I need the applet and
sage doesn't give it to me, it only displays the applet :(
any idea?

thanks again.

On Mar 22, 4:28 pm, "William Stein" <wst...@gmail.com> wrote:
> On Sat, Mar 22, 2008 at 5:31 AM, David Joyner <wdjoy...@gmail.com> wrote:
>
> > On Sat, Mar 22, 2008 at 8:14 AM, Janzo <juanman...@gmail.com> wrote:
>
> > > Hi.
> > > I'm trying to embed a 3d plot in my wordpress blog, I have found a
> > > little howto inhttp://www.openscience.org/blog/?p=208
>
> > > But I don't know how to get the code of a Jmol applet than a 3d plot
> > > generates.
>
> > > Do you know how to get the code?
>
> > I think it is under file -> export->"export image or script",
> > then you get a pop up window. I think jpg is the only choice currently
> > available,
> > but I don't remember for sure.
>
> I think the original poster (Janzo) wants a dynamically rotatable Jmol
> java applet embedded right in his webpage, rather than a static
> jpg image. If you just want a static image, you can take a screen shot,
> or use viewer='tachyon' as an option to the plot3d or show command
> in Sage.
>
> It is definitely possible to have the Jmol applet embedded right in a
> blog post -- in fact, that's exactly how I first learned about Jmol.
> Look at the last example here:
> http://www.openscience.org/blog/
> Look at the discussion here:
> http://groups.google.com/group/sage-devel/browse_thread/thread/b0dd0a...
>
> This might help.
>
> William

William Stein

unread,
Mar 22, 2008, 2:02:09 PM3/22/08
to sage...@googlegroups.com
On Sat, Mar 22, 2008 at 10:45 AM, Janzo <juanm...@gmail.com> wrote:
>
> Thanks David but William is right. I have seen that blog (exactly the
> post for embed wordpress with jmol is that http://www.openscience.org/blog/?p=208)
> but what I can't do is to get the jmol applet, I need the applet and
> sage doesn't give it to me, it only displays the applet :(
> any idea?
>

Get the jmol applet from the jmol website.

-- william

Janzo

unread,
Mar 22, 2008, 2:06:48 PM3/22/08
to sage-edu
Sorry it could be my poor english but you don't understand me.

Actually I have running jmol's applets of some molecules in my blog.
What I can't do is get the code of my sage's applet, I mean I plot
some parametric surface in a jmol applet, ok, now... where is the code
of that applet??

I hope to be more clear :)
thanks.

On Mar 22, 7:02 pm, "William Stein" <wst...@gmail.com> wrote:
> On Sat, Mar 22, 2008 at 10:45 AM, Janzo <juanman...@gmail.com> wrote:
>
> > Thanks David but William is right. I have seen that blog (exactly the
> > post for embed wordpress with jmol is thathttp://www.openscience.org/blog/?p=208)

William Stein

unread,
Mar 22, 2008, 2:10:30 PM3/22/08
to sage...@googlegroups.com, sage-support
On Sat, Mar 22, 2008 at 11:06 AM, Janzo <juanm...@gmail.com> wrote:
>
> Sorry it could be my poor english but you don't understand me.
>
> Actually I have running jmol's applets of some molecules in my blog.
> What I can't do is get the code of my sage's applet, I mean I plot
> some parametric surface in a jmol applet, ok, now... where is the code
> of that applet??
>
> I hope to be more clear :)

Maybe you don't meed the "code of the applet", but the data that Sage
creates which is then read in by the applet? If so, the only way to
answer your question is to wait to see if Robert Bradshaw responds (he
probably will by Monday),
or to look in detail at the appropriate part of the Sage source code.

-- William

Robert Bradshaw

unread,
Mar 22, 2008, 2:20:24 PM3/22/08
to sage...@googlegroups.com, Janzo
On Mar 22, 2008, at 11:06 AM, Janzo wrote:

> Sorry it could be my poor english but you don't understand me.
>
> Actually I have running jmol's applets of some molecules in my blog.
> What I can't do is get the code of my sage's applet, I mean I plot
> some parametric surface in a jmol applet, ok, now... where is the code
> of that applet??
>
> I hope to be more clear :)
> thanks.

I assume you're looking for the actual script that generates the
surface, right? There should be an easier way to get it (should we
always provide a direct link or would that be too intrusive?) but
here's a way to do it currently. At the top of the cell type

open ('a.txt', 'w')

which will create a file. This will turn into a link at the bottom of
the cell which you can click on. The url will be something like
https://localhost:8000/home/admin/73/cells/1/a.txt . This tells you
that all the data files for that cell are in https://localhost:8000/
home/admin/73/cells/1 . (Once you know the folder, you don't need
a.txt anymore, but that's the easiest way to get to it.)
Specifically, there is a .jmol script, and a .jmol.zip file.
The .jmol script is what needs to be fed into the applet, and all it
does is tell the applet to load everything in the .jmol.zip file
(which is an ordinary zip file, but all packaged into a single bundle
so it's easier to keep track of). This should be all you need to run
the applet statically on any web page.

- Robert

Janzo

unread,
Mar 23, 2008, 8:34:23 AM3/23/08
to sage-edu
Thanks Robert! I have a .pmesh file.

Now my problem is than I only know how to put a .mol (or .xyz) file in
my blog with that code

<div class="jmol" id="caffeine_applet">
<img src="wp-content/logo.png" onLoad="insertJmol('caffeine_applet',
400,400,'caffeine.mol')" alt="caffeine screenshot"/>
</div>

and this is a .pmesh file and doesn't work. I think this is more for
the jmol-users list but do you know how to convert the .pmesh file to
a .mol file?
By the way I'm going to try with other codes to insert the .pmesh
file...

Thanks a lot.

PS: I think a wordpress plugin to integrate the sage jmol applets
could be a lot of usefull for all

On Mar 22, 7:20 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:
> On Mar 22, 2008, at 11:06 AM, Janzo wrote:
>
> > Sorry it could be my poor english but you don't understand me.
>
> > Actually I have running jmol's applets of some molecules in my blog.
> > What I can't do is get the code of my sage's applet, I mean I plot
> > some parametric surface in a jmol applet, ok, now... where is the code
> > of that applet??
>
> > I hope to be more clear :)
> > thanks.
>
> I assume you're looking for the actual script that generates the
> surface, right? There should be an easier way to get it (should we
> always provide a direct link or would that be too intrusive?) but
> here's a way to do it currently. At the top of the cell type
>
> open ('a.txt', 'w')
>
> which will create a file. This will turn into a link at the bottom of
> the cell which you can click on. The url will be something like https://localhost:8000/home/admin/73/cells/1/a.txt . This tells you
> that all the data files for that cell are inhttps://localhost:8000/

Janzo

unread,
Mar 23, 2008, 4:21:21 PM3/23/08
to sage-edu
Hi again:

I have explored a bit more Jmol.
I have tried a lot to show the pmesh file in a Jmol applet... I have
learned to open the pmesh file in the Jmol program (console command:
pmesh "my_sage_surface.pmesh") but then I can't do anything with that :
(

Where is the code you use in sage to show the applet?

thanks.
> > the cell which you can click on. The url will be something like https://localhost:8000/home/admin/73/cells/1/a.txt. This tells you

William Stein

unread,
Mar 23, 2008, 4:48:40 PM3/23/08
to sage...@googlegroups.com, sage-support
On Sun, Mar 23, 2008 at 1:21 PM, Janzo <juanm...@gmail.com> wrote:
>
> Hi again:
>
> I have explored a bit more Jmol.
> I have tried a lot to show the pmesh file in a Jmol applet... I have
> learned to open the pmesh file in the Jmol program (console command:
> pmesh "my_sage_surface.pmesh") but then I can't do anything with that :
> (
>
> Where is the code you use in sage to show the applet?

If you refresh a sage notebook page that shows a 3d jmol image you'll
see that it contains:
jmol_applet(500, "/home/admin/37/cells/16/sage0-size500.jmol")
where jmol_applet is some javascript function that is defined by main.js
(part of Sage) basically to be

jmolApplet(size, "script " + url);

where jmolApplet is defined in Jmol.js (which is from the jmol website).

By the way, this email should be in sage-support. It's not a sage-edu
question, and there are over 10 times as many people subscribed to sage-support.

-- William

Reply all
Reply to author
Forward
0 new messages