日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python wxpython backend wxagg_[宜配屋]听图阁

發布時間:2025/4/16 python 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python wxpython backend wxagg_[宜配屋]听图阁 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用Matplotlib在wxPython的Panel上繪制曲線圖,需要導入:

import numpy

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

from matplotlib.figure import Figure

下面直接貼出源代碼:

#coding=utf-8

"""

程序的主入口

"""

import wx

import numpy

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

from matplotlib.figure import Figure

class FirseFrame(wx.Frame):

def __init__(self, parent=None, id=-1, title='', pos=wx.DefaultSize, size=wx.DefaultSize, style= wx.DEFAULT_FRAME_STYLE):

wx.Frame.__init__(self, parent, id, title, pos, size, style)

self.InitUI()

pass

def InitUI(self):

self.SetBackgroundColour('white')

self.scorePanel = wx.Panel(self)

scores = [89, 98, 70, 80, 60, 78, 85, 90]

sum = 0

for s in scores:

sum += s

average = sum / len(scores)

t_score = numpy.arange(1, len(scores) + 1, 1)

s_score = numpy.array(scores)

self.figure_score = Figure()

self.figure_score.set_figheight(3.6)

self.figure_score.set_figwidth(7.8)

self.axes_score = self.figure_score.add_subplot(111)

self.axes_score.plot(t_score, s_score, 'ro', t_score, s_score, 'k')

self.axes_score.axhline(y=average, color='r')

self.axes_score.set_title(u'My Scores')

self.axes_score.grid(True)

self.axes_score.set_xlabel('T')

self.axes_score.set_ylabel('score')

FigureCanvas(self.scorePanel, -1, self.figure_score)

pass

class MainApp(wx.App):

def OnInit(self):

style = wx.DEFAULT_FRAME_STYLE^wx.MAXIMIZE_BOX

self.frame = FirseFrame(id=-1, title=u'第一個窗口', pos=(10, 10), size=(340, 550), style=style)

self.frame.Show()

return True

def main():

app = MainApp()

app.MainLoop()

if __name__ == "__main__":

main()

效果:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持【聽圖閣-專注于Python設計】。

總結

以上是生活随笔為你收集整理的python wxpython backend wxagg_[宜配屋]听图阁的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。