亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

wxPython繪圖模塊wxPyPlot實現(xiàn)數(shù)據(jù)可視化

 更新時間:2019年11月19日 15:01:35   作者:網(wǎng)海水手  
這篇文章主要為大家詳細(xì)介紹了wxPython繪圖模塊wxPyPlot實現(xiàn)數(shù)據(jù)可視化,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了wxPython繪圖模塊wxPyPlot實現(xiàn)數(shù)據(jù)可視化的具體代碼,供大家參考,具體內(nèi)容如下

#-*- coding: utf-8 -*- 
 
################################################################################
## 使用wxPython的繪圖模塊wxPyPlot,需要數(shù)據(jù)可視化的時候,無需再借用其他的庫或模塊了
################################################################################
import numpy
import wx
import wx.lib.plot as wxPyPlot #導(dǎo)入繪圖模塊,并命名為wxPyPlot
 
#---------------------------------------------------------------------------
# 需要把數(shù)據(jù)封裝進入MyDataObject中
def MyDataObject():
 # 50 個點的sin函數(shù),用藍(lán)色圓點表示
 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函數(shù),用紅色表示
 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))
  
  # 創(chuàng)建菜單欄
  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)
 
  # 創(chuàng)建狀態(tài)欄,顯示信息
  self.CreateStatusBar(2)
  
  self.pc = wxPyPlot.PlotCanvas(self) #此處導(dǎo)入繪圖面板
 
 def OnPlotDraw1(self, event): #繪圖函數(shù)
  self.pc.Draw(MyDataObject())
 
 
###########################################################################
## 測試wxPyPlot的代碼
###########################################################################
if __name__=='__main__':
  app = wx.App()
  tf=TestFrame1(None)
  tf.Show()
  app.MainLoop()

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論