Skip to content

quantlies line style #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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},
)
Expand Down
16 changes: 14 additions & 2 deletions src/corner/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:")
Expand Down
7 changes: 6 additions & 1 deletion src/corner/corner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down