From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 2C/cGwA6pmRTGwEASxT56A (envelope-from ) for ; Thu, 06 Jul 2023 05:50:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 0Cn/GgA6pmT4awAAG6o9tA (envelope-from ) for ; Thu, 06 Jul 2023 05:50:24 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0E3642A13B for ; Thu, 6 Jul 2023 05:50:24 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=oElnua94; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1688615424; a=rsa-sha256; cv=none; b=nhymRbjMDsmpzTPhc+ChGk3yl8am9Qo9oxfaZU4Yqf5nVlwNib5z4+VGPKWeuzJ7781m0T fYAXJg7Unp+MePbaTO81ETLW5JyCWYyyNTjYF2mOkCc/ysdDFtLEEVn/hvRecbzX0GGu+g aXnccha9aTQ9+jadsX6lgyHSPgHcxZp6ur/RyIglyQS5bwEIBXz6eWqMkHwlVknY/k/cGa 9G+AcbjRmzL+PiXgr2Vi6kBPNPmQXL4P1sAUDtwvEFaRnauckg1Aynv0gsePXv/Fp7G6Jv BgOMOJrC2k/tWElAIySFXSMraFo5FsWkn8OeNuZ8Qg0g3ynRUAgLccpEnfL3DQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=oElnua94; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1688615424; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=8icDJSFfBOnvBBYsFwjImBm3aeLisyjCKhKwOHw5KIs=; b=iHHb9/x2GWNKnaulEAIMK8uzZ0gq/qJXKB17meUSJuKyfBvNKSMr7eLYKaaZCDB6rg+0of 3Kdq/M53rTdL7bRsCB5aohe1tfNzmUTl42q5PTCJeZLdhf3kzvV9PY9pCqCQxMnTqDyfVr YQrPjoKkMPJx1MPcaC/mcNAbMFHYOGUHkBBCxB9vGp26NvojPz3Nx8p3jYOgetfpJCvmlP WzAmXUPHTBEam6Q3oShfgNpE6vUHXR/QkMieGIfL41F7sRZsyFALasrksqgrovy3LlRx6V eO7K0sV1zaudjUfYO3t/xtXQJPVSEuXI9e8+AgMJ0HmTN2BYfJffRC078UFzJw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHFzr-0001vg-DU; Wed, 05 Jul 2023 23:49:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHFzq-0001vU-81 for emacs-orgmode@gnu.org; Wed, 05 Jul 2023 23:49:34 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHFzo-0007g9-GD for emacs-orgmode@gnu.org; Wed, 05 Jul 2023 23:49:33 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-666ecb21f86so300096b3a.3 for ; Wed, 05 Jul 2023 20:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688615371; x=1691207371; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=8icDJSFfBOnvBBYsFwjImBm3aeLisyjCKhKwOHw5KIs=; b=oElnua94HYMWFmfBZsUsctKNhg3/jdn0lkjP75Se44zAOVP7U3jpE+jgDCIs+ctm+K qvf9B2NZZiH8hnEfmbbE9YZD+RD1B25JFheJbf8nlDhrjyhy/5YJd5pWKXZ/x1I1Byw4 1q0ZDMHXo48KEjp3Nipulbm5h/5zuUGok3eznYGvI0WwoT2z5UPbuP/mkHGJP2Qzcluk afO5jrrex2/89PhNh7pz74W7WtWdPp1EWyfTtjgO15jzNtahwuL2w9JlHGjh88YjCOHZ hMfeLzYsTJn8XHi3DH5uUVQgBtLkIxNpvMg/fS8NSNXdb8OyHdcfOV0L8yvCAhMpbReQ oCAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688615371; x=1691207371; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8icDJSFfBOnvBBYsFwjImBm3aeLisyjCKhKwOHw5KIs=; b=flphSLe1ZIbj2okihJQn3UDAeYPNlHXLeJdIofIHRoCQ9J8GKvEwRzkYMdAIAvhmHG bnz0GiaJPn+LaFB+RZRouFmsT9H7FEmb7AVmapmclEQqaUgUrXShh4jJFflXDovuodHF xsNvuLc/UGvEOVXe+njblnZyIqgYbP0qoPDVDLpLRemkAIbMdiFWe/acxbMbBmLbmT56 H4pRYF+mJuP7aSHOTsBR3iNzhTxHAkTxf0UEZ3WNaXjsnT43dOYvYUw5/0HVyxfiDdTO Qu9X6c0fvj/ntE663+3htHX25pMG8FGE06KDMpyWTKckheO5kE44b2RlztcA9I/uK8OG mehw== X-Gm-Message-State: ABy/qLY0hvTf8SJw6MmajGGH8V97Gtif1mq1SWmTCQXREITS6jl4nFjl 60Sluwd9BSTTlHwF4/V7ru8= X-Google-Smtp-Source: APBJJlHqjRfZXvvaCTt8yVEER9daDgzSc5LmwZ/AfBsedAozy/Cl/KlgemXz5/nM+9jD7uDoS1OYTQ== X-Received: by 2002:a05:6a00:a88:b0:682:5a68:9846 with SMTP id b8-20020a056a000a8800b006825a689846mr897541pfl.16.1688615370657; Wed, 05 Jul 2023 20:49:30 -0700 (PDT) Received: from localhost (157-131-78-143.fiber.dynamic.sonic.net. [157.131.78.143]) by smtp.gmail.com with ESMTPSA id a5-20020aa78645000000b0066883d75932sm244006pfo.204.2023.07.05.20.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 20:49:29 -0700 (PDT) From: Jack Kamm To: Liu Hui Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] ob-python: support header argument `:results file graphics' In-Reply-To: References: <87y1jv0wlx.fsf@gmail.com> Date: Wed, 05 Jul 2023 20:49:28 -0700 Message-ID: <87pm551yyf.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=jackkamm@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -6.44 X-Migadu-Queue-Id: 0E3642A13B X-Spam-Score: -6.44 X-TUID: 1K+FlCHHUo7E Liu Hui 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.