On 2015/06/23 10:39 AM, Eric Firing wrote: > I would like to be able to publish plots that are updated as data are > received by the server. I don't actually want any of the toolbar > interactivity--I just want the updated plot to appear in the browser > automatically. I suspect this can all be done quite easily using the > webagg backend, but I have not yet figured it out by looking at the > embedding_in_webagg.py example and the backend_webagg* code. I expect > that stripping out the toolbar is straightforward, but what I don't > understand is how to achieve the dynamic updates, preferably without > using the animation framework, which I think would add unnecessary > complexity. > > Are there any other examples floating around that would help? > > Thanks. > > Eric
To answer my own question, in case anyone else is interested, here is a block of code that can be substituted for the corresponding elements of the embedding_in_webagg.py example. The whole block goes at the bottom. ------------------------------------------------- def create_figure(): fig = Figure() ax = fig.add_subplot(1,1,1) ax.set_xlim(0, 1) ax.set_ylim(0, 1) line, = ax.plot([], [], 'r-') return fig, line if __name__ == "__main__": figure, line = create_figure() application = MyApplication(figure) http_server = tornado.httpserver.HTTPServer(application) http_server.listen(8080) print("http://127.0.0.1:8080/") print("Press Ctrl+C to quit") def update2(): line.set_data(np.random.rand(2, 25)) figure.canvas.draw_idle() io_loop = tornado.ioloop.IOLoop.instance() cb = tornado.ioloop.PeriodicCallback(update2, 1000) cb.start() io_loop.start() ---------------------------------------------------------- Instead of the using the PeriodicCallback I will probably be using ZMQStream.on_recv() to register a callback on a socket, but that doesn't change the basic structure. Eric ------------------------------------------------------------------------------ Monitor 25 network devices or servers for free with OpManager! OpManager is web-based network management software that monitors network devices and physical & virtual servers, alerts via email & sms for fault. Monitor 25 devices for free with no restriction. Download now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o _______________________________________________ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users