[Matplotlib-users] Python script Graph to webpage
kitecamguy at gmail.com
Wed Jan 25 17:49:11 EST 2017
Here's my brief outline of a really basic approach.
You will create a simple program, let's call it *myplot.py*.
matplotlib.use('Agg') # backend that is used for web graphics
import matplotlib.pyplot as plt
# create your plot here, using 'plt'
print 'Content-Type: image/png\n'
plt.savefig( sys.stdout, format='png' )
And then in your web page, you have HTML IMG tag with *SRC="<**website*
That's all there is to it. When I first got into this, I don't think the
suggested *webagg *backend was available to me.
Web browsers will normally cache the image, so you probably want to set
expiration headers, either Cache-Control or Expires.
Another way to force browser to make a new request is to add a parameter
with random value:
This would be especially helpful in testing, because the browser would
never think it had already cached the image (unless the random number
Glenn Nelson in Santa Cruz
see my Kite Aerial Photos at http://www.glenn-nelson.us/kap
On Tue, Jan 24, 2017 at 11:00 PM, Trevor H <tripytrev at hotmail.com> wrote:
> Hi all,
> I am going to attempt to move my current python script (most seen here:
> To a web application so every time the page is refreshed the python script
> will run and display the latest graph & pie chart.
> Would anyone have any examples I could follow to get some idea of how I
> could create something like this?
> Matplotlib-users mailing list
> Matplotlib-users at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users