From d12f849b26c4e98d582e9e270f1e8b158834b8a7 Mon Sep 17 00:00:00 2001 From: jhshinn Date: Thu, 17 Nov 2022 14:36:47 +0900 Subject: [PATCH 1/3] Added a new parameter "quant_linestyle" to override the linestyles of the vertical quantile lines. --- src/corner/arviz_corner.py | 2 ++ src/corner/core.py | 11 ++++++++--- src/corner/corner.py | 9 ++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/corner/arviz_corner.py b/src/corner/arviz_corner.py index 5e1dab8..4784a4d 100644 --- a/src/corner/arviz_corner.py +++ b/src/corner/arviz_corner.py @@ -60,6 +60,7 @@ def arviz_corner( truth_color="#4682b4", scale_hist=False, quantiles=None, + quant_linestyle=None, verbose=False, fig=None, max_n_ticks=5, @@ -151,6 +152,7 @@ def arviz_corner( truth_color=truth_color, scale_hist=scale_hist, quantiles=quantiles, + quant_linestyle=quant_linestyle, verbose=verbose, fig=fig, max_n_ticks=max_n_ticks, diff --git a/src/corner/core.py b/src/corner/core.py index 7f7ebc4..b9b6e90 100644 --- a/src/corner/core.py +++ b/src/corner/core.py @@ -42,6 +42,7 @@ def corner_impl( truth_color="#4682b4", scale_hist=False, quantiles=None, + quant_linestyle=None, title_quantiles=None, verbose=False, fig=None, @@ -55,6 +56,7 @@ def corner_impl( ): if quantiles is None: quantiles = [] + quant_linestyle = [] if title_kwargs is None: title_kwargs = dict() if label_kwargs is None: @@ -220,9 +222,12 @@ def corner_impl( # Plot quantiles if wanted. if len(quantiles) > 0: qvalues = quantile(x, quantiles, weights=weights) - for q in qvalues: - ax.axvline(q, ls="dashed", color=color) - + for q_i, q in enumerate(qvalues): + if quant_linestyle: + ax.axvline(q, ls=quant_linestyle[q_i], color=color) + else: ax.axvline(q, ls="dashed", color=color) + # for q in qvalues: + # ax.axvline(q, ls="dashed", color=color) if verbose: print("Quantiles:") print([item for item in zip(quantiles, qvalues)]) diff --git a/src/corner/corner.py b/src/corner/corner.py index 3d50ee7..570ce1d 100644 --- a/src/corner/corner.py +++ b/src/corner/corner.py @@ -36,6 +36,7 @@ def corner( truth_color="#4682b4", scale_hist=False, quantiles=None, + quant_linestyle=None, verbose=False, fig=None, max_n_ticks=5, @@ -169,7 +170,11 @@ def corner( quantiles : iterable A list of fractional quantiles to show on the 1-D histograms as - vertical dashed lines. + vertical lines. The default linestyle is 'dashed'. + + quant_linestyle : iterable + A list of linestyle to override the default 'dashed' linestyle. + The size must be equal to that of quantiles. verbose : bool If true, print the values of the computed quantiles. @@ -254,6 +259,7 @@ def corner( truth_color=truth_color, scale_hist=scale_hist, quantiles=quantiles, + quant_linestyle=quant_linestyle, verbose=verbose, fig=fig, max_n_ticks=max_n_ticks, @@ -285,6 +291,7 @@ def corner( truth_color=truth_color, scale_hist=scale_hist, quantiles=quantiles, + quant_linestyle=None, verbose=verbose, fig=fig, max_n_ticks=max_n_ticks, From 4b62364ce2643f74d8d1d9c4a91ae808aa3e4a89 Mon Sep 17 00:00:00 2001 From: jhshinn Date: Thu, 17 Nov 2022 14:36:47 +0900 Subject: [PATCH 2/3] Added a new parameter "quant_linestyle" to override the linestyles of the vertical quantile lines. --- src/corner/arviz_corner.py | 2 ++ src/corner/core.py | 11 ++++++++--- src/corner/corner.py | 9 ++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/corner/arviz_corner.py b/src/corner/arviz_corner.py index 2461ef3..06acca7 100644 --- a/src/corner/arviz_corner.py +++ b/src/corner/arviz_corner.py @@ -61,6 +61,7 @@ def arviz_corner( truth_color="#4682b4", scale_hist=False, quantiles=None, + quant_linestyle=None, verbose=False, fig=None, max_n_ticks=5, @@ -153,6 +154,7 @@ def arviz_corner( truth_color=truth_color, scale_hist=scale_hist, quantiles=quantiles, + quant_linestyle=quant_linestyle, verbose=verbose, fig=fig, max_n_ticks=max_n_ticks, diff --git a/src/corner/core.py b/src/corner/core.py index bfb3084..a3ee2eb 100644 --- a/src/corner/core.py +++ b/src/corner/core.py @@ -50,6 +50,7 @@ def corner_impl( truth_color="#4682b4", scale_hist=False, quantiles=None, + quant_linestyle=None, title_quantiles=None, verbose=False, fig=None, @@ -63,6 +64,7 @@ def corner_impl( ): if quantiles is None: quantiles = [] + quant_linestyle = [] if title_kwargs is None: title_kwargs = dict() if label_kwargs is None: @@ -242,9 +244,12 @@ def corner_impl( # Plot quantiles if wanted. if len(quantiles) > 0: qvalues = quantile(x, quantiles, weights=weights) - for q in qvalues: - ax.axvline(q, ls="dashed", color=color) - + for q_i, q in enumerate(qvalues): + if quant_linestyle: + ax.axvline(q, ls=quant_linestyle[q_i], color=color) + else: ax.axvline(q, ls="dashed", color=color) + # for q in qvalues: + # ax.axvline(q, ls="dashed", color=color) if verbose: print("Quantiles:") print([item for item in zip(quantiles, qvalues)]) diff --git a/src/corner/corner.py b/src/corner/corner.py index 25de026..6a82751 100644 --- a/src/corner/corner.py +++ b/src/corner/corner.py @@ -37,6 +37,7 @@ def corner( truth_color="#4682b4", scale_hist=False, quantiles=None, + quant_linestyle=None, verbose=False, fig=None, max_n_ticks=5, @@ -174,7 +175,11 @@ def corner( quantiles : iterable A list of fractional quantiles to show on the 1-D histograms as - vertical dashed lines. + vertical lines. The default linestyle is 'dashed'. + + quant_linestyle : iterable + A list of linestyle to override the default 'dashed' linestyle. + The size must be equal to that of quantiles. verbose : bool If true, print the values of the computed quantiles. @@ -260,6 +265,7 @@ def corner( truth_color=truth_color, scale_hist=scale_hist, quantiles=quantiles, + quant_linestyle=quant_linestyle, verbose=verbose, fig=fig, max_n_ticks=max_n_ticks, @@ -292,6 +298,7 @@ def corner( truth_color=truth_color, scale_hist=scale_hist, quantiles=quantiles, + quant_linestyle=None, verbose=verbose, fig=fig, max_n_ticks=max_n_ticks, From 48c4bad8dc8b247cf8c83dc7bce60f0d06076985 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Nov 2022 07:31:25 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/corner/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corner/core.py b/src/corner/core.py index a3ee2eb..4e573ff 100644 --- a/src/corner/core.py +++ b/src/corner/core.py @@ -247,7 +247,8 @@ def corner_impl( for q_i, q in enumerate(qvalues): if quant_linestyle: ax.axvline(q, ls=quant_linestyle[q_i], color=color) - else: ax.axvline(q, ls="dashed", color=color) + else: + ax.axvline(q, ls="dashed", color=color) # for q in qvalues: # ax.axvline(q, ls="dashed", color=color) if verbose: