emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Richard Stanton <stanton@haas.berkeley.edu>
To: emacs-orgmode@gnu.org
Subject: Plotting in Python block won't over-write existing file
Date: Fri, 6 Mar 2015 10:41:48 -0800	[thread overview]
Message-ID: <D302C46F-8DBA-4FA1-A2EE-A6C06B8521FC@haas.berkeley.edu> (raw)

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

             reply	other threads:[~2015-03-06 18:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06 18:41 Richard Stanton [this message]
2015-03-06 19:21 ` Plotting in Python block won't over-write existing file Nick Dokos
     [not found] <mailman.99.1425747630.6389.emacs-orgmode@gnu.org>
2015-03-09  4:17 ` Richard Stanton

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=D302C46F-8DBA-4FA1-A2EE-A6C06B8521FC@haas.berkeley.edu \
    --to=stanton@haas.berkeley.edu \
    --cc=emacs-orgmode@gnu.org \
    /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).