From 8ad3fe93059fd2897e3c43a2205fda8c9c654e5f Mon Sep 17 00:00:00 2001 From: Christopher Stone Date: Mon, 12 Feb 2018 23:11:56 +0000 Subject: [PATCH] Replaced placeholder axis tags with calculated ones - although better rounding (based on sig. fig., not dp) is needed --- telemetry/code/monitor/graph_plotter_rewrite.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/telemetry/code/monitor/graph_plotter_rewrite.py b/telemetry/code/monitor/graph_plotter_rewrite.py index d9b23b7..8b2612f 100755 --- a/telemetry/code/monitor/graph_plotter_rewrite.py +++ b/telemetry/code/monitor/graph_plotter_rewrite.py @@ -29,6 +29,8 @@ class Series: self.title = title self.xname = xname self.yname = yname + self.xlimits = (100, 0) + self.ylimits = (0, 255) self.data = [] self.points = points def addpoint(self, point): @@ -43,8 +45,8 @@ class Plot(pyglet.window.Window): pyglet.window.Window.__init__(self, resizable=True) self.series = series self.font = 'Arkhip' - self.margins = (0.08, 0.08) # Fractions of window size - self.lines = (12, 8) + self.margins = (0.1, 0.08) # Fractions of window size + self.lines = (10, 8) #self.resizable = True self.set_caption(self.series.title) @@ -85,11 +87,14 @@ class Plot(pyglet.window.Window): # Using fp arithmetic to avoid intermittent fencepost errors pos = int(pos) if axis==0: # x axis, vertical lines + scale = float(self.series.xlimits[1]-self.series.xlimits[0])/(stop-start) + tagvalue = ((pos-start) * scale) + self.series.xlimits[0] + tagtext = str(round(tagvalue, 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, + tag = pyglet.text.Label(tagtext, color=BLACK, font_name=self.font, font_size=self.height*self.margins[1-axis]*0.28, - x=pos, y=self.height*self.margins[axis], + x=pos, y=self.height*self.margins[1-axis], anchor_x='left', anchor_y='top') axistitle = pyglet.text.Label(self.series.xname, color=BLACK, font_name=self.font, font_size=self.height*self.margins[axis]*0.3, @@ -97,9 +102,12 @@ class Plot(pyglet.window.Window): anchor_x='center', anchor_y='bottom') axistitle.draw() if axis==1: # y axis, horizontal lines + scale = float(self.series.ylimits[1]-self.series.ylimits[0])/(stop-start) + tagvalue = ((pos-start) * scale) + self.series.ylimits[0] + tagtext = str(round(tagvalue, 1)) 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, + tag = pyglet.text.Label(tagtext, color=BLACK, font_name=self.font, font_size=self.width*self.margins[axis]*0.22, x=self.width*self.margins[1-axis]*0.9, y=pos, anchor_x='right', anchor_y='center') -- libgit2 0.21.2