From 38f5a8178325be578518d176ae13b3f2cd25446b Mon Sep 17 00:00:00 2001
From: Polina Lakrisenko
Date: Mon, 7 Jul 2025 20:57:55 +0200
Subject: [PATCH 1/6] fix goodness_of_fit plot and add color parameter
---
petab/v1/visualize/plot_residuals.py | 6 +++++-
tests/v1/test_visualization.py | 6 +++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/petab/v1/visualize/plot_residuals.py b/petab/v1/visualize/plot_residuals.py
index a45fcde3..e563a07f 100644
--- a/petab/v1/visualize/plot_residuals.py
+++ b/petab/v1/visualize/plot_residuals.py
@@ -134,6 +134,7 @@ def plot_goodness_of_fit(
petab_problem: Problem,
simulations_df: str | Path | pd.DataFrame,
size: tuple = (10, 7),
+ color = None,
ax: plt.Axes | None = None,
) -> matplotlib.axes.Axes:
"""
@@ -148,6 +149,8 @@ def plot_goodness_of_fit(
output data file.
size:
Figure size.
+ color:
+ The marker colors, matches the `c` parameter of `matplotlib.pyplot.scatter`.
ax:
Axis object.
@@ -171,8 +174,8 @@ def plot_goodness_of_fit(
parameter_dfs=petab_problem.parameter_df,
)[0]
slope, intercept, r_value, p_value, std_err = stats.linregress(
- petab_problem.measurement_df["measurement"],
simulations_df["simulation"],
+ petab_problem.measurement_df["measurement"],
) # x, y
if ax is None:
@@ -182,6 +185,7 @@ def plot_goodness_of_fit(
ax.scatter(
petab_problem.measurement_df["measurement"],
simulations_df["simulation"],
+ c=color,
)
ax.axis("square")
diff --git a/tests/v1/test_visualization.py b/tests/v1/test_visualization.py
index 0edd4b78..3c5a3a65 100644
--- a/tests/v1/test_visualization.py
+++ b/tests/v1/test_visualization.py
@@ -8,14 +8,14 @@
import petab
from petab.C import *
-from petab.visualize import (
+from petab.v1.visualize import (
plot_goodness_of_fit,
plot_residuals_vs_simulation,
plot_with_vis_spec,
plot_without_vis_spec,
)
-from petab.visualize.lint import validate_visualization_df
-from petab.visualize.plotting import VisSpecParser
+from petab.v1.visualize.lint import validate_visualization_df
+from petab.v1.visualize.plotting import VisSpecParser
# Avoid errors when plotting without X server
plt.switch_backend("agg")
From 5de85581f0cbaf500f2df90bcf80223ed90546f9 Mon Sep 17 00:00:00 2001
From: Polina Lakrisenko
Date: Mon, 7 Jul 2025 21:10:49 +0200
Subject: [PATCH 2/6] style
---
petab/v1/visualize/plot_residuals.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/petab/v1/visualize/plot_residuals.py b/petab/v1/visualize/plot_residuals.py
index e563a07f..ee0826d1 100644
--- a/petab/v1/visualize/plot_residuals.py
+++ b/petab/v1/visualize/plot_residuals.py
@@ -150,7 +150,8 @@ def plot_goodness_of_fit(
size:
Figure size.
color:
- The marker colors, matches the `c` parameter of `matplotlib.pyplot.scatter`.
+ The marker colors, matches the `c` parameter of
+ `matplotlib.pyplot.scatter`.
ax:
Axis object.
From 5604a78b2143890f558e0ec02cd0421c5da1714f Mon Sep 17 00:00:00 2001
From: Polina Lakrisenko
Date: Mon, 7 Jul 2025 21:27:58 +0200
Subject: [PATCH 3/6] style
---
petab/v1/measurements.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/petab/v1/measurements.py b/petab/v1/measurements.py
index ec7a1069..8b23907b 100644
--- a/petab/v1/measurements.py
+++ b/petab/v1/measurements.py
@@ -289,7 +289,7 @@ def assert_overrides_match_parameter_count(
)
}
if NOISE_FORMULA in observable_df.columns
- else {obs_id: 0 for obs_id in observable_df.index.values}
+ else dict.fromkeys(observable_df.index.values, 0)
)
for _, row in measurement_df.iterrows():
From 7abb235ded891dbb13b3d4d51843db7026138104 Mon Sep 17 00:00:00 2001
From: Polina Lakrisenko
Date: Thu, 7 Aug 2025 21:41:26 +0200
Subject: [PATCH 4/6] gof plot, change to singular in axes labels
---
petab/v1/visualize/plot_residuals.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/petab/v1/visualize/plot_residuals.py b/petab/v1/visualize/plot_residuals.py
index ee0826d1..c39496dd 100644
--- a/petab/v1/visualize/plot_residuals.py
+++ b/petab/v1/visualize/plot_residuals.py
@@ -212,6 +212,6 @@ def plot_goodness_of_fit(
)
ax.set_title("Goodness of fit")
- ax.set_xlabel("simulated values")
- ax.set_ylabel("measurements")
+ ax.set_xlabel("simulated value")
+ ax.set_ylabel("measurement")
return ax
From 920238aec0b4a3391912448cf1816ce659dc2d3e Mon Sep 17 00:00:00 2001
From: Polina Lakrisenko
Date: Thu, 7 Aug 2025 21:48:08 +0200
Subject: [PATCH 5/6] style
---
petab/v1/visualize/plot_residuals.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/petab/v1/visualize/plot_residuals.py b/petab/v1/visualize/plot_residuals.py
index c39496dd..5063e687 100644
--- a/petab/v1/visualize/plot_residuals.py
+++ b/petab/v1/visualize/plot_residuals.py
@@ -134,7 +134,7 @@ def plot_goodness_of_fit(
petab_problem: Problem,
simulations_df: str | Path | pd.DataFrame,
size: tuple = (10, 7),
- color = None,
+ color=None,
ax: plt.Axes | None = None,
) -> matplotlib.axes.Axes:
"""
From 658c8c09df12a866b374401f2b7494aed134bc64 Mon Sep 17 00:00:00 2001
From: Polina Lakrisenko
Date: Fri, 8 Aug 2025 15:34:25 +0200
Subject: [PATCH 6/6] Update petab/v1/visualize/plot_residuals.py
Co-authored-by: Maren Philipps <55318391+m-philipps@users.noreply.github.com>
---
petab/v1/visualize/plot_residuals.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/petab/v1/visualize/plot_residuals.py b/petab/v1/visualize/plot_residuals.py
index 5063e687..230c8605 100644
--- a/petab/v1/visualize/plot_residuals.py
+++ b/petab/v1/visualize/plot_residuals.py
@@ -212,6 +212,6 @@ def plot_goodness_of_fit(
)
ax.set_title("Goodness of fit")
- ax.set_xlabel("simulated value")
- ax.set_ylabel("measurement")
+ ax.set_xlabel("Simulated value")
+ ax.set_ylabel("Measurement")
return ax