emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ob-python: support header argument `:results file graphics'


From: Liu Hui
Subject: Re: [PATCH] ob-python: support header argument `:results file graphics'
Date: Mon, 3 Jul 2023 18:40:16 +0800

Ihor Radchenko <yantar92@posteo.net> 于2023年7月3日周一 17:28写道:

> This might be a useful feature, but it will break the existing
> conventions, if used as in the patch. Currently, the above combination
> of :file and :results is treated as the following:
>
> ‘graphics’
>      When used along with ‘file’ type, the result is a link to the file
>      specified in ‘:file’ header argument.  However, unlike plain ‘file’
>      type, code block output is not written to the disk.  The block is
>      expected to generate the file by its side-effects only, as in the
>      following example:
>
>           #+begin_src shell :results file link :file "org-mode-unicorn.svg"
>             wget -c "https://orgmode.org/resources/img/org-mode-unicorn.svg";
>           #+end_src
>
>           #+RESULTS:
>           [[file:org-mode-unicorn.svg]]
>
>      If ‘:file’ header argument is omitted, interpret source block
>      result as the file path.

I have updated the patch and ‘:file’ header argument can be omitted
now, e.g.

#+begin_src python :results graphics file
import matplotlib.pyplot as plt
plt.plot([1,2,3,4,5])
plt.savefig('test.png')
return 'test.png'
#+end_src

In this case, `graphics' can be removed too.

> What if the user wants to use, for example, pyplot instead of
> matplotlib?

pyplot is a module of matplotlib. If you mean users want to use other
graphics libraries, they may advise `org-babel-python-save-graphics'
if they want to use `graphics' in the header argument. If necessary,
ob-python may support such libraries too.

Attachment: 0001-ob-python-support-header-argument-results-file-graph.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]