神剑山庄资源网 Design By www.hcban.com
本文实例为大家分享了wxPython绘图模块wxPyPlot实现数据可视化的具体代码,供大家参考,具体内容如下
#-*- coding: utf-8 -*- ################################################################################ ## 使用wxPython的绘图模块wxPyPlot,需要数据可视化的时候,无需再借用其他的库或模块了 ################################################################################ import numpy import wx import wx.lib.plot as wxPyPlot #导入绘图模块,并命名为wxPyPlot #--------------------------------------------------------------------------- # 需要把数据封装进入MyDataObject中 def MyDataObject(): # 50 个点的sin函数,用蓝色圆点表示 data1 = 2.*numpy.pi*numpy.arange(100)/100. data1.shape = (50, 2) data1[:,1] = numpy.sin(data1[:,0]) markers = wxPyPlot.PolyMarker(data1, legend='Green Markers', colour='blue', marker='circle',size=1) # 50个点的cos函数,用红色表示 data2 = 2.*numpy.pi*numpy.arange(100)/100. data2.shape = (50,2) data2[:,1] = numpy.cos(data2[:,0]) lines = wxPyPlot.PolySpline(data2, legend= 'Red Line', colour='red') GraphTitle="Plot Data(Sin and Cos)" return wxPyPlot.PlotGraphics([markers, lines],GraphTitle, "X Axis", "Y Axis") #----------------------------------------------------------------------------- class TestFrame1(wx.Frame): def __init__(self, parent=None, id=wx.ID_ANY, title="Using wxPyPlot"): wx.Frame.__init__(self, parent, id, title,size=(600, 400)) # 创建菜单栏 self.mainmenu = wx.MenuBar() menu = wx.Menu() menu.Append(100, 'Draw1', 'Draw plots1') self.Bind(wx.EVT_MENU,self.OnPlotDraw1, id=100) self.mainmenu.Append(menu, '&Plot') self.SetMenuBar(self.mainmenu) # 创建状态栏,显示信息 self.CreateStatusBar(2) self.pc = wxPyPlot.PlotCanvas(self) #此处导入绘图面板 def OnPlotDraw1(self, event): #绘图函数 self.pc.Draw(MyDataObject()) ########################################################################### ## 测试wxPyPlot的代码 ########################################################################### if __name__=='__main__': app = wx.App() tf=TestFrame1(None) tf.Show() app.MainLoop()
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无wxPython绘图模块wxPyPlot实现数据可视化的评论...
更新日志
2024年09月30日
2024年09月30日
- 孙悦.1996-伙伴【正大国际】【WAV+CUE】
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】