Embedding Interactive matplotlib figures in wxPython

匿名 (未验证) 提交于 2019-12-03 08:52:47

问题:

I saw the following example:

Embedding a matplotlib figure inside a WxPython panel

I got the example to work, however, is there a way to make the chart/plot interactive such as the one that is produced by:

http://matplotlib.sourceforge.net/examples/pylab_examples/finance_demo.html

The latter has a zoom, pan functionality which is what I would like to embed in my GUI.

回答1:

I got this working...

    chart_toolbar = NavigationToolbar2Wx(chart_canvas)     tw, th = chart_toolbar.GetSizeTuple()     fw, fh = chart_canvas.GetSizeTuple()     chart_toolbar.SetSize(wx.Size(fw, th))     chart_toolbar.Realize()      graphs_sizer = wx.BoxSizer(wx.VERTICAL)      graphs_sizer.Add(chart_canvas, 20, flag=wx.EXPAND, border=5)     graphs_sizer.Add(chart_toolbar, 1, flag=wx.ALIGN_CENTER, border=5)      graphs_panel.SetSizer(graphs_sizer)

For whatever reason I have not been able to put the toolbar on a different sizer/panel. Otherwise it works. If someone can get it on a different sizer, that would be greatly appreciated.



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