draw_label_rectangle#

ethograph.labels.plots.draw_label_rectangle(ax, start_time, end_time, labels, label_mappings, is_main=True, fraction=None, alpha=0.8)[source]#

Draw a label rectangle on a matplotlib axis.

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

  • start_time (float) – Start time of the label

  • end_time (float) – End time of the label

  • labels (int) – Label class ID for color mapping

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

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

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

Return type:

None

Example:

fig, ax = plt.subplots()
ax.plot(time, signal)
draw_label_rectangle(ax, 1.2, 3.5, label_id=1, label_mappings=label_mappings)