Plot the amplitude traces of a set of dipoles. Parameters ---------- dipoles : list of instance of Dipole The dipoles whose amplitudes should be shown. colors : list of color | None Color to plot with each dipole. If None default colors are used. show : bool
(dipoles, colors=None, show=True)
| 975 | |
| 976 | |
| 977 | def plot_dipole_amplitudes(dipoles, colors=None, show=True): |
| 978 | """Plot the amplitude traces of a set of dipoles. |
| 979 | |
| 980 | Parameters |
| 981 | ---------- |
| 982 | dipoles : list of instance of Dipole |
| 983 | The dipoles whose amplitudes should be shown. |
| 984 | colors : list of color | None |
| 985 | Color to plot with each dipole. If None default colors are used. |
| 986 | show : bool |
| 987 | Show figure if True. |
| 988 | |
| 989 | Returns |
| 990 | ------- |
| 991 | fig : matplotlib.figure.Figure |
| 992 | The figure object containing the plot. |
| 993 | |
| 994 | Notes |
| 995 | ----- |
| 996 | .. versionadded:: 0.9.0 |
| 997 | """ |
| 998 | import matplotlib.pyplot as plt |
| 999 | |
| 1000 | if colors is None: |
| 1001 | colors = cycle(_get_color_list()) |
| 1002 | fig, ax = plt.subplots(1, 1, layout="constrained") |
| 1003 | xlim = [np.inf, -np.inf] |
| 1004 | for dip, color in zip(dipoles, colors): |
| 1005 | ax.plot(dip.times, dip.amplitude * 1e9, color=color, linewidth=1.5) |
| 1006 | xlim[0] = min(xlim[0], dip.times[0]) |
| 1007 | xlim[1] = max(xlim[1], dip.times[-1]) |
| 1008 | ax.set(xlim=xlim, xlabel="Time (s)", ylabel="Amplitude (nAm)") |
| 1009 | if show: |
| 1010 | fig.show(warn=False) |
| 1011 | return fig |
| 1012 | |
| 1013 | |
| 1014 | def adjust_axes(axes, remove_spines=("top", "right"), grid=True): |
no test coverage detected