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 ondf (
DataFrame) – Intervals DataFrame with columns onset_s, offset_s, labels, individuallabel_mappings (
Dict[int,Dict]) – Dict mapping label IDs to color infoindividual (
Optional[str]) – If given, only plot segments for this individualis_main (
bool) – If True, plot full-height rectangles; if False, plot small rectangles at topfraction (
float) – Height fraction for non-main rectangles
- Return type:
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()