ob-sagemath icon indicating copy to clipboard operation
ob-sagemath copied to clipboard

error when generating sage pdf files

Open sjLambda opened this issue 7 years ago • 4 comments

Thanks for the sage integration with org-babel. It works well for text, code, and tables output, but not for some graphics output types. More specifically I am not able to specify pdf or eps as file output types. I need at least one vector format, even svg would be fine. Alas but to no avail.

Your png example works well. But change that same src block png to pdf or eps, the output generated is not valid postscript file. (see attached pdf for an sample file generated by sage). Is this something that can be fixed with ob-sagemath or a problem with org-babel?

A related question: how can I use the src_block vars inside sage code in that block? For example, :file below?

Try this src_block in any org file to recreate the problem PDF file:

#+begin_src sage  :file image.pdf
g=Graph({1:[2,3], 2:[1,3], 3:[1,2]});g
#+end_src

ai-graph-theory-1.pdf

sjLambda avatar May 01 '18 23:05 sjLambda

I paste the code of your block in SAGE, and the result is not a plot. Are you sure the code reflects what you want?

In SAGE I tried

g=Graph({1:[2,3], 2:[1,3], 3:[1,2]});
g.plot().save('/tmp/foo.pdf')

That could be a starting point.

Doxdrum avatar Sep 13 '18 09:09 Doxdrum

Doxdrum, yes you are right about running in SAGE and your example works. However, I'm running from a source block inside an ORG file in Emacs. ob-sagemath dumps only to png and not other formats.

sjLambda avatar Oct 01 '18 20:10 sjLambda

As of 9.7.beta8, this works :


#+name: test2
#+begin_src sage :exports both :results file link :file test2.pdf
  plot(sin, (-pi, pi), figsize=4)
#+end_src

#+RESULTS: test2
[[file:test2.pdf]]

I sugest closing this issue...

EmmanuelCharpentier avatar Aug 17 '22 20:08 EmmanuelCharpentier

Any chance something similiar could be done but for svg as well?

kchousos avatar Dec 11 '22 22:12 kchousos