简体   繁体   English

如何使用mpld3创建实时图

[英]How to create a real-time plot with mpld3

Is there a way to add a new data point and remove an old one (push, shift principle) with mpld3 on the frontend side? 有没有一种方法可以在前端侧添加带有mpld3的新数据点并删除旧数据点(按推,移位原理)? I would like to make a real-time plot using mpld3. 我想使用mpld3进行实时绘图。 Initializing the plot once and updating it with websockets for example... The only way I could think of so far is updating the data directly in javascript after initialization using the underlying d3 library like in this example . 初始化情节一次使用WebSockets比如......我能想到的,至今使用的底层D3库就像在初始化之后更新直接在JavaScript中的数据的唯一方法更新它这个例子。

It's easiest to do this using D3.JS on the client side. 在客户端使用D3.JS进行此操作最简单。

If you really hate writing JS code and are OK with having to refresh the page to update, you can do this by providing the image via a hook on your backend which rewrites and sends a fresh matplotlib figure every time a request is made. 如果您真的很讨厌编写JS代码,并且不必刷新页面即可更新,则可以通过在后端上的钩子提供图像来完成此操作,该钩子将在每次发出请求时重写并发送一个新的matplotlib图形。 This is a Bad Idea though, for a variety of reasons. 但是,由于多种原因,这是一个坏主意。

I'm not aware of any capacity in which mpld3 in and of itself is helpful here, sorry. 抱歉,我不知道mpld3本身在其中mpld3的任何功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM