From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arun Persaud Subject: using pdf as output of src-block doesn't show an inline image Date: Fri, 5 Feb 2016 21:48:21 -0800 Message-ID: <56B58925.5050204@lbl.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRvjc-00053R-KJ for emacs-orgmode@gnu.org; Sat, 06 Feb 2016 00:48:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRvjX-0002GY-Kx for emacs-orgmode@gnu.org; Sat, 06 Feb 2016 00:48:40 -0500 Received: from fe4.lbl.gov ([128.3.41.71]:12289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRvjX-0002GS-BB for emacs-orgmode@gnu.org; Sat, 06 Feb 2016 00:48:35 -0500 Received: by mail-pa0-f52.google.com with SMTP id uo6so45890883pac.1 for ; Fri, 05 Feb 2016 21:48:24 -0800 (PST) Received: from ?IPv6:2602:306:bd9b:d540:be5f:f4ff:fe1c:eade? ([2602:306:bd9b:d540:be5f:f4ff:fe1c:eade]) by smtp.gmail.com with ESMTPSA id v29sm28266288pfa.31.2016.02.05.21.48.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Feb 2016 21:48:23 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode Hi I use org mode more and more to plot data using python source blocks. If I create pngs, org mode will display these results as an inline image, which is nice. Since I also export my org buffer via latex to pdf, it would be nice to create pdf plots with python, so that I get vector graphics in the pdf. This is easy to do in python's matplotlib, but once I change to pdf output, the images don't get displayed inline in org-mode anymore :( instead, I just get a file: link. I had a quick look, but can't figure out how to enable this. Should be relatively easy I would think, since emacs already can display pdfs and right-clicking on the file: link will open a new frame with the pdf. Is there any reason not to display them inline? The closest I found is: http://stackoverflow.com/questions/15407485/inline-pdf-images-in-org-mode If it is not that easy, is there a way to run a pre-export and post-export hook that changes my *.png files to *pdf before the export and then changes them back to *.png after the export? Here is a test file ---------------- #+STARTUP: inlineimages * test #+NAME: checkfilename #+HEADER: :var fileout="test--checkfilename.pdf" #+BEGIN_SRC python :session :results file import numpy as np import matplotlib.pyplot as plt fig, ax = plt.subplots(1, 1) X = np.linspace(1, 10) Y = np.sin(X) ax.plot(X, Y) fig.savefig(fileout) plt.close(fig) fileout #+END_SRC --------------------- to create a png, just replace the .pdf in the HEADER with .png this uses ipython and cpaste ------- ; use ipython in org mode (setq org-babel-python-command "ipython3 --no-banner --classic --no-confirm-exit") ; use %cpaste to paste code into ipython in org mode (defadvice org-babel-python-evaluate-session (before org-python-use-cpaste (session body &optional result-type result-params) activate) "Add a %cpaste and '--' to the body, so that ipython does the right thing." (setq body (concat "%cpaste -q\n" body "\n--"))) ------- Arun