From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dov Grobgeld Subject: Re: Generated images in buffer Date: Sun, 28 Nov 2010 22:43:40 +0200 Message-ID: References: <87bp594iau.fsf@gmail.com> <87y68d9x4w.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1699894123==" Return-path: Received: from [140.186.70.92] (port=59989 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PMo62-0006gt-Bc for emacs-orgmode@gnu.org; Sun, 28 Nov 2010 15:43:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PMo61-0002YK-BY for emacs-orgmode@gnu.org; Sun, 28 Nov 2010 15:43:42 -0500 Received: from mail-qy0-f169.google.com ([209.85.216.169]:55164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PMo61-0002YG-5Q for emacs-orgmode@gnu.org; Sun, 28 Nov 2010 15:43:41 -0500 Received: by qyk7 with SMTP id 7so785157qyk.0 for ; Sun, 28 Nov 2010 12:43:40 -0800 (PST) In-Reply-To: <87y68d9x4w.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: Jeff Horn , emacs-orgmode@gnu.org --===============1699894123== Content-Type: multipart/alternative; boundary=00163646d5c2ba0167049623029f --00163646d5c2ba0167049623029f Content-Type: text/plain; charset=ISO-8859-1 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 wrote: > (add-hook 'org-babel-after-execute-hook > (lambda () (org-display-inline-images nil t))) > --00163646d5c2ba0167049623029f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
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<= br style=3D"font-family: courier new,monospace;">#+begin_src ditaa :file example.png
+---------+
| cBLU=A0=A0=A0 |
|=A0=A0=A0=A0=A0=A0=A0= =A0 |
|=A0=A0=A0 +----+
|=A0=A0=A0 |cPNK|
|=A0=A0=A0 |=A0=A0=A0 |
+----+----+
#+end_src

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

width, height =3D 256,256
surface =3D cairo.Image= Surface (cairo.FORMAT_ARGB32, width, height)
ctx =3D cairo.Context (surface)
ctx.set_source_rgb(0,0,= 0)
ctx.rectangle(0,0,width,height)<= br style=3D"font-family: courier new,monospace;"> ctx.fill()
ctx.set_source_rgb(1,1,1)
ctx.move_to(width/2,hei= ght/2)
ctx.arc(width/2,height/2,width*0.2= 5,0,math.pi*2)
ctx.fill()
surface.write_to_png("circle.png") #+end_src

#+res= ults:

[[file:circle.png]]

* A matplotlib graph= from http://matplotli= b.sourceforge.net

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

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

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

#+res= ults:

[[file:graph.png]]

I'm wondering over one thing thoug= h. 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, 20= 10 at 19:27, Dan Davison <dandavison7@gmail.com> wrote:
=A0(add-hook 'org-babel-after-execute-hook
=A0 =A0 =A0 =A0 =A0 =A0(lambda () (org-display-inline-images nil t)))

--00163646d5c2ba0167049623029f-- --===============1699894123== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============1699894123==--