emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Plotting in Python block won't over-write existing file
@ 2015-03-06 18:41 Richard Stanton
  2015-03-06 19:21 ` Nick Dokos
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Stanton @ 2015-03-06 18:41 UTC (permalink / raw)
  To: emacs-orgmode

Here’s a sample Python code block:

#+begin_src python :results file :exports both
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import pandas as pd

df = pd.DataFrame({'date': [1900, 1901, 1902], 'x1' : [3, 4, 5], 'x2' : [6, 7, 9]})
df.set_index('date', inplace=True, drop=True)
df.plot()
plt.savefig('x4.png')
return 'x4.png' # return filename to org-mode
#+End_src

When I run it, the graph appears on the screen and in the named file, as desired.

However, if I go back, change one of the numbers, and rerun the block, while it claims to have run OK, the graph is not updated. I only get a new plot if I also change the file name (e.g., to x5.png). It looks like it’s refusing to over-write an existing file. Is there a reason for this, and is there a way to change this behavior?

By the way, this is with org-mode 8.3beta-884-g9ed426

Thanks.

Richard Stanton

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Plotting in Python block won't over-write existing file
  2015-03-06 18:41 Richard Stanton
@ 2015-03-06 19:21 ` Nick Dokos
  0 siblings, 0 replies; 3+ messages in thread
From: Nick Dokos @ 2015-03-06 19:21 UTC (permalink / raw)
  To: emacs-orgmode

Richard Stanton <stanton@haas.berkeley.edu> writes:

> Here’s a sample Python code block:
>
> #+begin_src python :results file :exports both
> import matplotlib
> matplotlib.use('Agg')
> import matplotlib.pyplot as plt
> import pandas as pd
>
> df = pd.DataFrame({'date': [1900, 1901, 1902], 'x1' : [3, 4, 5], 'x2' : [6, 7, 9]})
> df.set_index('date', inplace=True, drop=True)
> df.plot()
> plt.savefig('x4.png')
> return 'x4.png' # return filename to org-mode
> #+End_src
>
> When I run it, the graph appears on the screen and in the named file, as desired.
>
> However, if I go back, change one of the numbers, and rerun the block,
> while it claims to have run OK, the graph is not updated. I only get a
> new plot if I also change the file name (e.g., to x5.png). It looks
> like it’s refusing to over-write an existing file. Is there a reason
> for this, and is there a way to change this behavior?
>
> By the way, this is with org-mode 8.3beta-884-g9ed426
>

IIUC, you eval the code, hit the resulting link (which opens a buffer with the
graph), change a number and reeval the code - do you hit the link again?
That should ask you whether you want to read the changed file again and
show the updated graph.

Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Plotting in Python block won't over-write existing  file
       [not found] <mailman.99.1425747630.6389.emacs-orgmode@gnu.org>
@ 2015-03-09  4:17 ` Richard Stanton
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Stanton @ 2015-03-09  4:17 UTC (permalink / raw)
  To: emacs-orgmode

> Date: Fri, 06 Mar 2015 14:21:54 -0500
> From: Nick Dokos <ndokos@gmail.com>
> To: emacs-orgmode@gnu.org
> Subject: Re: [O] Plotting in Python block won't over-write existing
> 	file
> Message-ID: <87sidi9bjh.fsf@alphaville.usersys.redhat.com>
> Content-Type: text/plain; charset=utf-8
> 
> Richard Stanton <stanton@haas.berkeley.edu> writes:
> 
>> Here?s a sample Python code block:
>> 
>> #+begin_src python :results file :exports both
>> import matplotlib
>> matplotlib.use('Agg')
>> import matplotlib.pyplot as plt
>> import pandas as pd
>> 
>> df = pd.DataFrame({'date': [1900, 1901, 1902], 'x1' : [3, 4, 5], 'x2' : [6, 7, 9]})
>> df.set_index('date', inplace=True, drop=True)
>> df.plot()
>> plt.savefig('x4.png')
>> return 'x4.png' # return filename to org-mode
>> #+End_src
>> 
>> When I run it, the graph appears on the screen and in the named file, as desired.
>> 
>> However, if I go back, change one of the numbers, and rerun the block,
>> while it claims to have run OK, the graph is not updated. I only get a
>> new plot if I also change the file name (e.g., to x5.png). It looks
>> like it?s refusing to over-write an existing file. Is there a reason
>> for this, and is there a way to change this behavior?
>> 
>> By the way, this is with org-mode 8.3beta-884-g9ed426
>> 
> 
> IIUC, you eval the code, hit the resulting link (which opens a buffer with the
> graph), change a number and reeval the code - do you hit the link again?
> That should ask you whether you want to read the changed file again and
> show the updated graph.

Thanks, Nick. After MUCH investigation, and a lot of help from John Kitchen, I worked out that

a. The file was changing fine on disk, just not redisplaying in Emacs.

b. The problem seems to be related to the version of Emacs I'm using (24.4 for OS X), downloaded from http://emacsformacosx.com/builds. After going back there and downloading and installing Emacs 24.4.90 pretest, org-mode now updates graphs just fine. 

I don't know what the problem was, or why changing the Emacs version solved it (with no other changes), but maybe this will be helpful to someone else.

Best,

RIchard Stanton

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-09  4:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.99.1425747630.6389.emacs-orgmode@gnu.org>
2015-03-09  4:17 ` Plotting in Python block won't over-write existing file Richard Stanton
2015-03-06 18:41 Richard Stanton
2015-03-06 19:21 ` Nick Dokos

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).