emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ken Mankoff <mankoff@gmail.com>
To: Dror Atariah <drorata@gmail.com>
Cc: Nick Dokos <ndokos@gmail.com>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: [Orgmode] Unable to capture the file name generated using matplotlib
Date: Tue, 26 May 2015 10:02:54 -0400	[thread overview]
Message-ID: <m27frvphbl.fsf@gmail.com> (raw)
In-Reply-To: <CANfRcg1hN-FNSZy_JRzowUnCY+27CkTNWNHWPBYTZjE6jseocA@mail.gmail.com>


On 2015-05-26 at 09:26, Dror Atariah <drorata@gmail.com> wrote:
>> #+BEGIN_SRC python :session with_matplotlib :results file :exports both
>> import matplotlib
>> matplotlib.use('Agg')
>> import matplotlib.pyplot as plt
>> fig=plt.figure(figsize=(3,2))            # 4
>> plt.plot([1,3,2])                              # 3
>> plt.savefig('myfig.png')                  # 2
>> 'myfig.png'                                     # 1
>> #+END_SRC
>>
>> #+RESULTS:
>> [[file:myfig.png]]
>>
>
> As I mentioned before, if I evaluate the second block as-is I get the
> error. However, if I comment out all the lines except #1 then the code
> returns the correct results block. Then, I started to add the numbered
> lines. Adding #2 and #3 still doesn't break the behavior. Once adding line
> #4 the behavior breaks. Maybe this observation can be helpful? This happens
> both when starting Emacs -Q or without -Q.


Still no solution but a few comments:

1) What you write here and on SE are not the same. Please cut-and-paste because details matter. For example, the SE code has "import matplotlib.pyplot" and then "plt.figure" but that code crashes because you did not import "as plt" like you do here...

2) It seems to be an echo issue. In my *with_matplotlib* buffer in Emacs, I see:

#+BEGIN_EXAMPLE
Python 2.7.9 |Anaconda 2.2.0 (x86_64)| (default, Dec 15 2014, 10:37:34) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import matplotlib
>>> matplotlib.use('Agg')
>>> import matplotlib.pyplot as plt
fig=plt.figure(figsize=(3,2))
plt.plot([1,3,2])

plt.savefig('myfig.png')
'myfig.png'

open('/var/folders/bl/trcxdptd1_q4k6q5fdhvp2m00000gn/T/babel-52565cmH/python-525659vF', 'w').write(str(_))
'org_babel_python_eoe'
>>> [<matplotlib.lines.Line2D object at 0x10454dd10>]
>>> 'myfig.png'
>>> 'org_babel_python_eoe'
>>>
#+END_EXAMPLE

Where you see everything printed twice. I notice that in addition, you have

> r/folders/kz/1c2cxn1x60n_t5p2j1p02b180000gn/T/py6499_X0''', 'exec'));

at the top of your buffer, and I do not. I think the "exec" might be causing everything to echo as it runs, so everything is printed 2x, and that confuses Org, and it is not able to capture your filename.

  -k.
  

  reply	other threads:[~2015-05-26 14:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-02  7:48 [Orgmode] Unable to capture the file name generated using matplotlib Dror Atariah
2015-05-02 17:09 ` Nick Dokos
2015-05-02 17:11 ` Nick Dokos
2015-05-05 20:20   ` Dror Atariah
2015-05-23 18:49     ` Dror Atariah
2015-05-25 17:25       ` Dror Atariah
2015-05-25 17:29         ` Ken Mankoff
2015-05-25 18:22           ` Dror Atariah
2015-05-25 18:30             ` John Kitchin
2015-05-26 13:11               ` Dror Atariah
2015-05-26 13:15                 ` Ken Mankoff
2015-05-26 13:19                   ` Dror Atariah
2015-05-26 13:26               ` Dror Atariah
2015-05-26 14:02                 ` Ken Mankoff [this message]
2015-05-26 14:37                   ` Dror Atariah
2015-05-26 18:39                   ` Dror Atariah
2015-06-02  5:49                     ` Dror Atariah
2015-06-02 12:21                       ` Ken Mankoff
2015-06-02 18:01                         ` Dror Atariah
2015-05-26  1:49             ` Ken Mankoff
2015-05-26 13:18               ` Dror Atariah
2015-05-26 14:05                 ` Ken Mankoff

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=m27frvphbl.fsf@gmail.com \
    --to=mankoff@gmail.com \
    --cc=drorata@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=ndokos@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).