plot_label_segments_multirow#

ethograph.labels.plots.plot_label_segments_multirow(ax, df, label_mappings, row_index=0, row_spacing=0.8, rect_height=0.7, alpha=0.7, individual=None)[source]#

Plot label segments at a specific row position.

Useful for comparing ground truth vs. predictions on the same axis by placing each on a different row.

Parameters:
  • ax (Axes) – Matplotlib axis to plot on

  • df (DataFrame) – Intervals DataFrame with columns onset_s, offset_s, labels, individual

  • label_mappings (Dict[int, Dict[str, str]]) – Dict mapping label IDs to color info

  • row_index (int) – Row number (0-based) for vertical positioning

  • row_spacing (float) – Vertical spacing between rows

  • rect_height (float) – Height of each rectangle

  • alpha (float) – Transparency of rectangles

  • individual (Optional[str]) – If given, only plot segments for this individual

Return type:

None

Example:

import ethograph as eto
from ethograph.labels.intervals import load_label_mapping

dt = eto.open("data.nc")
pred_dt = eto.open("predictions.nc")
label_mappings = load_label_mapping("mapping.txt")

fig, ax = plt.subplots()
ax.set_yticks([0, 0.8])
ax.set_yticklabels(["ground truth", "predictions"])

# gt_df, pred_df are intervals DataFrames with onset_s, offset_s, labels, individual
gt_df = ...
pred_df = ...

plot_label_segments_multirow(ax, gt_df, label_mappings, row_index=0)
plot_label_segments_multirow(ax, pred_df, label_mappings, row_index=1)
plt.show()