本文整理汇总了Python中Graph.Graph.plotData方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.plotData方法的具体用法?Python Graph.plotData怎么用?Python Graph.plotData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph.Graph
的用法示例。
在下文中一共展示了Graph.plotData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import plotData [as 别名]
#.........这里部分代码省略.........
elif i == 3:
leg.setPosition((fX, fY, -fZ))
i+=1
def dropBody(self):
'''drops the main body of the robot'''
self.body.setPosition( (0, const.bodyHeight/2+const.Height, 0) )
def refreshRobot(self, lBody, lFemur=None, lTibia=None):
'''Refreshes the position of the labels and camera'''
self.refreshBody(lBody)
#self.refreshLegs(lTibia, lFemur)
self.refreshJoints()
def refreshBody(self, lBody):
'''Refreshes the label position and the camera of the center body'''
self.body.UpdateDisplay()
x,y,z = self.body.getPosition()
self.center = (x,y,z)
self.refreshGraph((x,y))
if self.showLabels:
lBody.pos = (x,y,z)
lBody.text = '%.2f, %.2f, %.2f, %.1f kg' % (x,y,z,self.totalMass)
def refreshGraph(self, val):
if len(self.graphVal) > const.maxSize:
self.graphVal = []
else:
self.graphVal.append(val)
self.graph.plotData(self.graphVal)
def refreshLegs(self, lTibia, lFemur):
'''Refreshes the position of the labels'''
for i in range(len(self.femur)):
x,y,z = self.femur[i].getPosition()
lFemur.pos = (x,y,z)
for i in range(len(self.tibia)):
x,y,z = self.tibia[i].getPosition()
lTibia.pos = (x,y,z)
def scalp (self, vec, scal):
'''geometric utility functions - from ODE example'''
vec[0] *= scal
vec[1] *= scal
vec[2] *= scal
def length (self, vec):
'''geometric utility functions - from ODE example'''
return sqrt (vec[0]**2 + vec[1]**2 + vec[2]**2)
def DegreeToRadian(self, deg):
'''geometric utility functions - from ODE example '''
return float(deg)/180.0 * pi
def RadianToDegree(self, rad):
'''geometric utility functions - from ODE example '''
示例2: DataPanel
# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import plotData [as 别名]
class DataPanel(object):
def __init__(self, appScreen, petriDish, left, top, width, height):
self.dataPanelSurface = appScreen.subsurface(pygame.Rect((left, top),
(width, height)))
self.left = left
self.top = top
self.width = width
self.height = height
self.petriDish = petriDish
self.herbPlot = Graph(left, 100, width, height-100)
self.herbPlot.setColor((255,160,0))
self.predPlot = Graph(left, 100, width, height-100)
self.predPlot.setColor((255,40,0))
self.omniPlot = Graph(left, 100, width, height-100)
self.omniPlot.setColor((0,0,255))
self.grassPlot = Graph(left, 100, width, height-100)
self.grassPlot.setColor((0,255,0))
self.time = 0
def updatePlots(self, timePassed):
self.time += timePassed
# updates all plots
self.herbPlot.updateData(self.petriDish.getHerbivoreCount(),
timePassed)
self.herbPlot.plotData(self.dataPanelSurface)
self.predPlot.updateData(self.petriDish.getPredatorCount(),
timePassed)
self.predPlot.plotData(self.dataPanelSurface)
self.omniPlot.updateData(self.petriDish.getOmnivoreCount(),
timePassed)
self.omniPlot.plotData(self.dataPanelSurface)
self.grassPlot.updateData(self.petriDish.getGrassCount() * 200,
timePassed)
self.grassPlot.plotData(self.dataPanelSurface)
def blitAllData(self):
# draws all the data variables to the data panel
DataVariable('Herbivores', self.petriDish.getHerbivoreCount(),
self.dataPanelSurface, 20, 10, 100, 50).draw()
DataVariable('Predators', self.petriDish.getPredatorCount(),
self.dataPanelSurface, 20, 35, 100, 50).draw()
DataVariable('Omnivores', self.petriDish.getOmnivoreCount(),
self.dataPanelSurface, 20, 60, 100, 50).draw()
DataVariable('Grass', self.petriDish.getGrassCount(),
self.dataPanelSurface, 20, 85, 100, 50).draw()
DataVariable('hAvgSpeed', self.petriDish.getAvgHSpeed(),
self.dataPanelSurface, 20, 110, 100, 50).draw()
DataVariable('hAvgFleeSpeed', self.petriDish.getAvgHerbFleeSpeed(),
self.dataPanelSurface, 20, 135, 100, 50).draw()
DataVariable('hAvgVision', self.petriDish.getAvgHVision(),
self.dataPanelSurface, 20, 160, 100, 50).draw()
DataVariable('pAvgSpeed', self.petriDish.getAvgPSpeed(),
self.dataPanelSurface, 20, 185, 100, 50).draw()
DataVariable('pAvgChaseSpeed', self.petriDish.getAvgPredChaseSpeed(),
self.dataPanelSurface, 20, 210, 100, 50).draw()
DataVariable('pAvgVision', self.petriDish.getAvgPredVision(),
self.dataPanelSurface, 20, 235, 100, 50).draw()
DataVariable('oAvgSpeed', self.petriDish.getAvgOSpeed(),
self.dataPanelSurface, 20, 260, 100, 50).draw()
DataVariable('oAvgFleeSpeed', self.petriDish.getAvgOmniFleeSpeed(),
self.dataPanelSurface, 20, 285, 100, 50).draw()
DataVariable('oAvgVision', self.petriDish.getAvgOmniVision(),
self.dataPanelSurface, 20, 310, 100, 50).draw()