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 ondf (
DataFrame) – Intervals DataFrame with columns onset_s, offset_s, labels, individuallabel_mappings (
Dict[int,Dict[str,str]]) – Dict mapping label IDs to color inforow_index (
int) – Row number (0-based) for vertical positioningrow_spacing (
float) – Vertical spacing between rowsrect_height (
float) – Height of each rectanglealpha (
float) – Transparency of rectanglesindividual (
Optional[str]) – If given, only plot segments for this individual
- Return type:
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()