[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ob-python: support header argument `:results file graphics'
From: |
Jack Kamm |
Subject: |
Re: [PATCH] ob-python: support header argument `:results file graphics' |
Date: |
Wed, 05 Jul 2023 20:49:28 -0700 |
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.
- Re: [PATCH] ob-python: support header argument `:results file graphics', (continued)
- Re: [PATCH] ob-python: support header argument `:results file graphics', Jack Kamm, 2023/07/08
- Re: [PATCH] ob-python: support header argument `:results file graphics', Ihor Radchenko, 2023/07/09
- Re: [PATCH] ob-python: support header argument `:results file graphics', Jack Kamm, 2023/07/12
- Re: [PATCH] ob-python: support header argument `:results file graphics', Ihor Radchenko, 2023/07/12
- Re: [PATCH] ob-python: support header argument `:results file graphics', Jack Kamm, 2023/07/13
- Re: [PATCH] ob-python: support header argument `:results file graphics', Liu Hui, 2023/07/05
Re: [PATCH] ob-python: support header argument `:results file graphics', Jack Kamm, 2023/07/05
Re: [PATCH] ob-python: support header argument `:results file graphics', Jack Kamm, 2023/07/05