From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Mikhail Titov" Subject: Re: python/babel inline images Date: Thu, 7 Jun 2012 10:09:58 -0500 Message-ID: <005101cd44bf$9ae2ce90$d0a86bb0$@us> References: <87pq9egifm.fsf@bye.fritz.box> <874nqp9580.fsf@gmx.com> <87ehpt8k1l.wl%william.lechelle@ens-lyon.fr> <87d35cwjrt.fsf@bye.fritz.box> <001801cd4418$e34e5d40$a9eb17c0$@us> <8762b3eclu.fsf@bye.fritz.box> Mime-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:36962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SceLc-0004R4-Qk for emacs-orgmode@gnu.org; Thu, 07 Jun 2012 11:10:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SceLa-00080g-Ah for emacs-orgmode@gnu.org; Thu, 07 Jun 2012 11:10:04 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:56101 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SceLa-0007yY-3X for emacs-orgmode@gnu.org; Thu, 07 Jun 2012 11:10:02 -0400 In-Reply-To: <8762b3eclu.fsf@bye.fritz.box> Content-Language: en-us List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: 'henry atting' Cc: emacs-orgmode@gnu.org > -----Original Message----- > From: henry atting [mailto:nsmp_06@online.de] > Sent: Thursday, June 07, 2012 3:43 AM > To: Mikhail Titov > Cc: 'henry atting'; emacs-orgmode@gnu.org > Subject: Re: python/babel inline images > > >> The code itself works flawlessly. So > >> the workaround which I already have used is to link to the resulting > >> image. The only drawback with this solution is that after every > >> evaluation I have to remove the empty `'Results:' > > > > You can use :results silent > > This is great! Actually this solves my problem which means: create a link > to the file and set results to silent. This has an implication of inability to cache results in case you might want it. I personally would just leave empty #+RESULTS: block as is and I would place link manually two lines below it (leave 1 blank line so re-evaluation won't delete your link). > > >> but the heck with > >> it, I can live with it happily till the end of my days. > >> However I find that some inconsistency lies therein. Before > >> python/matplotlib I used gnuplot with which babel had no problem of > >> this type. > > > > Try using > > > > ... :file exp_csv.svg > > ... > > plot.savefig(file=sys.stdout) > > This does not compile, the compiler complains about missing arguments. > I have to write it like this: > > plot.savefig("file.svg", format='svg') I never used that library but it makes sense:-) The only problem with this solution that you should make sure nothing else goes to stdout. I think it is a huge shortcoming. > So, just to mention the current state of affairs (with a simple > example): > > --8<---------------cut here---------------start------------->8--- > #+begin_src python :results output > from pylab import * > > t = arange(0.0, 2.0, 0.01) > s = sin(2*pi*t) > plot(t, s) > show() > savefig("file.svg", format='svg') > #+end_src > --8<---------------cut here---------------start------------->8--- > > The above code works. But if I set `:file' to `file.svg' with every > evaluation the link to the file is placed after #+RESULTS: but the > file itself is empty. As William LECHELLE pointed out that in this case file captures the output of the savefig() call which does not output anything to stdout. So it is expected. > If the code is evaluated without `:file > file.svg' the evaluation simply works and the file.svg appears in the > working directory. I think this is the best way to proceed. M.