Skip to content

Commit 2bedf47

Browse files
committed
Add optional arguments for legend locations for ECDF plots
1 parent 103fe5f commit 2bedf47

File tree

4 files changed

+615
-304
lines changed

4 files changed

+615
-304
lines changed

bayesflow/diagnostics/plots/calibration_ecdf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def calibration_ecdf(
1919
figsize: Sequence[float] = None,
2020
label_fontsize: int = 16,
2121
legend_fontsize: int = 14,
22+
legend_location: str = "upper right",
2223
title_fontsize: int = 18,
2324
tick_fontsize: int = 12,
2425
rank_ecdf_color: str = "#132a70",
@@ -184,7 +185,7 @@ def calibration_ecdf(
184185

185186
for ax, title in zip(plot_data["axes"].flat, titles):
186187
ax.fill_between(z, L, U, color=fill_color, alpha=0.2, label=rf"{int((1 - alpha) * 100)}$\%$ Confidence Bands")
187-
ax.legend(fontsize=legend_fontsize)
188+
ax.legend(fontsize=legend_fontsize, loc=legend_location)
188189
ax.set_title(title, fontsize=title_fontsize)
189190

190191
prettify_subplots(plot_data["axes"], num_subplots=plot_data["num_variables"], tick_fontsize=tick_fontsize)

bayesflow/diagnostics/plots/calibration_ecdf_from_quantiles.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def calibration_ecdf_from_quantiles(
1919
figsize: Sequence[float] = None,
2020
label_fontsize: int = 16,
2121
legend_fontsize: int = 14,
22+
legend_location: str = "upper right",
2223
title_fontsize: int = 18,
2324
tick_fontsize: int = 12,
2425
rank_ecdf_color: str = "#132a70",
@@ -173,7 +174,7 @@ def calibration_ecdf_from_quantiles(
173174
alpha=0.2,
174175
label=rf"{int((1 - alpha) * 100)}$\%$ Confidence Bands" + "\n(pointwise)",
175176
)
176-
ax.legend(fontsize=legend_fontsize)
177+
ax.legend(fontsize=legend_fontsize, loc=legend_location)
177178
ax.set_title(title, fontsize=title_fontsize)
178179

179180
prettify_subplots(plot_data["axes"], num_subplots=plot_data["num_variables"], tick_fontsize=tick_fontsize)

examples/SIR_Posterior_Estimation.ipynb

Lines changed: 446 additions & 121 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)