本文整理汇总了Python中matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg.queue_resize方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTKAgg.queue_resize方法的具体用法?Python FigureCanvasGTKAgg.queue_resize怎么用?Python FigureCanvasGTKAgg.queue_resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg
的用法示例。
在下文中一共展示了FigureCanvasGTKAgg.queue_resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: realTimeVisualisation
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import queue_resize [as 别名]
class realTimeVisualisation(gtk.Window):
def __init__(self,networkVariables):
'''
'''
super(realTimeVisualisation,self).__init__()
self.set_size_request(640,690)
self.set_position(gtk.WIN_POS_CENTER)
self.connect("destroy", gtk.main_quit)
self.fig = Figure(figsize=(5,4), dpi=100)
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
self.canvas.set_size_request(640,690)
vbox = gtk.VBox(False,1)
alignIm = gtk.Alignment(0, 1 , 1, 0)
alignIm.add(self.canvas)
vbox.pack_start(alignIm)
self.add(vbox)
self.initNetworkVariables(networkVariables)
self.createGraph()
updateTime = 1 #len(self.quantitiesToPlot) ## if this time is to fast, it will show nothing
gobject.timeout_add(updateTime,self.updateGraph)
self.show_all()
def initNetworkVariables(self,networkVariables):
'''
'''
self.dt = 0.01
self.filename = '../.realtime.viz'
self.quantitiesToPlot = ['Pressure','Flow']
self.initialValues = [0,0,0,0,0]
try:
self.dt = networkVariables['dt']
self.filename = networkVariables['filename']
self.quantitiesToPlot = networkVariables['quantitiesToPlot']
self.initialValues = networkVariables['initialValues']
except: pass
def updateGraph(self):
'''
'''
try:
with open(''.join([cur,'/',self.filename]),'r') as dataFile:
for dataLine in dataFile:
dataString = dataLine
break
os.remove(''.join([cur,'/',self.filename]))
except: pass
dataDict = {}
try:
dataDict = eval(dataString)
except:
try:
if dataString == 'STOP':
return False
except: pass
pass
try:
for quantity in self.quantitiesToPlot:
newValue = dataDict[quantity]
## update y values
yvals = self.lines[quantity].get_ydata()
yvalsn = np.append(yvals,newValue)
self.lines[quantity].set_ydata(yvalsn)
## update x values
timeOld = self.lines[quantity].get_xdata()
time = np.append(timeOld,[timeOld[-1]+self.dt])
self.lines[quantity].set_xdata(time)
## adjust limits
self.adjustAxis(self.axis[quantity],time,yvalsn)
# update view()
self.canvas.figure = self.fig
self.fig.set_canvas(self.canvas)
self.canvas.queue_resize()
except: pass
return True
def adjustAxis(self,axis,xVals,yVals):
'''
'''
mmF = 0.1
#get values for y
yMaxVals = np.max(yVals)
#.........这里部分代码省略.........