简体   繁体   English

如何使用 mpld3 将 plot 动画化为 html 中的 matplotlib

[英]How to plot animated matplotlib in html with mpld3

I want to show a graphs that is monitoring a sensor data in my raspberry pi in a html page.我想在 html 页面中显示一个图表,该图表正在监视我的 raspberry pi 中的传感器数据。 I have been using matplotlib graphs and recently I have installed mpld3 library but I the code shows me this error:我一直在使用 matplotlib 图表,最近我安装了 mpld3 库,但我的代码显示了这个错误:

Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
[2786:2888:0217/042317.744817:ERROR:object_proxy.cc(621)] Failed to call method: org.freedesktop.Notifications.GetCapabilities: object_path= /org/freedesktop/Notifications: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
ATTENTION: default value of option force_s3tc_enable overridden by environment.
127.0.0.1 - - [17/Feb/2022 04:23:19] "GET / HTTP/1.1" 200 -
[2838:2838:0217/042319.282873:ERROR:sandbox_linux.cc(364)] InitializeSandbox() called with multiple threads in process gpu-process.
[1:8:0217/042319.671753:ERROR:command_buffer_proxy_impl.cc(124)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.
127.0.0.1 - - [17/Feb/2022 04:23:20] "GET /d3.js HTTP/1.1" 200 -
127.0.0.1 - - [17/Feb/2022 04:23:20] "GET /mpld3.js HTTP/1.1" 200 -
127.0.0.1 - - [17/Feb/2022 04:23:21] code 404, message Not Found
127.0.0.1 - - [17/Feb/2022 04:23:21] "GET /favicon.ico HTTP/1.1" 404 -

And the code that I'm running is this:我正在运行的代码是这样的:

from matplotlib.pyplot import figure
import mpld3

fig = figure()
ax = fig.gca()
ax.plot([1,2,3,4])

mpld3.show(fig)

What is my error?我的错误是什么? Or if you know how to show matplots graphs in html only with python and html!或者,如果您知道如何仅使用 python 和 html 在 html 中显示 matplots 图表!

thanks!谢谢!

Consider using mpld3.enable_notebook() .考虑使用mpld3.enable_notebook() The documentation says "This is useful if you want every figure to be automatically embedded in the notebook as an interactive JavaScript figure."文档说“如果您希望每个图形都作为交互式 JavaScript 图形自动嵌入到笔记本中,这将很有用。” You can find other resources here .您可以在此处找到其他资源。

1 - In regards to your Chromium error, see this . 1 - 关于您的 Chromium 错误,请参阅

2 - In regards to your Sandbox error, see this . 2 - 关于您的沙盒错误,请参阅

3 - In regards to your GPU error, see this . 3 - 关于您的 GPU 错误,请参阅

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

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