Skip to content
Snippets Groups Projects

Adjusted the histogram scale of the x axis to automatically adjust for varying...

Merged Alex UNNERVIK requested to merge HistXLim into master
All threads resolved!
+ 17
3
@@ -957,6 +957,18 @@ class Hist(GridSubplot):
dev_neg, dev_pos, eval_neg, eval_pos, threshold = self._get_neg_pos_thres(
idx, input_scores, input_names
)
if dev_neg and dev_pos and eval_neg and eval_pos is not None:
xmin = min(numpy.min(dev_neg[0]), numpy.min(eval_neg[0]), numpy.min(dev_pos[0]), numpy.min(eval_pos[0]))
xmax = max(numpy.max(dev_neg[0]), numpy.max(eval_neg[0]), numpy.max(dev_pos[0]), numpy.max(eval_pos[0]))
elif dev_neg and dev_pos is not None:
xmin = min(numpy.min(dev_neg[0]), numpy.min(dev_pos[0]))
xmax = max(numpy.max(dev_neg[0]), numpy.max(dev_pos[0]))
elif eval_neg and eval_pos is not None:
# Providing EVAL set results only not currently supported by bob bio hist, but potentially in the future?
xmin = min(numpy.min(eval_neg[0]), numpy.min(eval_pos[0]))
xmax = max(numpy.max(eval_neg[0]), numpy.max(eval_pos[0]))
# keep id of the current system
sys = idx
# if the id of the current system does not match the id of the plot,
@@ -968,16 +980,16 @@ class Hist(GridSubplot):
if not self._hide_dev or not self._eval:
self._print_subplot(
idx, sys, dev_neg, dev_pos, threshold, not self._no_line, False
idx, sys, dev_neg, dev_pos, threshold, not self._no_line, False, xlim=(xmin, xmax)
)
if self._eval:
idx += self._ncols if not self._hide_dev else 0
self._print_subplot(
idx, sys, eval_neg, eval_pos, threshold, not self._no_line, True
idx, sys, eval_neg, eval_pos, threshold, not self._no_line, True, xlim=(xmin, xmax)
)
def _print_subplot(self, idx, sys, neg, pos, threshold, draw_line, evaluation):
def _print_subplot(self, idx, sys, neg, pos, threshold, draw_line, evaluation, xlim=None):
""" print a subplot for the given score and subplot index"""
n = idx % self._step_print
col = n % self._ncols
@@ -995,6 +1007,8 @@ class Hist(GridSubplot):
is_lower = evaluation or not self._eval
if is_lower and sys_idx + self._ncols >= min(sys_per_page, rest_print):
axis.set_xlabel(self._x_label)
if xlim is not None:
axis.set_xlim(xlim)
dflt_title = "Eval. scores" if evaluation else "Dev. scores"
if self.n_systems == 1 and (not self._eval or self._hide_dev):
dflt_title = " "
Loading