plot_label_segments#

ethograph.labels.plots.plot_label_segments(ax, df, label_mappings, individual=None, is_main=True, fraction=0.2, alpha=0.8)[source]#

Plot label segments from an intervals DataFrame.

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]) – Dict mapping label IDs to color info

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

  • is_main (bool) – If True, plot full-height rectangles; if False, plot small rectangles at top

  • fraction (float) – Height fraction for non-main rectangles

Return type:

None

Example:

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

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

fig, ax = plt.subplots()
# df is an intervals DataFrame with onset_s, offset_s, labels, individual
plot_label_segments(ax, df, label_mappings)
plt.show()