Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 6d01a87d authored by Ed Rogers's avatar Ed Rogers
Browse files

Improve set_bar_colors for later upgrades

parent dab5cf61
......@@ -14,8 +14,10 @@ from matplotlib.figure import Figure
class HearingTestCanvas(FigureCanvas):
"""Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
false_color = np.array([0., 1., 0.])
true_color = np.array([0., 0., 1.])
running_color = np.array([0., 1., 0.])
finished_color = np.array([0., 0., 1.])
upper_color_depth = 0.5
lower_color_depth = 1.0
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
......@@ -39,9 +41,9 @@ class HearingTestCanvas(FigureCanvas):
inds = np.arange(0, test.freqs.size)
self.axes.set_facecolor('k')
self.ul_bar = self.axes.bar(inds, test.upper_bounds - self.baseline,
color=0.5*self.false_color, bottom=self.baseline)
color=self.upper_color_depth*self.running_color, bottom=self.baseline)
self.ll_bar = self.axes.bar(inds, test.lower_bounds - self.baseline,
color=self.false_color, bottom=self.baseline)
color=self.lower_color_depth*self.running_color, bottom=self.baseline)
xlim = self.axes.get_xlim()
for i in np.arange(test.lower_lim + self.baseline, test.upper_lim, test.block_size()):
self.axes.plot(self.axes.get_xlim(), np.ones(2)*i, color='k')
......@@ -55,7 +57,7 @@ class HearingTestCanvas(FigureCanvas):
def update_test(self, test: HearingTest) -> None:
self.set_bar_heights(self.ul_bar, test.upper_bounds - self.baseline)
self.set_bar_heights(self.ll_bar, test.lower_bounds - self.baseline)
self.set_bar_colors([self.ul_bar, self.ll_bar], test.finished_freqs)
self.set_bar_colors(test)
self.draw()
@staticmethod
......@@ -63,15 +65,14 @@ class HearingTestCanvas(FigureCanvas):
for bar, h in zip(bars, vals):
bar.set_height(h)
@staticmethod
def set_bar_colors(bars, finished):
depth = [0.5, 1]
for i, bar_line in enumerate(bars):
for bar, f in zip(bar_line, finished):
def set_bar_colors(self, test: HearingTest) -> None:
depth = [self.upper_color_depth, self.lower_color_depth]
for i, bar_line in enumerate([self.ul_bar, self.ll_bar]):
for bar, f in zip(bar_line, test.finished_freqs):
if f:
bar.set_facecolor(depth[i] * HearingTestCanvas.true_color)
bar.set_facecolor(depth[i] * HearingTestCanvas.finished_color)
else:
bar.set_facecolor(depth[i] * HearingTestCanvas.false_color)
bar.set_facecolor(depth[i] * HearingTestCanvas.running_color)
# TODO add animation
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment