Skip to content
Snippets Groups Projects
Commit bc5ea988 authored by Andi Gerken's avatar Andi Gerken
Browse files

Added evaluation to show all tracks in one plot.

parent 113fe09c
No related branches found
No related tags found
1 merge request!54robofish-io-evaluate2 and lazy imports
......@@ -37,6 +37,7 @@ def function_dict() -> dict:
"follow_iid": base.evaluate_follow_iid,
"individual_speed": base.evaluate_individual_speed,
"individual_iid": base.evaluate_individual_iid,
"single_plot_tracks": base.evaluate_single_plot_tracks,
# "quiver": base.evaluate_quiver, # Quiver has issues with multiple paths and raises exceptions. The function is not used for now.
"all": base.evaluate_all,
}
......
......@@ -627,6 +627,38 @@ def evaluate_quiver(
return fig
def evaluate_single_plot_tracks(
paths: Iterable[Union[str, Path]],
labels: Iterable[str] = None,
predicate: Callable[[robofish.io.Entity], bool] = None,
poses_from_paths: Iterable[Iterable[np.ndarray]] = None,
max_files: int = None,
):
"""Evaluate the tracks of the entities as a plot."""
if poses_from_paths is None:
poses_from_paths, file_settings = utils.get_all_poses_from_paths(
paths, predicate, max_files=max_files
)
fig, ax = plt.subplots(
1, len(poses_from_paths), figsize=(8 * len(poses_from_paths), 8)
)
if len(poses_from_paths) == 1:
ax = [ax]
cmap = plt.get_cmap("Blues")
for i, poses_per_path in enumerate(poses_from_paths):
for fi, poses in enumerate(poses_per_path):
for e in poses:
ax[i].plot(
e[:, 0], e[:, 1], c=cmap(fi / len(poses_per_path)), alpha=0.5
)
ax[i].set_title(labels[i])
ax[i].set_xlabel("x [cm]")
ax[i].set_ylabel("y [cm]")
return fig
def evaluate_social_vector(
paths: Iterable[Union[str, Path]],
labels: Iterable[str] = None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment