[IPython-User] dynamic notebook graph

Brian Granger ellisonbg@gmail....
Thu Apr 26 14:10:33 CDT 2012

On Mon, Apr 23, 2012 at 10:20 AM, Michaelian Ennis
<michaelian.ennis@gmail.com> wrote:
> I just realized I sent this to dev instead of user.  Moving it over.
> I have a method, say, obj.getstats()  that returns data structure
> that looks like:
>            {'22': {'port': '22',
>              'kind': 'tcp',
>              'read': {'rate': '0.000', 'avg': '0', 'max': '0'},
>              'write': {'rate': '0.000', 'avg': '0', 'max': '0'}},
>             '80': {'port': '80',
>              'kind': 'tcp',
>              'read': {'rate': '0.677', 'avg': '2', 'max': '15'},
>              'write': {'rate': '0.000', 'avg': '0', 'max': '0'}},
>             '443': {'port': '443',
>              'kind': 'tcp',
>              'read': {'rate': '0.677', 'avg': '1', 'max': '20'},
>              'write': {'rate': '0.000', 'avg': '0', 'max': '0'}}
>            }

> every time its called.  I'd like to graph this data in a simple bar
> graph but have that graph update every so many seconds.  I'd like to
> to this in notebook.  Is there support for such a thing?  If so what
> do I need to read to get it working?

It will be tough to do this without blocking the notebook.  We are in
the process of making changes to the design that will make things like
this easier, but we need don't have a solution that will be
non-blocking.  One option that would work is to expose your data
source as a WebSocket server using tornado.  Then you would write a
dynamic Javascript widget using IPython.core.display.Javascript that
gets data from the WebSocket server and plots it using some Javascript
plotting library.  That would be fully non-blocking.

The simple blocking way of doing this would be to simply call your
function in a loop and plot the result in that loop using matplotlib.
Calling IPython.core.display.clear_output in between will clear the
old plot and you will get the effect you are after.  But again, that
will completely block the execution of other code in the notebook.



> Ian
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

More information about the IPython-User mailing list