title: Plotting during a loop in RStudio
body: <p>I am implementing a solution to the Traveling Salesman Problem (TSP) in R (simulated Annealing) and I want to output the current best path periodically.  I have searched quite a bit for how to output plots during a <code>for</code> loop and have thus far failed.  </p>
  
  <p>I use RStudio, and want to see the graphs as they are generated.  If you have ever watched TSP solvers do their thing, you will understand how cool it is to watch.  Here is a sample of the graphics output I want to see <a href="http://www.staff.science.uu.nl/~beuke106/anneal/anneal.html" rel="noreferrer">http://www.staff.science.uu.nl/~beuke106/anneal/anneal.html</a></p>
  
  <p>I don't think that the memory usage will be a problem (during about 500,000 iterations, I am only expecting 50-100 plots).  Here is a sample function, where we would expect to see 10 different plots during the time the function runs:</p>
  
  <pre><code>Plotz &lt;- function(iter = 1000000, interval = 100000) {
    x &lt;- 1:10
    for(i in 1:iter){
      y &lt;- runif(10)
      if(i %% interval == 0) {
        plot(x, y)
      }
    }
    return(c(x, y))
  }
  Plotz()
  </code></pre>
  
  <p>When I run this, all I see is the final plot produced (in RStudio).  How can I see the plots as they're generated?</p>
  
  <p>Also: I am on Ubuntu (whatever the newest stable release is).  Don't know if that is relevant.</p>
  
  <p>Thank you everyone in advance.</p>
  
  <p>EDIT: Per Captain Murphy's suggestion, I tried running this in the Linux terminal, and the graphics appeared.  I still think the question of "How to do this in RStudio?" Is still relevant, however.  It's such a good program, so maybe someone has an idea of what could be done to get this to work?</p>
  
  <p>EDIT2: As Thilo stated, this is a known bug in Rstudio.  If anyone has any other ideas to solve this without the software itself being fixed, then there is still something to discuss.  Otherwise, consider this question solved.</p>