1212from fooof .core .modutils import safe_import , check_dependency
1313from fooof .plts .settings import PLT_FIGSIZES
1414from fooof .plts .style import style_spectrum_plot , style_plot
15- from fooof .plts .utils import check_ax , add_shades , savefig
15+ from fooof .plts .utils import check_ax , add_shades , savefig , check_plot_kwargs
1616
1717plt = safe_import ('.pyplot' , 'matplotlib' )
1818
@@ -36,10 +36,10 @@ def plot_spectra(freqs, power_spectra, log_freqs=False, log_powers=False,
3636 Whether to plot the frequency axis in log spacing.
3737 log_powers : bool, optional, default: False
3838 Whether to plot the power axis in log spacing.
39- labels : list of str, optional, default: None
40- Legend labels for the spectra.
4139 colors : list of str, optional, default: None
4240 Line colors of the spectra.
41+ labels : list of str, optional, default: None
42+ Legend labels for the spectra.
4343 ax : matplotlib.Axes, optional
4444 Figure axes upon which to plot.
4545 **plot_kwargs
@@ -64,15 +64,17 @@ def plot_spectra(freqs, power_spectra, log_freqs=False, log_powers=False,
6464 # Plot
6565 for freqs , powers , color , label in zip (plt_freqs , plt_powers , colors , labels ):
6666
67- # Set plot data, logging if requested
67+ # Set plot data, logging if requested, and collect color, if absent
6868 freqs = np .log10 (freqs ) if log_freqs else freqs
6969 powers = np .log10 (powers ) if log_powers else powers
70+ if color :
71+ plot_kwargs ['color' ] = color
7072
71- ax .plot (freqs , powers , color = color , label = label , ** plot_kwargs )
73+ ax .plot (freqs , powers , label = label , ** plot_kwargs )
7274
7375 style_spectrum_plot (ax , log_freqs , log_powers )
7476
75-
77+
7678@savefig
7779@check_dependency (plt , 'matplotlib' )
7880def plot_spectra_shading (freqs , power_spectra , shades , shade_colors = 'r' ,
0 commit comments