我想更新用于创建mpld3生成的python matplotlib列表图的输入数据。实际上,我有同样的问题:
Get point information after dragging
我熟悉python和matplotlib。 sjp14051回答了上述帖子,展示了如何生成在生成的html图中移动的点坐标的更改。能否解释一下如何将javascript生成的坐标变化移回python环境,更新用于生成绘图的原始输入点[0]列表?
(如果合适,请将其与引用的SO问题合并。)
答案 0 :(得分:2)
Here is a medium-sized example of retrieving data from an mpld3
plot that I use to place call-outs on graphs。获取数据的简单方法是将其放入浏览器prompt
:
function save_callouts(callouts) {
function callout_py(d) {
return "plt.text(" + d.x + ", " + d.y + ", '" + d.s + "', va='center')\n"
+ "plt.plot([" + d.x1 + ", " + d.x2 + "], [" + d.y1 + ", " + d.y2 + "], 'k-')\n"
}
prompt("Copy code to generate callouts:", callouts.map(callout_py).join("\n"));
}
可能有更简单的方法来实现这一目标,但prompt
然后在用户的部分进行复制和粘贴可以完成工作。