diff --git a/bob/measure/script/common_options.py b/bob/measure/script/common_options.py index f3dc178ec88d66e947165e1f7eedc607d2537f94..cd6c855fb35c50426f4ba80872043c26e282aab8 100644 --- a/bob/measure/script/common_options.py +++ b/bob/measure/script/common_options.py @@ -59,6 +59,20 @@ def scores_argument(min_arg=1, force_eval=False, **kwargs): return custom_scores_argument +def alpha_option(dflt=1, **kwargs): + '''An alpha option for plots''' + def custom_eval_option(func): + def callback(ctx, param, value): + ctx.meta['alpha'] = value + return value + return click.option( + '-a', '--alpha', default=dflt, type=click.FLOAT, + show_default=True, + help='Adjusts transparency of plots.', + callback=callback, **kwargs)(func) + return custom_eval_option + + def no_legend_option(dflt=True, **kwargs): '''Get option flag to say if legend should be displayed or not''' return bool_option( @@ -284,7 +298,7 @@ def n_bins_option(**kwargs): return custom_n_bins_option -def table_option(**kwargs): +def table_option(dflt="rst", **kwargs): '''Get table option for tabulate package More informnations: https://pypi.org/project/tabulate/ ''' @@ -294,7 +308,7 @@ def table_option(**kwargs): return value return click.option( '--tablefmt', type=click.Choice(tabulate.tabulate_formats), - default='rst', show_default=True, help='Format of printed tables.', + default=dflt, show_default=True, help='Format of printed tables.', callback=callback, **kwargs)(func) return custom_table_option @@ -664,6 +678,7 @@ def roc_command(docstring, far_name="FAR"): @figsize_option() @style_option() @linestyles_option() + @alpha_option() @verbosity_option() @click.pass_context @functools.wraps(func) @@ -718,6 +733,7 @@ def det_command(docstring, far_name="FAR"): @figsize_option() @style_option() @linestyles_option() + @alpha_option() @verbosity_option() @click.pass_context @functools.wraps(func) @@ -765,6 +781,7 @@ def epc_command(docstring): @figsize_option() @style_option() @linestyles_option() + @alpha_option() @verbosity_option() @click.pass_context @functools.wraps(func) diff --git a/bob/measure/script/figure.py b/bob/measure/script/figure.py index c9fe3a5d4ced69281c53152193176addec0d9ae5..aae0c04b652a5fea2b353cfff66e40c4fc0ce2a3 100644 --- a/bob/measure/script/figure.py +++ b/bob/measure/script/figure.py @@ -430,6 +430,7 @@ class PlotBase(MeasureBase): self._points = ctx.meta.get('points', 2000) self._split = ctx.meta.get('split') self._axlim = ctx.meta.get('axlim') + self._alpha = ctx.meta.get('alpha') self._disp_legend = ctx.meta.get('disp_legend', True) self._legend_loc = ctx.meta.get('legend_loc') self._min_dig = None @@ -571,7 +572,8 @@ class Roc(PlotBase): CAR=self._semilogx, min_far=self._min_dig, color=self._colors[idx], linestyle=self._linestyles[idx], - label=self._label('dev', idx) + label=self._label('dev', idx), + alpha=self._alpha, ) if self._split: mpl.figure(2) @@ -584,7 +586,8 @@ class Roc(PlotBase): CAR=self._semilogx, min_far=self._min_dig, color=self._colors[idx], - label=self._label('eval.', idx) + label=self._label('eval.', idx), + alpha=self._alpha, ) if self._far_at is not None: from .. import fprfnr @@ -604,7 +607,8 @@ class Roc(PlotBase): CAR=self._semilogx, min_far=self._min_dig, color=self._colors[idx], linestyle=self._linestyles[idx], - label=self._label('dev', idx) + label=self._label('dev', idx), + alpha=self._alpha, ) @@ -648,7 +652,8 @@ class Det(PlotBase): dev_neg, dev_pos, self._points, min_far=self._min_dig, color=self._colors[idx], linestyle=self._linestyles[idx], - label=self._label('dev.', idx) + label=self._label('dev.', idx), + alpha=self._alpha, ) if self._split: mpl.figure(2) @@ -658,7 +663,8 @@ class Det(PlotBase): eval_neg, eval_pos, self._points, min_far=self._min_dig, color=self._colors[idx], linestyle=linestyle, - label=self._label('eval.', idx) + label=self._label('eval.', idx), + alpha=self._alpha, ) if self._far_at is not None: from .. import farfrr @@ -675,7 +681,8 @@ class Det(PlotBase): dev_neg, dev_pos, self._points, min_far=self._min_dig, color=self._colors[idx], linestyle=self._linestyles[idx], - label=self._label('dev.', idx) + label=self._label('dev.', idx), + alpha=self._alpha, ) def _set_axis(self): @@ -713,7 +720,8 @@ class Epc(PlotBase): color=self._colors[idx], linestyle=self._linestyles[idx], label=self._label( 'curve', idx - ) + ), + alpha=self._alpha, )