Open an interactive online version by clicking the badge Binder badge or download the notebook.

Interactive plots#

pyfar provides convenient interactive keyboard shortcuts. These allow switching plots, zooming in and out, moving along the x and y-axis, and zooming and moving the range of colormaps.

To do this, you need to use an interactive matplotlib backend. For jupyter notebooks one can for example use the matplotlib magic %matplotlib ipympl.

The available keyboard shortcuts can be queried using

print(pf.plot.shortcuts())

or in the online documentation.

A great use-case for the interactive features is the inspection of a multichannel signal like a head-related impulse responses (HRIR) dataset. pyfar includes a HRIR dataset, which we will use in this notebook. In the following plot you can use ,/. (DE keyboard layouts) or [ and ] (EN keyboard layouts) to cycle through the channels inside the plot. Using Shift + a can be used to toggle between showing all lines again and a single line. Pressing Shift + f will switch to a frequency domain plot, Shift + t will switch back to the time domain.

Warning

Please note, that this will only work in an interactive notebook environment such as binder. You can use the link at the top of the page.

[1]:
import pyfar as pf
import matplotlib.pyplot as plt

# set an interactive backend for matplotlib
%matplotlib ipympl

# load an example HRIR dataset on the horizontal plane
hrirs, sources = pf.signals.files.head_related_impulse_responses(position='horizontal')

pf.plot.use()
plt.figure()
pf.plot.time(hrirs)
Loading head_related_impulse_responses data. This is only done once.
[1]:
<Axes: xlabel='Time in s', ylabel='Amplitude'>

License notice#

This notebook © 2024 by the pyfar developers is licensed under CC BY 4.0

CC BY Large

Watermark#