From mboxrd@z Thu Jan 1 00:00:00 1970 From: Khoroshyy Petro Subject: Re: export image generated by python code. Date: Wed, 2 May 2012 21:10:00 +0200 Message-ID: References: <4f9eac49.8a1b340a.7045.ffff8af9@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:53369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPew9-0007uD-LE for emacs-orgmode@gnu.org; Wed, 02 May 2012 15:10:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPew7-0008Bb-IP for emacs-orgmode@gnu.org; Wed, 02 May 2012 15:10:05 -0400 Received: from mail-lpp01m010-f41.google.com ([209.85.215.41]:46294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPew7-00085s-8F for emacs-orgmode@gnu.org; Wed, 02 May 2012 15:10:03 -0400 Received: by lagz14 with SMTP id z14so884615lag.0 for ; Wed, 02 May 2012 12:10:00 -0700 (PDT) In-Reply-To: <4f9eac49.8a1b340a.7045.ffff8af9@mx.google.com> 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: Darlan Cavalcante Moreira Cc: org-mode mailing list Hi Darlan. Thanks for you response. I am aware of the working folder differences and use absolute path in my scripts. I have found a workaround in this mailing list: http://lists.gnu.org/archive/html/emacs-orgmode/2011-06/msg00156.html This solves my problem with inline images in results. Have not tried exports yet. #+begin_src python :results output raw :exports results import numpy, matplotlib, matplotlib.pyplot figure =3D matplotlib.pyplot.figure() axes =3D figure.add_subplot(111, title=3Du"Hello", xlabel=3D"x", ylabel= =3D"y") x =3D numpy.arange(-10, 10, 0.1) axes.plot(x, x**2) figure.savefig("/tmp/plot_test.png") figure.clf() print "["+"[/tmp/plot_test.png]]" #+end_src On Mon, Apr 30, 2012 at 5:14 PM, Darlan Cavalcante Moreira wrote: > > Remember that when you execute the code via "C-c C-c" it is run in a > temporary file which is not in the same folder as the org file from where > it was generated from. Maybe you are reading some data from a file and > Python is not able to locate the file when run with "C-c C-c". > > Put ":results output" in the header and then print the current working > directory to see what I mean. If this is the problem, use the full path t= o > load any data you need in the python code. Remember you can use variables > in org-babel to pass this path to python, such as ":var > datapath=3D"some_path_or_lisp_function_to_get_the_path" in the babel head= er.. > > -- > Darlan > > At Mon, 30 Apr 2012 15:54:34 +0200, > Khoroshyy Petro wrote: >> >> Hi all. >> After some struggle, I can see inline pictures =A0in my org file. >> The problem was python execution. If I execure the code in python-mode >> shell, it generates a picture. >> I the code executed via C-c C-c, the output picture file is empty. >> I still do not know how to solve it. >> >> And I have encountered another problem. The 'result' image is not >> exported, even if I add play with :export option. >> >> Any recommendations how to solve those? >> Thanks >> Petro >> #+BEGIN_SRC python :file estimated_spectra_cl.png >> =A0 import pylab >> =A0 from scipy import optimize >> =A0 import numpy as np >> =A0 import pylab as plt >> ..... >> =A0 plt.figure() >> =A0 plt.plot(spectra[:,0],spectra[:,1:]) >> =A0 plt.grid(1) >> =A0 # plt.show() >> =A0 plt.savefig("estimated_spectra_cl.png",dpi=3D100) >> #+END_SRC >> >> #+RESULTS: >> [[file:estimated_spectra_cl.png]] >> --=20 ______________________________ Petro Khoroshyy