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 onstart_time (
float) – Start time of the labelend_time (
float) – End time of the labellabels (
int) – Label class ID for color mappinglabel_mappings (
Dict[int,Dict]) – Dict mapping label IDs to color infois_main (
bool) – If True, draw full-height rectangle; if False, draw small rectangle at topfraction (
Optional[float]) – Height fraction for non-main rectangles
- Return type:
Example:
fig, ax = plt.subplots() ax.plot(time, signal) draw_label_rectangle(ax, 1.2, 3.5, label_id=1, label_mappings=label_mappings)