[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Plotting in Python block won't over-write existing file
From: |
Nick Dokos |
Subject: |
Re: [O] Plotting in Python block won't over-write existing file |
Date: |
Fri, 06 Mar 2015 14:21:54 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Richard Stanton <address@hidden> 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