diff --git a/tupak/core/result.py b/tupak/core/result.py index b3553cc58c1e2b61dcdcd2ae96dbaffbb452071e..8ecf8e1a4b0103e72943ad8ade5074f77f2dca9b 100644 --- a/tupak/core/result.py +++ b/tupak/core/result.py @@ -270,8 +270,8 @@ class Result(dict): string = r"${{{0}}}_{{-{1}}}^{{+{2}}}$" return string.format(fmt(median), fmt(lower), fmt(upper)) - def plot_corner(self, parameters=None, save=True, priors=None, dpi=300, - titles=True, **kwargs): + def plot_corner(self, parameters=None, priors=None, titles=True, save=True, + filename=None, dpi=300, **kwargs): """ Plot a corner-plot using corner See https://corner.readthedocs.io/en/latest/ for a detailed API. @@ -280,18 +280,20 @@ class Result(dict): ---------- parameters: list, optional If given, a list of the parameter names to include - save: bool, optional - If true, save the image using the given label and outdir priors: tupak.core.prior.PriorSet If given, add the prior probability density functions to the one-dimensional marginal distributions - dpi: int, optional - Dots per inch resolution of the plot titles: bool If true, add 1D titles of the median and (by default 1-sigma) error bars. To change the error bars, pass in the quantiles kwarg. See method `get_one_dimensional_median_and_error_bar` for further details). If `quantiles=None` is passed in, no title is added. + save: bool, optional + If true, save the image using the given label and outdir + filename: str, optional + If given, overwrite the default filename + dpi: int, optional + Dots per inch resolution of the plot **kwargs: Other keyword arguments are passed to `corner.corner`. We set some defaults to improve the basic look and feel, but these can all be @@ -368,8 +370,9 @@ class Result(dict): ax.plot(theta, priors[par].prob(theta), color='C2') if save: - utils.check_directory_exists_and_if_not_mkdir(self.outdir) - filename = '{}/{}_corner.png'.format(self.outdir, self.label) + if filename is None: + utils.check_directory_exists_and_if_not_mkdir(self.outdir) + filename = '{}/{}_corner.png'.format(self.outdir, self.label) logger.debug('Saving corner plot to {}'.format(filename)) fig.savefig(filename, dpi=dpi)