title: Python: How to show matplotlib in flask
body: <p>I'm very new to Flask and Matplotlib.  I'd like to be able to show a simple chart I generated in some html, but I'm having a very hard time figuring out how.  Here is my Python code:</p>
  
  <pre><code>from flask import Flask, render_template
  import numpy as np
  import pandas
  import matplotlib.pyplot as plt
  
  app = Flask(__name__)
  variables = pandas.read_csv('C:\\path\\to\\variable.csv')
  price =variables['price']
  
  
  @app.route('/test')
  def chartTest():
      lnprice=np.log(price)
      plt.plot(lnprice)
      return render_template('untitled1.html', name = plt.show())
  
  if __name__ == '__main__':
     app.run(debug = True)
  </code></pre>
  
  <p>And here is my HTML:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
     &lt;body&gt;
  
        &lt;h1&gt;Price Chart&lt;/h1&gt;
  
        &lt;p&gt;{{ name }}&lt;/p&gt;
  
        &lt;img src={{ name }} alt="Chart" height="42" width="42"&gt;
  
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>