title: Lattice plots in for loop - empty images created
body: <p>I want to produce several lattice plots in a for loop, but it does create empty images!!!</p>
  
  <pre><code>for (f in unique(df$month)) {
      plot.new()
      bwplot(x ~ country|type, data = df[df$month == f,], panel=function(...) {
          panel.abline(h=0, col="green")
          panel.bwplot(...)
      })
      savePlot(paste0("file_", f), "png")
  }
  </code></pre>
  
  <p>When I run the inner of the for loop "by hand", it works, but in loop it stops working. Why?</p>
  
  <p>Here is the code to generate the data:</p>
  
  <pre><code>set.seed(123)
  n &lt;- 300
  country &lt;- sample(c("Europe", "Africa", "Asia", "Australia"), n, replace = TRUE)
  type &lt;- sample(c("city", "river", "village"), n, replace = TRUE)
  month &lt;- sample(c("may", "june", "july"), n, replace = TRUE)
  x &lt;- rnorm(n)
  df &lt;- data.frame(x, country, type, month)
  </code></pre>