Skip to content

Commit 0a85b2a

Browse files
committed
fix merge
1 parent 0f5d2fa commit 0a85b2a

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

fooof/plts/error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def plot_spectral_error(freqs, error, shade=None, log_freqs=False, ax=None, **pl
4040

4141
plt_freqs = np.log10(freqs) if log_freqs else freqs
4242

43-
plot_spectrum(plt_freqs, error, ax=ax, linewidth=3)
43+
plot_spectra(plt_freqs, error, ax=ax, linewidth=3)
4444

4545
if np.any(shade):
4646
ax.fill_between(plt_freqs, error-shade, error+shade, alpha=0.25)

fooof/plts/spectra.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from fooof.core.modutils import safe_import, check_dependency
1313
from fooof.plts.settings import PLT_FIGSIZES
1414
from 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

1717
plt = 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')
7880
def plot_spectra_shading(freqs, power_spectra, shades, shade_colors='r',

fooof/tests/plts/test_spectra.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
@plot_test
1414
def test_plot_spectra(tfm, tfg, skip_if_no_mpl):
15-
15+
1616
# Test with 1d inputs - 1d freq array and list of 1d power spectra
17-
plot_spectra(tfm.freqs, tfm.power_spectrum,
17+
plot_spectra(tfm.freqs, tfm.power_spectrum,
1818
save_fig=True, file_path=TEST_PLOTS_PATH, file_name='test_plot_spectra_1d.png')
1919

2020
# Test with 1d inputs - 1d freq array and list of 1d power spectra
@@ -37,10 +37,10 @@ def test_plot_spectra(tfm, tfg, skip_if_no_mpl):
3737

3838
@plot_test
3939
def test_plot_spectra_shading(tfm, tfg, skip_if_no_mpl):
40-
41-
plot_spectrum_shading(tfm.freqs, tfm.power_spectrum, shades=[8, 12], add_center=True,
42-
save_fig=True, file_path=TEST_PLOTS_PATH,
43-
file_name='test_plot_spectrum_shading1.png')
40+
41+
plot_spectra_shading(tfm.freqs, tfm.power_spectrum, shades=[8, 12], add_center=True,
42+
save_fig=True, file_path=TEST_PLOTS_PATH,
43+
file_name='test_plot_spectrum_shading1.png')
4444

4545
plot_spectra_shading(tfg.freqs, [tfg.power_spectra[0, :], tfg.power_spectra[1, :]],
4646
shades=[8, 12], add_center=True, save_fig=True, file_path=TEST_PLOTS_PATH,

0 commit comments

Comments
 (0)