diff --git a/telemetry/code/monitor/graph_plotter_rewrite.py b/telemetry/code/monitor/graph_plotter_rewrite.py index a556ee8..81a6dc3 100755 --- a/telemetry/code/monitor/graph_plotter_rewrite.py +++ b/telemetry/code/monitor/graph_plotter_rewrite.py @@ -49,8 +49,8 @@ class Plot(pyglet.window.Window): """Draw all the components of the graph""" self.drawBackground() self.drawHeading() - self.drawXAxis() - self.drawYAxis() + self.drawAxis(0) + self.drawAxis(1) def drawBackground(self): """Draw the graph background, currently a plain colour""" @@ -63,38 +63,37 @@ class Plot(pyglet.window.Window): anchor_x='center', anchor_y='top') heading.draw() - def drawXAxis(self): - top = self.bounds[1][1] - bot = self.bounds[1][0] - start = self.bounds[0][0] - stop = self.bounds[0][1] - increment = float(stop-start)/self.lines[0] - for x in numpy.arange(start, stop+1, increment): + def drawAxis(self, axis): # axis=0 is x, 1 is y + limita = self.bounds[axis][1] + limitb = self.bounds[axis][0] + start = self.bounds[1-axis][0] + stop = self.bounds[1-axis][1] + increment = float(stop-start)/self.lines[axis] + for pos in numpy.arange(start, stop+1, increment): # Using fp arithmetic to avoid intermittent fencepost errors - x = int(x) - pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (x, top, x, bot)), + pos = int(pos) + if axis==0: + pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (limita, pos, limitb, pos)), ('c3B', (0, 0, 0, 0, 0, 0))) - tag = pyglet.text.Label("123", color=BLACK, - font_name=self.font, font_size=self.height*self.margins[0]*0.3, - x=x, y=self.height*self.margins[0], - anchor_x='center', anchor_y='top') + tag = pyglet.text.Label("123", color=BLACK, + font_name=self.font, font_size=self.height*self.margins[1-axis]*0.3, + x=pos, y=self.height*self.margins[axis], + anchor_x='left', anchor_y='top') + if axis==1: + pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (pos, limita, pos, limitb)), + ('c3B', (0, 0, 0, 0, 0, 0))) + tag = pyglet.text.Label("123", color=BLACK, + font_name=self.font, font_size=self.width*self.margins[1-axis]*0.3, + x=self.width*self.margins[axis], y=pos, + anchor_x='right', anchor_y='center') + tag.draw() axistitle = pyglet.text.Label(self.series.xname, color=BLACK, font_name=self.font, font_size=self.height*self.margins[0]*0.3, x=self.width/2, y=0, anchor_x='center', anchor_y='bottom') axistitle.draw() - def drawYAxis(self): - lef = self.bounds[0][0] - rig = self.bounds[0][1] - start = self.bounds[1][0] - stop = self.bounds[1][1] - increment = float(stop-start)/self.lines[1] - for y in numpy.arange(start, stop+1, increment): - # Using fp arithmetic to avoid intermittent fencepost errors - y = int(y) - pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (lef, y, rig, y)), - ('c3B', (0, 0, 0, 0, 0, 0))) + -- libgit2 0.21.2