Skip to content

Commit 38f5a81

Browse files
committed
fix goodness_of_fit plot and add color parameter
1 parent 636404d commit 38f5a81

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

petab/v1/visualize/plot_residuals.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def plot_goodness_of_fit(
134134
petab_problem: Problem,
135135
simulations_df: str | Path | pd.DataFrame,
136136
size: tuple = (10, 7),
137+
color = None,
137138
ax: plt.Axes | None = None,
138139
) -> matplotlib.axes.Axes:
139140
"""
@@ -148,6 +149,8 @@ def plot_goodness_of_fit(
148149
output data file.
149150
size:
150151
Figure size.
152+
color:
153+
The marker colors, matches the `c` parameter of `matplotlib.pyplot.scatter`.
151154
ax:
152155
Axis object.
153156
@@ -171,8 +174,8 @@ def plot_goodness_of_fit(
171174
parameter_dfs=petab_problem.parameter_df,
172175
)[0]
173176
slope, intercept, r_value, p_value, std_err = stats.linregress(
174-
petab_problem.measurement_df["measurement"],
175177
simulations_df["simulation"],
178+
petab_problem.measurement_df["measurement"],
176179
) # x, y
177180

178181
if ax is None:
@@ -182,6 +185,7 @@ def plot_goodness_of_fit(
182185
ax.scatter(
183186
petab_problem.measurement_df["measurement"],
184187
simulations_df["simulation"],
188+
c=color,
185189
)
186190

187191
ax.axis("square")

tests/v1/test_visualization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
import petab
1010
from petab.C import *
11-
from petab.visualize import (
11+
from petab.v1.visualize import (
1212
plot_goodness_of_fit,
1313
plot_residuals_vs_simulation,
1414
plot_with_vis_spec,
1515
plot_without_vis_spec,
1616
)
17-
from petab.visualize.lint import validate_visualization_df
18-
from petab.visualize.plotting import VisSpecParser
17+
from petab.v1.visualize.lint import validate_visualization_df
18+
from petab.v1.visualize.plotting import VisSpecParser
1919

2020
# Avoid errors when plotting without X server
2121
plt.switch_backend("agg")

0 commit comments

Comments
 (0)