emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Darlan Cavalcante Moreira <darcamo@gmail.com>
To: Khoroshyy Petro <khoroshyy@gmail.com>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: export image generated by python code.
Date: Mon, 30 Apr 2012 12:14:12 -0300	[thread overview]
Message-ID: <4f9eac49.8a1b340a.7045.ffff8af9@mx.google.com> (raw)
In-Reply-To: <CAEoO5zre9Ms_7Vit-J_HGP4so-awCG1gGCBwKxbohfox8wEmzg@mail.gmail.com>


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 to
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="some_path_or_lisp_function_to_get_the_path" in the babel header..

--
Darlan

At Mon, 30 Apr 2012 15:54:34 +0200,
Khoroshyy Petro <khoroshyy@gmail.com> wrote:
> 
> Hi all.
> After some struggle, I can see inline pictures  in 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
>   import pylab
>   from scipy import optimize
>   import numpy as np
>   import pylab as plt
> .....
>   plt.figure()
>   plt.plot(spectra[:,0],spectra[:,1:])
>   plt.grid(1)
>   # plt.show()
>   plt.savefig("estimated_spectra_cl.png",dpi=100)
> #+END_SRC
> 
> #+RESULTS:
> [[file:estimated_spectra_cl.png]]
> 

  reply	other threads:[~2012-04-30 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-30 13:54 export image generated by python code Khoroshyy Petro
2012-04-30 15:14 ` Darlan Cavalcante Moreira [this message]
2012-05-02 19:10   ` Khoroshyy Petro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f9eac49.8a1b340a.7045.ffff8af9@mx.google.com \
    --to=darcamo@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=khoroshyy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).