title: Ggplot subset data functions and dplyr
body: <p>When doing data analysis, we often use dplyr to modify the dataframe further in specific <code>geom</code>s. This allows us to change the default dataframe of a ggplot later, and have everything still work.</p>
  
  <pre><code>template &lt;- ggplot(db, aes(x=time, y=value)) + 
       geom_line(data=function(db){db %&gt;% filter(event=="Bla")}) + 
       geom_ribbon(aes(ymin=low, ymax=up))
  ggsave( template, "global.png" )
  for(i in unique(db$simulation)) 
       ggsave( template %+% subset(db, simulation==i), paste0(i, ".png")
  </code></pre>
  
  <p>Is there a nicer/shorter way to specify the <code>filter</code> command, e.g. using some magical <code>.</code>?</p>
  
  <p><em>EDIT</em>
  To clarify some of the comments: By using <code>geom_line(data = db %&gt;% filter(event=="Bla"))</code>, the layer would not be updated when I change the default dataframe later using <code>%+%</code>. I am really aiming to use the <code>data</code> argument of geom_* as a function.</p>