title: Efficiently plotting millions of data points in R
body: <p>I'm trying to plot some million data points in R. I'm currently using ggplot2 (but I'm open to suggestions of alternate packages). The problem is that the graph takes too long to render (often upwards of a minute). I'm looking for ways to do this faster -- in real time ideally. I would appreciate any help -- attaching code to the question for clarity. </p>
  
  <p>Creating a (random) data frame with ~500000 data points: </p>
  
  <pre><code>letters &lt;- c("A", "B", "C", "D", "E", "F", "G")
  myLetters &lt;- sample(x = letters, size = 100000, replace = T)
  direction &lt;- c("x", "y", "z")
  factor1 &lt;- sample(x = direction, size = 100000, replace = T)
  factor2 &lt;- runif(100000, 0, 20)
  factor3 &lt;- runif(100000, 0, 100)
  decile &lt;- sample(x = 1:10, size = 100000, replace = T)
  
  
  new.plot.df &lt;- data.frame(letters = myLetters, factor1 = factor1, factor2 = factor2, 
                        factor3 = factor3, decile = decile)
  </code></pre>
  
  <p>Now, plotting the data: </p>
  
  <pre><code>color.plot &lt;- ggplot(new.plot.df, aes(x = factor3, y = factor2, color = factor1)) +
  geom_point(aes(alpha = factor2)) +
  facet_grid(decile ~ letters)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/WGd1L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WGd1L.png" alt="enter image description here"></a></p>
  
  <p><strong>How do I make the rendering faster?</strong></p>