title: Django Rendering Matplotlib chart in HTML using mpld3
body: <p>I'm trying to get a <strong>mpld3 chart</strong> into my webapp using Django and MPLD3/Matplotlib. As described <a href="http://mpld3.github.io/modules/API.html#mpld3.fig_to_html" rel="nofollow noreferrer">here</a> it should be straightforward getting the HTML code of the figure written in python.</p>
  
  <p><em>Views.py</em></p>
  
  <pre><code>def figure(request):
  
      np.random.seed(9615)
  
      N = 100
      df = pd.DataFrame((.1 * (np.random.random((N, 5)) - .5)).cumsum(0),
                    columns=['a', 'b', 'c', 'd', 'e'], )
  
      # plot line + confidence interval
      fig, ax = plt.subplots()
      ax.grid(True, alpha=0.3)
  
      for key, val in df.iteritems():
          l, = ax.plot(val.index, val.values, label=key)
          ax.fill_between(val.index,
                          val.values * .5, val.values * 1.5,
                          color=l.get_color(), alpha=.4)
      ax.set_xlabel('x')
      ax.set_ylabel('y')
      ax.set_title('Interactive legend', size=20)
  
      html_fig = mpld3.fig_to_html(fig,template_type='general')
      plt.close(fig)
  
      return render(request, "dashboard.html", {'active_page' : 'dashboard.html', 'div_figure' : html_fig})
  </code></pre>
  
  <p><em>dashboard.html</em></p>
  
  <pre><code>&lt;div id="fig_container"&gt;
                  {{ div_figure }}
  &lt;/div&gt;
  </code></pre>
  
  <p>AFAIK, the python code gets translated into javascript and should be executed when views.py is rendering dashboard.html, right?</p>
  
  <p>As result, I get the HTML code displayed as text on my dashboard.hmtl.</p>
  
  <p><strong>QUESTION:</strong> How do I get the chart displayed? Do I need to parse the HTML string which is returned by the method html_to_fig?</p>