From d5bc030bad7bf90cf7ee97557978425c0bd65481 Mon Sep 17 00:00:00 2001 From: Christopher Stone Date: Mon, 12 Feb 2018 22:24:29 +0000 Subject: [PATCH] Rotated y-axis title. This uses (inelegant) direct manipulation of OGL, which is highly state-based. Sadly, there doesn't seem to be a better way to do it. --- telemetry/code/monitor/graph_plotter_rewrite.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/telemetry/code/monitor/graph_plotter_rewrite.py b/telemetry/code/monitor/graph_plotter_rewrite.py index b95ca60..e054e08 100755 --- a/telemetry/code/monitor/graph_plotter_rewrite.py +++ b/telemetry/code/monitor/graph_plotter_rewrite.py @@ -44,6 +44,7 @@ class Plot(pyglet.window.Window): self.bounds = ((int(self.width * self.margins[0]), int(self.width * (1 - self.margins[0]))), (int(self.height * self.margins[1]), int(self.height * (1 - self.margins[1])))) pyglet.window.Window.on_resize(self, width, height) + print(self.height) def on_draw(self): """Draw all the components of the graph""" @@ -84,6 +85,7 @@ class Plot(pyglet.window.Window): font_name=self.font, font_size=self.height*self.margins[axis]*0.3, x=self.width/2, y=0, anchor_x='center', anchor_y='bottom') + axistitle.draw() if axis==1: # y axis, horizontal lines pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (limita, pos, limitb, pos)), ('c3B', (0, 0, 0, 0, 0, 0))) @@ -94,10 +96,19 @@ class Plot(pyglet.window.Window): axistitle = pyglet.text.Label(self.series.yname, color=BLACK, font_name=self.font, font_size=self.height*self.margins[axis]*0.3, x=0, y=self.height/2, - anchor_x='left', anchor_y='center') + anchor_x='center', anchor_y='top') + pyglet.gl.glPushMatrix() + pyglet.gl.glTranslatef(self.height//2, self.height//2, 0.0) + pyglet.gl.glRotatef(90.0, 0.0, 0.0, 1.0) + axistitle.draw() + pyglet.gl.glPopMatrix() + #pyglet.gl.glRotatef(-90.0, 0.0, 0.0, 1.0) + #pyglet.gl.glTranslatef(-self.width//2, -self.height//2, 0.0) + tag.draw() - axistitle.draw() + + -- libgit2 0.21.2