在 wxPython 中嵌入交互式 matplotlib 图形 [英] Embedding Interactive matplotlib figures in wxPython
本文介绍了在 wxPython 中嵌入交互式 matplotlib 图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到了下面的例子:
我得到了这个例子,但是,有没有一种方法可以使图表/绘图具有交互性,例如由以下人员生成的:
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
后者具有缩放、平移功能,这是我想嵌入到我的 GUI 中的功能.
The latter has a zoom, pan functionality which is what I would like to embed in my GUI.
推荐答案
我正在执行此操作...
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)
无论出于何种原因,我都无法将工具栏放在不同的大小器/面板上.否则,它将起作用.如果有人可以在不同的 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.
这篇关于在 wxPython 中嵌入交互式 matplotlib 图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文