Python script Graph to webpage

Hi all,

I am going to attempt to move my current python script (most seen here:http://stackoverflow.com/questions/41697966/python-pie-chart-not-presented-in-order
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?

Thanks
TJ

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170125/7de57e73/attachment.html>

TJ,

There's an example of embedding matplotlib using the webagg backend in the
official documentation here:
http://matplotlib.org/examples/user_interfaces/embedding_webagg.html

I don't have much experience with it, but I hope it helps.
-p

···

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:
http://stackoverflow.com/questions/41697966/python-pie-
chart-not-presented-in-order
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?

Thanks
TJ

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170125/aa99051e/attachment.html&gt;

You can also do this via one of the web frame works (ex flask, django,...)
and just serve the png. The webbackend will provide an interactive figure.

Something like: https://gist.github.com/wilsaj/862153 (py3 version
attached).

Documenting how to use mpl within the web-frameworks is something that
should definitely be in the main docs.
Tom

···

On Wed, Jan 25, 2017, 11:39 Paul Hobson <pmhobson at gmail.com> wrote:

TJ,

There's an example of embedding matplotlib using the webagg backend in the
official documentation here:
http://matplotlib.org/examples/user_interfaces/embedding_webagg.html

I don't have much experience with it, but I hope it helps.
-p

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:
http://stackoverflow.com/questions/41697966/python-pie-chart-not-presented-in-order
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?

Thanks
TJ

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170125/ab80a932/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fa.py
Type: text/x-python
Size: 942 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170125/ab80a932/attachment.py>

Here's my brief outline of a really basic approach.
You will create a simple program, let's call it *myplot.py*.

import sys
import matplotlib
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*
*>/myplot.py"*

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:
*SRC="<**website**>/myplot.py?x=<**random number**>"*
This would be especially helpful in testing, because the browser would
never think it had already cached the image (unless the random number
repeats).

···

----
Glenn Nelson in Santa Cruz
social: http://google.com/+GlennNelson
see my Kite Aerial Photos at kap image catalog

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:
http://stackoverflow.com/questions/41697966/python-pie-
chart-not-presented-in-order
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?

Thanks
TJ

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170125/022c329b/attachment-0001.html&gt;