* export image generated by python code. @ 2012-04-30 13:54 Khoroshyy Petro 2012-04-30 15:14 ` Darlan Cavalcante Moreira 0 siblings, 1 reply; 3+ messages in thread From: Khoroshyy Petro @ 2012-04-30 13:54 UTC (permalink / raw) To: org-mode mailing list 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]] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: export image generated by python code. 2012-04-30 13:54 export image generated by python code Khoroshyy Petro @ 2012-04-30 15:14 ` Darlan Cavalcante Moreira 2012-05-02 19:10 ` Khoroshyy Petro 0 siblings, 1 reply; 3+ messages in thread From: Darlan Cavalcante Moreira @ 2012-04-30 15:14 UTC (permalink / raw) To: Khoroshyy Petro; +Cc: org-mode mailing list 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]] > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: export image generated by python code. 2012-04-30 15:14 ` Darlan Cavalcante Moreira @ 2012-05-02 19:10 ` Khoroshyy Petro 0 siblings, 0 replies; 3+ messages in thread From: Khoroshyy Petro @ 2012-05-02 19:10 UTC (permalink / raw) 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 = matplotlib.pyplot.figure() axes = figure.add_subplot(111, title=u"Hello", xlabel="x", ylabel="y") x = 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 <darcamo@gmail.com> 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 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]] >> -- ______________________________ Petro Khoroshyy ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-02 19:10 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-04-30 13:54 export image generated by python code Khoroshyy Petro 2012-04-30 15:14 ` Darlan Cavalcante Moreira 2012-05-02 19:10 ` Khoroshyy Petro
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.