title: plotly: removing plot and creating a new one in the same div
body: <p>I have a plotly plot and when the data changes I want to remove the plot and generate a new one. To do that I do this:</p>
  
  <pre><code>$('#heatmap2').empty()
  </code></pre>
  
  <p>and then I regenerate my plot. But when I do that it crashes with this:</p>
  
  <pre><code>TypeError: Cannot read property 'textContent' of null
      at Array.Mo.text (plotly-latest.min.js:12)
      at Array.c.convertToTspans (plotly-latest.min.js:31)
      at Array.Mo.call (plotly-latest.min.js:12)
      at l (plotly-latest.min.js:29)
      at Object.i.syncOrAsync (plotly-latest.min.js:30)
      at Array.r (plotly-latest.min.js:29)
      at Array.Mo.call (plotly-latest.min.js:12)
      at Object.s.draw (plotly-latest.min.js:29)
      at r (plotly-latest.min.js:28)
      at Object.w.colorbar (plotly-latest.min.js:38)
  </code></pre>
  
  <p>Here's a codepen that shows that after calling empty() on the div you can't create another plot in it:</p>
  
  <p><a href="http://codepen.io/anon/pen/ZbZpBE?editors=101" rel="nofollow">http://codepen.io/anon/pen/ZbZpBE?editors=101</a></p>
  
  <p>this doesn't seem to throw the error I get, but still the plot is not created.</p>
  
  <p>How can I clear out an existing plot and then create a new plot in the
  same div?</p>