Thanks! This is exactly what I was looking for. And indeed it is as easy to
output a graph from python (or any other language) as it is from ditaa:

* A ditaa image
#+begin_src ditaa :file example.png
+---------+
| cBLU    |
|         |
|    +----+
|    |cPNK|
|    |    |
+----+----+
#+end_src

#+results:
[[file:example.png]]
* A Python image
#+begin_src python :file circle.png
import cairo,math, os

width, height = 256,256
surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, width, height)
ctx = cairo.Context (surface)
ctx.set_source_rgb(0,0,0)
ctx.rectangle(0,0,width,height)
ctx.fill()
ctx.set_source_rgb(1,1,1)
ctx.move_to(width/2,height/2)
ctx.arc(width/2,height/2,width*0.25,0,math.pi*2)
ctx.fill()
surface.write_to_png("circle.png")
#+end_src

#+results:

[[file:circle.png]]

* A matplotlib graph from http://matplotlib.sourceforge.net

#+begin_src python :file graph.png
from pylab import *

t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)

xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
savefig("graph.png",dpi=50)
#+end_src

#+results:

[[file:graph.png]]

I'm wondering over one thing though. When exporting to HTML, the ditaa
source code is omitted, but the python source code is included. Is there any
way of controlling this in begin_src?

Thanks!
Dov


On Sun, Nov 28, 2010 at 19:27, Dan Davison <dandavis...@gmail.com> wrote:

>  (add-hook 'org-babel-after-execute-hook
>            (lambda () (org-display-inline-images nil t)))
>
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to