diff --git a/demo.png b/demo.png new file mode 100644 index 0000000..73c60a6 Binary files /dev/null and b/demo.png differ diff --git a/demo.py b/demo.py index 60e9a42..c554425 100644 --- a/demo.py +++ b/demo.py @@ -18,12 +18,13 @@ ndim, nsamples = 3, 50000 # Generate some fake data. -data1 = np.random.randn(ndim * 4 * nsamples / 5).reshape( - [4 * nsamples / 5, ndim] +data1 = np.random.randn(int(ndim * 4 * nsamples / 5)).reshape( + [int(4 * nsamples / 5), ndim] ) + data2 = 4 * np.random.rand(ndim)[None, :] + np.random.randn( - ndim * nsamples / 5 -).reshape([nsamples / 5, ndim]) + int(ndim * nsamples / 5) +).reshape([int(nsamples / 5), ndim]) data = np.vstack([data1, data2]) # Plot it. @@ -36,6 +37,7 @@ r"$\Gamma \, [\mathrm{parsec}]$", ], quantiles=[0.16, 0.5, 0.84], + q_ls=["solid", "dashed", "dashdot"], show_titles=True, title_kwargs={"fontsize": 12}, ) diff --git a/src/corner/core.py b/src/corner/core.py index d742556..c42e090 100644 --- a/src/corner/core.py +++ b/src/corner/core.py @@ -49,6 +49,7 @@ def corner_impl( truth_color="#4682b4", scale_hist=False, quantiles=None, + q_ls=None, title_quantiles=None, verbose=False, fig=None, @@ -243,8 +244,19 @@ 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) + if q_ls is None or len(q_ls) == 0: + for q in qvalues: + ax.axvline(q, ls="dashed", color=color) + else: + if len(q_ls) == len(quantiles): + for q, ls in zip(qvalues, q_ls): + ax.axvline(q, ls=ls, color=color) + elif len(q_ls) < len(quantiles): + print( + f"Not enough line styles given for quantiles, using {q_ls[0]} for all" + ) + for q in qvalues: + ax.axvline(q, ls=q_ls[0], color=color) if verbose: print("Quantiles:") diff --git a/src/corner/corner.py b/src/corner/corner.py index e4f54ad..a219609 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, + q_ls=None, verbose=False, fig=None, max_n_ticks=5, @@ -180,7 +181,10 @@ def corner( quantiles : iterable A list of fractional quantiles to show on the 1-D histograms as - vertical dashed lines. + vertical dashed lines or depends on ``q_ls``. + + q_ls : iterable + A list of matplotlib line style specifiers to be used for the quantiles. verbose : bool If true, print the values of the computed quantiles. @@ -266,6 +270,7 @@ def corner( truth_color=truth_color, scale_hist=scale_hist, quantiles=quantiles, + q_ls=q_ls, verbose=verbose, fig=fig, max_n_ticks=max_n_ticks,