Re: [O] Output result of source block to a file

2019-06-08 Thread John Kitchin
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

Re: [O] Output result of source block to a file

2019-06-08 Thread Roger Mason
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

Re: [O] Output result of source block to a file

2019-06-07 Thread John Kitchin
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. #

Re: [O] Output result of source block to a file

2019-06-07 Thread stardiviner
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

Re: [O] Output result of source block to a file

2019-06-07 Thread Roger Mason
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 > >

Re: [O] Output result of source block to a file

2019-06-06 Thread John Kitchin
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 --

Re: [O] Output result of source block to a file

2019-06-06 Thread Roger Mason
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

Re: [O] Output result of source block to a file

2019-06-06 Thread Roger Mason
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

Re: [O] Output result of source block to a file

2019-06-06 Thread Roger Mason
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

Re: [O] Output result of source block to a file

2019-06-05 Thread Ken Mankoff
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

Re: [O] Output result of source block to a file

2019-06-05 Thread stardiviner
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