Skip to content

Commit

Permalink
allow lw,ls for filled contour styling (#98)
Browse files Browse the repository at this point in the history
* allow lw,ls for filled contour styling

* tweak
  • Loading branch information
cmbant committed May 15, 2023
1 parent c10526a commit 651b8c2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions getdist/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand Down

0 comments on commit 651b8c2

Please sign in to comment.