从python中的动态mpld3图中检索数据 [英] Retrieve Data From Dynamic mpld3 plot in python

查看:52
本文介绍了从python中的动态mpld3图中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新用于创建 mpld3 生成的 python matplotlib 列表图的输入数据.实际上,我有与此处发布的问题相同的问题:

I would like to update input data used to create an mpld3 generated python matplotlib list plot. Effectively, I have the same question as posted here:

拖动后获取点信息

我熟悉python和matplotlib.sjp14051 已经回答了上面的帖子,展示了如何在生成的 html 图中移动的点坐标中生成变化.您能解释一下如何将从javascript生成的坐标更改移回到python环境中,以更新用于生成绘图的原始输入点[0]列表吗?

I'm familiar with python and matplotlib. sjp14051 had answered the above post, showing how to generate changes changes in point coordinates that are moved within the generated html plot. Could you please explain how the coordinate change generated from javascript can be moved back to the python environment to update the original input point[0] list used to generate the plot?

(如果合适,请将其与引用的SO问题合并.)

(If appropriate, please merge this with the referenced SO question.)

推荐答案

这里是中等大小从 mpld3 绘图中检索数据的示例,我用它在图上放置标注.获取数据的简单方法是将其放入浏览器 prompt:

Here is a medium-sized example of retrieving data from an mpld3 plot that I use to place call-outs on graphs. The simple approach to getting the data is to put it in a browser prompt:

<代码>函数save_callouts(callouts){函数callout_py(d){返回"plt.text("+ d.x +","+ d.y +",'"+ d.s +"',va ='center')\ n+"plt.plot([" + d.x1 +," + d.x2 +],[" + d.y1 +," + d.y2 +],'k-')\ n"}提示(复制代码以生成标注:",callouts.map(callout_py).join("\ n"));}

可能会有一些巧妙的方法来完成此任务,但是提示后面紧跟着用户的粘贴和粘贴就可以完成工作.

There might be slicker ways to accomplish this, but prompt followed by copy-and-paste on the user's part gets the job done.

这篇关于从python中的动态mpld3图中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆