Commit 654dbda955af418ae31e5e8ab97a8c09443e3e58
1 parent
9f810b17
Exists in
master
Resructured axes title and tag scaling
now axes titles and text scale at the same rate, to avoid the ugly situation of uneven overlaps. May want to change scaling factors in the future so that titles are larger than lables, but that can be done easily.
Showing
1 changed file
with
5 additions
and
4 deletions
Show diff stats
robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py
... | ... | @@ -129,6 +129,7 @@ class Plot(pyglet.window.Window): |
129 | 129 | """Handle a resize event from the pyglet event loop""" |
130 | 130 | self.bounds = ((int(self.width * self.margins[0]), int(self.width * (1 - self.margins[0]))), |
131 | 131 | (int(self.height * self.margins[1]), int(self.height * (1 - self.margins[1])))) |
132 | + self.tag_size = min(self.height*self.margins[1]*0.3,self.width*self.margins[0]*0.3) | |
132 | 133 | # This sometimes seems to throw an error ('AttributeError: 'Plot' object has no attribute 'margins') when started for a second time from the same instance. Interesting. Causes the plot windows to freeze |
133 | 134 | pyglet.window.Window.on_resize(self, width, height) |
134 | 135 | |
... | ... | @@ -173,11 +174,11 @@ class Plot(pyglet.window.Window): |
173 | 174 | pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (pos, limita, pos, limitb)), |
174 | 175 | ('c3B', (0, 0, 0, 0, 0, 0))) |
175 | 176 | tag = pyglet.text.Label(tagtext, color=BLACK, |
176 | - font_name=self.font, font_size=self.height*self.margins[1]*0.3, | |
177 | + font_name=self.font, font_size=self.tag_size, | |
177 | 178 | x=pos, y=self.height*self.margins[1], |
178 | 179 | anchor_x='left', anchor_y='top') |
179 | 180 | axistitle = pyglet.text.Label(self.series.xname, color=BLACK, |
180 | - font_name=self.font, font_size=self.height*self.margins[1]*0.3, | |
181 | + font_name=self.font, font_size=self.tag_size, | |
181 | 182 | x=self.width/2, y=0, |
182 | 183 | anchor_x='center', anchor_y='bottom') |
183 | 184 | axistitle.draw() |
... | ... | @@ -188,11 +189,11 @@ class Plot(pyglet.window.Window): |
188 | 189 | pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (limita, pos, limitb, pos)), |
189 | 190 | ('c3B', (0, 0, 0, 0, 0, 0))) |
190 | 191 | tag = pyglet.text.Label(tagtext, color=BLACK, |
191 | - font_name=self.font, font_size=self.width*self.margins[0]*0.2, | |
192 | + font_name=self.font, font_size=self.tag_size, | |
192 | 193 | x=self.width*self.margins[0]*0.9, y=pos, |
193 | 194 | anchor_x='right', anchor_y='center') |
194 | 195 | axistitle = pyglet.text.Label(self.series.yname, color=BLACK, |
195 | - font_name=self.font, font_size=self.height*self.margins[0]*0.3, | |
196 | + font_name=self.font, font_size=self.tag_size, | |
196 | 197 | x=0, y=self.height/2, |
197 | 198 | anchor_x='center', anchor_y='top') |
198 | 199 | pyglet.gl.glPushMatrix() # Set up a new context to avoid confusing the main one | ... | ... |