A similar approach as the last one should work, the problem I was having is
that to print the binary string from python you have to decode it, and
latin-1 seems close to right, but it puts a bunch of extra bytes in it that
lead to a bad png file. I feel like this worked in Python2 with StringIO,
bu
Hello John,
John Kitchin writes:
> you probably figured out the "import io" and "f = io..." line are not
> necessary here.
Indeed.
> I couldn't figure out a reasonable way to use :results graphics link
> that didn't result in repeating the filename more than desired. These
> also both work, bu
you probably figured out the "import io" and "f = io..." line are not
necessary here.
I couldn't figure out a reasonable way to use :results graphics link
that didn't result in repeating the filename more than desired. These
also both work, but seem to both require repeating the filename twice.
#
Roger Mason writes:
> Hello,
>
> stardiviner writes:
>
>> Roger Mason writes:
>>
>>> Hello,
>>>
>>> I want to output the result of the evaluation of a (python) source block
>>> to a (graphics) file and have a link to the file inserted in the buffer.
>
>>> #+begin_src python :results value fil
Hello John,
John Kitchin writes:
> I think you can use something like this:
>
> #+BEGIN_SRC python :results output file :var fname="test.png"
> import matplotlib.pyplot as plt
> import io
>
> f = io.StringIO()
> plt.plot([1, 2, 3, 17])
> plt.savefig(fname)
> print(fname, end='')
> #+END_SRC
>
>
I think you can use something like this:
#+BEGIN_SRC python :results output file :var fname="test.png"
import matplotlib.pyplot as plt
import io
f = io.StringIO()
plt.plot([1, 2, 3, 17])
plt.savefig(fname)
print(fname, end='')
#+END_SRC
It is in Python3.
John
--
Hello again,
stardiviner writes:
> Roger Mason writes:
>
>> Hello,
>>
>> I want to output the result of the evaluation of a (python) source block
>> to a (graphics) file and have a link to the file inserted in the buffer.
>
> For this, you should try updated header arguments like ":results grap
Hello,
Ken Mankoff writes:
>
> What about :var file="scaleplot02.pdf".
That was my starting point, but the resulting link is prefixed by ':'
Perhaps I should upgrade org.
Cheers,
Roger
Hello,
stardiviner writes:
> Roger Mason writes:
>
>> Hello,
>>
>> I want to output the result of the evaluation of a (python) source block
>> to a (graphics) file and have a link to the file inserted in the buffer.
>> #+begin_src python :results value file :file scaleplot02.pdf :exports
>> r
On 2019-06-05 at 12:41 +02, Roger Mason wrote...
> I want to output the result of the evaluation of a (python) source
> block to a (graphics) file and have a link to the file inserted in the
> buffer.
>
> Here is the code:
>
> #+begin_src python :results value file :file scaleplot02.pdf :exports
Roger Mason writes:
> Hello,
>
> I want to output the result of the evaluation of a (python) source block
> to a (graphics) file and have a link to the file inserted in the buffer.
For this, you should try updated header arguments like ":results graphics link"
or ":results file link".
>
> Her
11 matches
Mail list logo