5

I use ggplot2 to plot my graphs. I want to use the graphs to create a keynote presentation.

During my presentation, I want to introduce different elements of the plot sequentially. First, the points corresponding to the condition A, then the points corresponding to condition B and then some curves for example.

I thought that maybe I could create the whole plot and export it in a way that I could manipulate single elements in keynote (like deleting the points of one condition). Thanks to people from stackoverflow, I was able to do that: R, export a file to keynote

But I found that it is very difficult to select individual elements in keynote. So, I wonder which is there is some more efficient way.

Community
  • 1
  • 1
danilinares
  • 1,172
  • 1
  • 9
  • 28
  • 3
    I suppose making a separate image corresponding to each additional plot element and then just displaying them on a series of slides isn't 'more efficient', but it's an option at least. – joran Oct 10 '11 at 03:18

1 Answers1

11

If you're willing to use some different tools, this is very doable with Sweave and the LaTeX document class beamer for the slides:

\documentclass{beamer}
\title{Sequential Graphs}
\begin{document}

\frame{\titlepage}

\frame{
Here's a graph:
<<echo = FALSE,fig = TRUE>>=
library(ggplot2)
d1 <- data.frame(x = 1:20, y = runif(20),grp = rep(letters[1:2],each = 10))
p <- ggplot(data = d1, aes(x = x, y = y)) + geom_point()
print(p)
@
}

\frame{
Here's the next graph:
<<echo = FALSE,fig = TRUE>>=
p <- p +geom_line(aes(group = 1))
print(p)
@
}

\frame{
Here's the last graph:
<<echo = FALSE,fig = TRUE>>=
p <- p +geom_point(aes(colour = grp))
print(p)
@
}
\end{document}

I've used ggplot here since it has a convenient syntax for adding elements to a graph, but this should work with any other graphics method in R, I'd think.

joran
  • 169,992
  • 32
  • 429
  • 468
  • 5
    +1 I agree with this general approach, i.e. create separate plots and save these to disk. Using beamer isn't essential. This code will generate a pdf for each plot. These pdf files can then be individually imported into a presentation to 'build' the plot. – Andrie Oct 10 '11 at 07:08