From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 U8h9CjH8pGS7MgAASxT56A (envelope-from ) for ; Wed, 05 Jul 2023 07:14:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 6HrFCTH8pGRlJAAA9RJhRA (envelope-from ) for ; Wed, 05 Jul 2023 07:14:25 +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 915E01C501 for ; Wed, 5 Jul 2023 07:14:24 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=IT0QK97p; 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=1688534064; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=qY8Cv1MMppMTJdo5y5koj4rn1QRJ+i8WGvv9qnzh6ck=; b=s1ykMBgf4Lap71WGYWwVMU7U5Tm/RDVRnW2HwkCd2XLJzOgpYasFtRoC5dgiR6Rjq5S1SK O4dPbnaIE1L/TzqB8EhSmmsvgGWTmZHmrC29jTFd20wVlo5Pg0XaKk8vH4yYZka5pUT4yr /g2oEj00TuQMrptqWNXPpN6KedWyhA0gZ5hhyjRWcn/rewaHQ4noamlcOuO5Kc4I6BzLxQ KFB/J+s6uTNJDmGubyuDv+j2U1IJyLeh7zpHV1ai+WrBiflsbvYTZmF32iTV/Ibx1KdWV1 uXd42aNR9sKisRweZN8xumbcGnOqYxd3yrNK0O9oO5DzexV0mCdILcbH8VZsCg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=IT0QK97p; 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=1688534064; a=rsa-sha256; cv=none; b=TxjvpZLKqHG7ZT4AMIoAvKVqCjVlLJ18zkmVHOK+E6SlIXF468anOOuIiiHTsYPt9+pfID 3f0Q4BcSseNXa8ncS4O2X3UqgK9rTvr0ZnymjRNQhALNRE5L1BffVInWtjPRdWv6LxcDhj WTWNnddYLYQOzINqZWxUf2lh++LnvdAtp7K/UzHKedLF/r7pLBsGcEiZZBFrFxvM59cEBl uqDagY4tINkjDSOGo0pVcV3wBsW8lj+sRJ4XXDSgD8fvyw5hBhwc90VV0EePtK0+EsQgMO jU0jAQvR/Dk7A5NLLMjCO6+FMxkmr69YKiDDn1bvC/OZaKc3eWD3GCCt6dCGQA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGupQ-0004v9-QE; Wed, 05 Jul 2023 01:13:24 -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 1qGupK-0004uf-L8 for emacs-orgmode@gnu.org; Wed, 05 Jul 2023 01:13:18 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGupJ-0008TB-43 for emacs-orgmode@gnu.org; Wed, 05 Jul 2023 01:13:18 -0400 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3a38953c928so3495702b6e.1 for ; Tue, 04 Jul 2023 22:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688533996; x=1691125996; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :from:to:cc:subject:date:message-id:reply-to; bh=qY8Cv1MMppMTJdo5y5koj4rn1QRJ+i8WGvv9qnzh6ck=; b=IT0QK97p5guoDFDQGeCAeT+QwPWj0fPQXE9Fx42R8jbpJeBmA/c7CtrnN4/xigELpn m9b+3Q36NVKn9Pq6y4iG7hLbEs3AloVIsAjD+uv+GeZvncazaN4Kq/O0Ba/aqv+IB/Ps gXE+AVukepxnDBMa1Jz7QyMwkGcGRpnvZ6MRHSqgaw45XC2ko13sjdoXqCpQsjsLdRf3 RrCmXYtZAWkfGqvCO6/c3XkuK0drYgSgQtTUgYcJLGnQ5QTHaQ2i7kcrevreBiFuNA2K mGfCxerdLh1cLZ3NdyUfEImeLSESbbOeMpRwB2tPKBuEJarAuQTjay0j6CvUqS+eVS2f GTkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688533996; x=1691125996; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qY8Cv1MMppMTJdo5y5koj4rn1QRJ+i8WGvv9qnzh6ck=; b=GK2zDUdRMAn5dAB7lIAh0RdFVTshDsZBvrYoUTjQ7p8DPfTf9R9JE+HZuAF6jgUbWz KnytHyB0Fdc6s/kdTWwwr/Gkfg8GofjhDczsOcquv+c2A+v9r7CZX8AjTDab+bQgxGBg OHO3TsIA64o/l8xrVU+MHPcsZibpnA6/RAEcw7FMDqb4JBiCYYbCVF23DLj7gGyRFSL+ +fhgoNwBbLjVFCNv2pPCLDlpiEVFxz/XE2zcu2l1RgrrArWFrWmpUiiY0Biz7POcI/yt 0DKhDlpv9w7QXzbXAwxuBaWuGFDAWaAfw9KAExOPk93DXAzoxZpKlL+SxYeU5TWrSSkO MVkA== X-Gm-Message-State: AC+VfDxMtLWZRdqldgukTnjhEByf7kvDLqE4nG6RVMzypC6rUWKWz4E6 vEQaaahygJQ26eHmTa3xSomc4PhZfs4= X-Google-Smtp-Source: ACHHUZ4wCqrYiZDEJQZG4EEWnXafgMcnQXcWAG4qM5BHvBNdQuCvZVTiItTt/3iBkwVadgVoInmhaw== X-Received: by 2002:a05:6808:1598:b0:3a1:e166:156a with SMTP id t24-20020a056808159800b003a1e166156amr19938810oiw.8.1688533995730; Tue, 04 Jul 2023 22:13:15 -0700 (PDT) Received: from localhost (157-131-78-143.fiber.dynamic.sonic.net. [157.131.78.143]) by smtp.gmail.com with ESMTPSA id l6-20020a656806000000b005579c73d209sm14546248pgt.1.2023.07.04.22.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 22:13:14 -0700 (PDT) From: Jack Kamm To: Liu Hui , emacs-orgmode@gnu.org Subject: Re: [PATCH] ob-python: support header argument `:results file graphics' In-Reply-To: References: Date: Tue, 04 Jul 2023 22:13:14 -0700 Message-ID: <87y1jv0wlx.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=jackkamm@gmail.com; helo=mail-oi1-x236.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: scn0.migadu.com X-Migadu-Spam-Score: -12.23 X-Spam-Score: -12.23 X-Migadu-Queue-Id: 915E01C501 X-TUID: AvSdbBX5Ox+u Liu Hui writes: > Hi, > > This patch adds graphics output support for ob-python via matplotlib. > Specifically, it allows to use header argument `:results file > graphics' as follows: > > #+begin_src python :file "test.png" :results graphics file > import matplotlib.pyplot as plt > plt.plot([1,2,3,4,5]) > #+end_src > > The feature is described in the documentation as follows and has been > supported by ob-R, ob-julia, etc. Thanks -- I haven't had a chance to test drive this yet, but I do have a couple questions: 1. Do you need to add a call to pyplot.gcf().clear(), in case of multiple blocks in a session? 2. Would it make sense to wrap in pyplot.rc_context, so that we can use the :width and :height arguments like ob-R? E.g., with pyplot.rc_context({'figure.figsize': (8,5)}): pyplot.plot([1,2,3,4,5]) pyplot.gcf().savefig('filename.png') Will create a png file with width 8 and height 5.