diff --git a/bob/measure/script/figure.py b/bob/measure/script/figure.py index 0b40631571104ee6a7d4172b19404780712ab236..bb9148fb9874f9b966b644b960101d8f56cbe326 100644 --- a/bob/measure/script/figure.py +++ b/bob/measure/script/figure.py @@ -882,12 +882,15 @@ class GridSubplot(PlotBase): figure=mpl.gcf(), ) - def create_subplot(self, n): + def create_subplot(self, n, shared_axis=None): i, j = numpy.unravel_index(n, (self._nrows, self._ncols)) i1 = i * self._row_times + self._grid_axis_offset i2 = (i + 1) * self._row_times + self._grid_axis_offset j1, j2 = j * self._col_times, (j + 1) * self._col_times - axis = mpl.gcf().add_subplot(self._gs[i1:i2, j1:j2]) + if shared_axis is not None: + axis = mpl.gcf().add_subplot(self._gs[i1:i2, j1:j2], sharex=shared_axis, sharey=shared_axis) + else: + axis = mpl.gcf().add_subplot(self._gs[i1:i2, j1:j2]) return axis def finalize_one_page(self): @@ -966,23 +969,26 @@ class Hist(GridSubplot): col = idx % self._ncols idx = col + self._ncols * row + dev_axis = None + if not self._hide_dev or not self._eval: - self._print_subplot( + dev_axis = self._print_subplot( idx, sys, dev_neg, dev_pos, threshold, not self._no_line, False ) 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, + shared_axis=dev_axis) - def _print_subplot(self, idx, sys, neg, pos, threshold, draw_line, evaluation): + def _print_subplot(self, idx, sys, neg, pos, threshold, draw_line, evaluation, + shared_axis=None): """ print a subplot for the given score and subplot index""" n = idx % self._step_print col = n % self._ncols sub_plot_idx = n + 1 - axis = self.create_subplot(n) + axis = self.create_subplot(n, shared_axis) self._setup_hist(neg, pos) if col == 0: axis.set_ylabel(self._y_label) @@ -1015,6 +1021,7 @@ class Hist(GridSubplot): # to display, save figure if self._step_print == sub_plot_idx or (is_lower and sys == self.n_systems - 1): self.finalize_one_page() + return axis def _get_title(self, idx, dflt=None): """ Get the histo title for the given idx"""