vocalpy.plot.spect.annotated_spectrogram#
- vocalpy.plot.spect.annotated_spectrogram(spect: Spectrogram, annot: Annotation, tlim: tuple | list | None = None, flim: tuple | list | None = None, y_segments: float = 0.5, h_segments: float = 0.4, y_labels: float = 0.3, label_color_map: dict | None = None, pcolormesh_kwargs: dict | None = None, text_kwargs=None) tuple[Figure, dict] [source]#
Plot a
vocalpy.Spectrogram
with avocalpy.Annotation
below it.Convenience function that calls
vocalpy.plot.spectrogram()
andvocalpy.plot.annotation()
.- Parameters:
- spectvocalpy.Spectrogram
- annotvocalpy.Annotation
Annotation that has segments to be plotted (the annot.seq.segments attribute)
- tlimtuple, list
Limits of time axis (min, max) (i.e., x-axis). Default is None, in which case entire range of t will be plotted.
- flimtuple, list
limits of frequency axis (min, max) (i.e., x-axis). Default is None, in which case entire range of f will be plotted.
- y_segmentsfloat
Height at which segments should be plotted. Default is 0.5 (assumes y-limits of 0 and 1).
- h_segmentsfloat, int
Height of rectangles that represent segments. Default is 0.4.
- y_labelsfloat
Height on y-axis at which segment labels (if any) are plotted. Default is 0.4.
- label_color_mapdict, optional
A
dict
that maps string labels to colors (that are valid color arguments for matplotlib).- pcolormesh_kwargsdict
Keyword arguments that will get passed to
matplotlib.axes.Axes.pcolormesh()
when using that method to plot spectrogram.- text_kwargsdict
keyword arguments for
matplotlib.axes.Axes.text()
. Passed to the functionvocalpy.plot.annot.labels()
that plots labels using Axes.text method. Defaults are defined asvocalpy.plot.annot.DEFAULT_TEXT_KWARGS
.
- Returns:
- fig, axes
Matplotlib Figure and
dict
of Axes instances. The axes containing the spectrogram isaxes['spect']
and the axes containing the annotated segments isaxes['annot']
.
Examples
>>> bfsongrepo = voc.example("bfsongrepo") >>> spect_maker = voc.SpectrogramMaker(callback=voc.spectrogram) >>> spects = spect_maker.make(bfsongrepo.sound) >>> voc.plot.annotated_spectrogram(spect=spects[0], annot=bfsongrepo.annotation[0], tlim = [3.2, 3.9], flim=[500,12500])