emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jack Kamm <jackkamm@gmail.com>
To: Liu Hui <liuhui1610@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] ob-python: support header argument `:results file graphics'
Date: Wed, 05 Jul 2023 20:49:28 -0700	[thread overview]
Message-ID: <87pm551yyf.fsf@gmail.com> (raw)
In-Reply-To: <CAOQTW-MCb0w67wEkBfXJ1asHrc-h6-2M-bGOLibS1WKHX9nMzw@mail.gmail.com>

Liu Hui <liuhui1610@gmail.com> writes:

> I don't think so. Some users may want to keep the figure between
> blocks, and they can always clear the figure themselves when
> necessary.

I'd rather not have to call pyplot.gcf().clear() every time, it doesn't
seem nice.  ob-R doesn't require manually clearing the plot, and neither
do Jupyter notebooks.

I would propose the following instead: for ":results output graphics",
ob-python should plot the gcf, and clear it beforehand. But for
":results value graphics", the ob-python block should return a
matplotlib Figure object to plot, which would allow keeping and
modifying a Figure between blocks.

I actually proposed that behavior before in this patch:

https://list.orgmode.org/87eenpfe77.fsf@gmail.com/

But never wound up applying it -- the patch was rather large, with a lot
of extra features, and I wasn't sure they were all worth the extra
complexity.  Then life got in the way, and I never got around to
revisiting ob-python plotting, until now.

> BTW, I have updated the patch to turn off the feature by default,
> since it may break existing src blocks using `graphics'. WDYT? Thanks.

I don't think the defcustom is necessary at this point. The feature
makes ob-python consistent with similar Babel languages like ob-R, and I
can't think of any existing use case of ob-python with ":results
graphics" that this would break. In case I missed some obscure edge
case, we can ask forgiveness and redirect the user to ":results link"
instead.

The defcustom might be useful in the future in case we want to support a
non-matplotlib plotting system (such as ete3), but that is relatively
rare and I think it's better to keep it simple for now.


  reply	other threads:[~2023-07-06  3:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03  4:31 [PATCH] ob-python: support header argument `:results file graphics' Liu Hui
2023-07-03  9:28 ` Ihor Radchenko
2023-07-03 10:40   ` Liu Hui
2023-07-03 11:41     ` Ihor Radchenko
2023-07-03 13:23       ` Liu Hui
2023-07-04 11:29         ` Ihor Radchenko
2023-07-05  5:23           ` Jack Kamm
2023-07-05 11:05             ` Ihor Radchenko
2023-07-06  2:49               ` Jack Kamm
2023-07-07 10:53                 ` Ihor Radchenko
2023-07-08 13:55                   ` Jack Kamm
2023-07-09  9:12                     ` Ihor Radchenko
2023-07-12  5:10                       ` Jack Kamm
2023-07-12  8:38                         ` Ihor Radchenko
2023-07-14  2:47                           ` Jack Kamm
2023-07-05  8:09           ` Liu Hui
2023-07-05  4:55   ` Jack Kamm
2023-07-07 10:56     ` Ihor Radchenko
2023-07-05  5:13 ` Jack Kamm
2023-07-05  8:11   ` Liu Hui
2023-07-06  3:49     ` Jack Kamm [this message]
2023-07-06  9:54       ` Liu Hui
2023-07-08 13:59         ` Jack Kamm

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=87pm551yyf.fsf@gmail.com \
    --to=jackkamm@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=liuhui1610@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).