On Apr 16, 2009, at 3:50 PM, William Stein wrote:

> 2009/4/16 Ondrej Certik <ond...@certik.cz>:
>>
>> Hi,
>>
>> the notebook (sagelite) can work with Graphics primitives in Sage,
>> that's very nice.
>>
>> I would like to make sympy (and other packages) to be able to easily
>> work with the plotting. One way to do plotting is to use matplotlib
>> (or anything else) and drop a .png file, the notebook will show it.
>>
>> But I think a better way is to just return a Graphics object, as  
>> described at:
>>
>> http://sagemath.org/doc/reference/sage/plot/plot.html
>>
>> since the notebook can plot that one too.
>
> The notebook plots graphics objects by just making the show command
> (on a graphics object) output a png.   There is nothing at all special
> about how the notebook plots Graphics 2d objects -- anything that
> outputs a png gets "plotted" and that is it.  It's an incredibly
> simple "protocol", but means that you just immediately use it in your
> code.

To clarify, the __repr__ method calls show() by default.

>>  That would work for 2D
>> plots. For 3D plots, Sage seems to be using a little bit different
>> architecture:
>>
>> sage: G = plot3d(lambda x, y: x^2 + y^2, (-2,2), (-2,2))
>> sage: type(G)
>> <type 'sage.plot.plot3d.parametric_surface.ParametricSurface'>
>>
>> as described at:
>>
>> http://sagemath.org/doc/reference/plot3d.html
>
> For 3d plots it's really very similar, but of course they aren't
> always png's.  Calling show with viewer="tachyon" just renders a png,
> and we're in the above case.  Calling show with no options (no
> viewer="tachyon") uses jmol, which means that a certain file type is
> output.  The notebook then notices that file was created and embeds a
> java jmol applet configured using that file.

It's .jmol (which is actually a .zip file). See http:// 
hg.sagemath.org/sage-main/file/5c72dbb92d82/sage/server/notebook/ 
cell.py#l1

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to