Julia charting interaction

谁说我不能喝 提交于 2019-12-12 04:43:18

问题


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.

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.


回答1:


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.



来源:https://stackoverflow.com/questions/47189612/julia-charting-interaction

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!