From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dominique Dumont Subject: Re: Refresher on including R/ggplot2 output via latex/pdf? Date: Mon, 28 Oct 2019 09:21:08 +0100 Message-ID: <3138050.Zb6PjB5n7X@ylum> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:52298) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP0H4-000107-Ta for emacs-orgmode@gnu.org; Mon, 28 Oct 2019 04:21:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iP0H2-00008z-Qy for emacs-orgmode@gnu.org; Mon, 28 Oct 2019 04:21:14 -0400 Received: from smtp1-g21.free.fr ([212.27.42.1]:20209) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iP0H2-00008H-L0 for emacs-orgmode@gnu.org; Mon, 28 Oct 2019 04:21:12 -0400 Received: from ylum.localnet (unknown [192.56.171.14]) (Authenticated sender: domi.dumont) by smtp1-g21.free.fr (Postfix) with ESMTPSA id 4A125B0053F for ; Mon, 28 Oct 2019 09:21:09 +0100 (CET) In-Reply-To: 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" To: emacs-orgmode@gnu.org On Monday, 28 October 2019 05:16:00 CET John Hendy wrote: > I just went to use what I think is how I used to include ggplot2 > results in PDF experts, but it's not working. [...] > My test file: > ----- > * test > > #+begin_src R :results output graphics :exports results :file foo.png > library(ggplot2) > > df <- data.frame(x=c(1, 2), y=c(2, 4)) > p <- ggplot(df, aes(x = x, y = y)) + geom_point() > print(p) > #+end_src I had a similar issue to get plots in a revealjs export. Long story short, I solved the issue by adding these instructions at the end of the R script: grid::grid.newpage() grid::grid.draw(p) Hope this helps