Skip to content

Commit ced6091

Browse files
add **kwargs to diagnostics.plot_recovery
allows modifying the key part of the plot, i.e., the scatter (with or without errorbars)
1 parent 1cba9c6 commit ced6091

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bayesflow/diagnostics.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def plot_recovery(
5353
n_row=None,
5454
xlabel="Ground truth",
5555
ylabel="Estimated",
56+
**kwargs
5657
):
5758
"""Creates and plots publication-ready recovery plot with true vs. point estimate + uncertainty.
5859
The point estimate can be controlled with the ``point_agg`` argument, and the uncertainty estimate
@@ -106,6 +107,9 @@ def plot_recovery(
106107
The label on the x-axis of the plot
107108
ylabel : str, optional, default: 'Estimated'
108109
The label on the y-axis of the plot
110+
**kwargs : optional
111+
Additional keyword arguments passed to ax.errorbar or ax.scatter.
112+
Example: `rasterized=True` to reduce PDF file size with many dots
109113
110114
Returns
111115
-------
@@ -156,9 +160,9 @@ def plot_recovery(
156160

157161
# Add scatter and error bars
158162
if uncertainty_agg is not None:
159-
_ = ax.errorbar(prior_samples[:, i], est[:, i], yerr=u[:, i], fmt="o", alpha=0.5, color=color)
163+
_ = ax.errorbar(prior_samples[:, i], est[:, i], yerr=u[:, i], fmt="o", alpha=0.5, color=color, **kwargs)
160164
else:
161-
_ = ax.scatter(prior_samples[:, i], est[:, i], alpha=0.5, color=color)
165+
_ = ax.scatter(prior_samples[:, i], est[:, i], alpha=0.5, color=color, **kwargs)
162166

163167
# Make plots quadratic to avoid visual illusions
164168
lower = min(prior_samples[:, i].min(), est[:, i].min())

0 commit comments

Comments
 (0)