朱莉娅制图互动 [英] Julia charting interaction

查看:94
本文介绍了朱莉娅制图互动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个Julia图表包,该包允许用户单击图表中的某个点(例如,小节中的条形图).然后发送一个事件,我可以交互接收并解释单击了哪个条,然后生成我想要的任何其他图表.

I am looking for a Julia charting package that allows the user to click on a point in the chart (a bar in a barplot for example). Then send an event that I can interactively receive and interpret which bar was clicked on to then produce another chart of whatever I would like.

我发现了交互式的Julia程序包,但它们却相反.将小部件放在屏幕上,用户可以更改滑块,例如更改图表.但不要点击图表.

I have found interactive Julia packages which go the other way. Put a widget on the screen and the user can change a slider for example to change chart. But not clicking on chart.

推荐答案

PyPlot包装matplotlib,并且matplotlib支持事件处理.在此处阅读 matplotlib事件处理文档.这是将第一个示例中的所有功能翻译为Julia的功能.您可能需要参考[PyCall文档] 2 来了解pyobject[:symbol]语法.

PyPlot wraps matplotlib, and matplotlib supports event handling. Read the matplotlib event handling docs here. This is has all the functionality from their first example translated into Julia. You may want to refer to the [PyCall docs]2 to read about the pyobject[:symbol] syntax.

julia> using PyPlot
julia> fig=figure()
PyPlot.Figure(PyObject <matplotlib.figure.Figure object at 0x1159d3f90>)
julia> function onclick(event)
       println(event)
       println((event[:xdata],event[:ydata],event[:x],event[:y]))
       end
onclick (generic function with 1 method)
julia> fig[:canvas][:mpl_connect]("button_press_event",onclick)
6
julia> PyObject <matplotlib.backend_bases.MouseEvent object at 0x131d5d110>
(nothing, nothing, 385, 388.0)
PyObject <matplotlib.backend_bases.MouseEvent object at 0x131d5d410>
(nothing, nothing, 365, 256.0)
PyObject <matplotlib.backend_bases.MouseEvent object at 0x131d5d3d0>
(nothing, nothing, 429, 337.0)

最后六行是我随机点击出现的空白图形.我建议查看对象拾取"部分.

The last six lines are from me clicking randomly on the blank figure that appeared. I suggest looking at the "Object Picking" section.

这篇关于朱莉娅制图互动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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