Liu Hui <liuhui1...@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....@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.