From 651b8c2b2915ad499ff646dc061222f96d27f1a4 Mon Sep 17 00:00:00 2001 From: Antony Lewis Date: Mon, 15 May 2023 12:31:20 +0100 Subject: [PATCH] allow lw,ls for filled contour styling (#98) * allow lw,ls for filled contour styling * tweak --- getdist/plots.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/getdist/plots.py b/getdist/plots.py index 983f0ba..5c97c6d 100644 --- a/getdist/plots.py +++ b/getdist/plots.py @@ -1078,12 +1078,8 @@ def add_2d_contours(self, root, param1=None, param2=None, plotno=0, of=None, col else: proxy_ix = -1 - def clean_args(_args): # prevent unused argument warnings - _args = dict(_args) - _args.pop('color', None) - _args.pop('ls', None) - _args.pop('lw', None) - return _args + def clean_args(_args): + return {k: v for k, v in _args.items() if k not in ('color', 'ls', 'lw')} if kwargs.get('filled'): if cols is None: @@ -1101,13 +1097,15 @@ def clean_args(_args): # prevent unused argument warnings self.contours_added[proxy_ix] = ( matplotlib.patches.Rectangle((0, 0), 1, 1, fc=matplotlib.colors.to_rgb(cs.tcolors[-1][0]))) ax.contour(density.x, density.y, density.P, levels[:1], colors=cs.tcolors[-1], - linewidths=self._scaled_linewidth(self.settings.linewidth_contour), + linewidths=self._scaled_linewidth(self.settings.linewidth_contour + if kwargs.get('lw') is None else kwargs['lw']), + linestyles=kwargs.get('ls'), alpha=alpha * self.settings.alpha_factor_contour_lines, **clean_args(kwargs)) else: args = self._get_line_styles(plotno, **kwargs) linestyles = [args['ls']] cols = [args['color']] - lws = args['lw'] # not linewidth_contour is only used for filled contours + lws = args['lw'] # note linewidth_contour is only used for filled contours kwargs = self._get_plot_args(plotno, **kwargs) kwargs['alpha'] = alpha cs = ax.contour(density.x, density.y, density.P, sorted(contour_levels), colors=cols, linestyles=linestyles,