Skip to content

Commit 3541e51

Browse files
committed
consolidate plotting to spectra funcs in docs
1 parent 0ed7439 commit 3541e51

File tree

6 files changed

+34
-37
lines changed

6 files changed

+34
-37
lines changed

doc/api.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ Plots for visualizing power spectra.
247247
.. autosummary::
248248
:toctree: generated/
249249

250-
plot_spectrum
251250
plot_spectra
252251

253252
Plots for plotting power spectra with shaded regions.
@@ -257,7 +256,6 @@ Plots for plotting power spectra with shaded regions.
257256
.. autosummary::
258257
:toctree: generated/
259258

260-
plot_spectrum_shading
261259
plot_spectra_shading
262260

263261
Plot Model Properties & Parameters

examples/analyses/plot_mne_example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from fooof import FOOOFGroup
3333
from fooof.bands import Bands
3434
from fooof.analysis import get_band_peak_fg
35-
from fooof.plts.spectra import plot_spectrum
35+
from fooof.plts.spectra import plot_spectra
3636

3737
###################################################################################################
3838
# Load & Check MNE Data
@@ -284,10 +284,10 @@ def check_nans(data, nan_policy='zero'):
284284

285285
# Compare the power spectra between low and high exponent channels
286286
fig, ax = plt.subplots(figsize=(8, 6))
287-
plot_spectrum(fg.freqs, fg.get_fooof(np.argmin(exps)).power_spectrum,
288-
ax=ax, label='Low Exponent')
289-
plot_spectrum(fg.freqs, fg.get_fooof(np.argmax(exps)).power_spectrum,
290-
ax=ax, label='High Exponent')
287+
plot_spectra(fg.freqs, fg.get_fooof(np.argmin(exps)).power_spectrum,
288+
ax=ax, label='Low Exponent')
289+
plot_spectra(fg.freqs, fg.get_fooof(np.argmax(exps)).power_spectrum,
290+
ax=ax, label='High Exponent')
291291

292292
###################################################################################################
293293
# Conclusion

examples/plots/plot_power_spectra.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import matplotlib.pyplot as plt
1212

1313
# Import plotting functions
14-
from fooof.plts.spectra import plot_spectrum, plot_spectra
15-
from fooof.plts.spectra import plot_spectrum_shading, plot_spectra_shading
14+
from fooof.plts.spectra import plot_spectra, plot_spectra_shading
1615

1716
# Import simulation utilities for creating test data
1817
from fooof.sim.gen import gen_power_spectrum, gen_group_power_spectra
@@ -59,7 +58,7 @@
5958
#
6059
# First we will start with the core plotting function that plots an individual power spectrum.
6160
#
62-
# The :func:`~.plot_spectrum` function takes in an array of frequency values and a 1d array of
61+
# The :func:`~.plot_spectra` function takes in an array of frequency values and a 1d array of
6362
# of power values, and plots the corresponding power spectrum.
6463
#
6564
# This function, as all the functions in the plotting module, takes in optional inputs
@@ -70,7 +69,7 @@
7069
###################################################################################################
7170

7271
# Create a spectrum plot with a single power spectrum
73-
plot_spectrum(freqs, powers1, log_powers=True)
72+
plot_spectra(freqs, powers1, log_powers=True)
7473

7574
###################################################################################################
7675
# Plotting Multiple Power Spectra
@@ -97,7 +96,7 @@
9796
# In some cases it may be useful to highlight or shade in particular frequency regions,
9897
# for example, when examining power in particular frequency regions.
9998
#
100-
# The :func:`~.plot_spectrum_shading` function takes in a power spectrum and one or more
99+
# The :func:`~.plot_spectra_shading` function takes in a power spectrum and one or more
101100
# shaded regions, and plot the power spectrum with the indicated region shaded.
102101
#
103102
# The same can be done for multiple power spectra with :func:`~.plot_spectra_shading`.
@@ -110,7 +109,7 @@
110109
###################################################################################################
111110

112111
# Plot a single power spectrum, with a shaded region covering alpha
113-
plot_spectrum_shading(freqs, powers1, [8, 12], log_powers=True)
112+
plot_spectra_shading(freqs, powers1, [8, 12], log_powers=True)
114113

115114
###################################################################################################
116115

@@ -157,6 +156,6 @@
157156
fig, ax = plt.subplots(figsize=[12, 8])
158157
plot_spectra_shading(freqs_al, powers_al, [8, 12],
159158
log_powers=True, alpha=0.6, ax=ax)
160-
plot_spectrum(freqs_al10, powers_al10, log_powers=True,
159+
plot_spectra(freqs_al10, powers_al10, log_powers=True,
161160
color='black', linewidth=3, label='10 Hz Alpha', ax=ax)
162161
plt.title('Comparing Alphas', {'fontsize' : 20, 'fontweight' : 'bold'});

motivations/measurements/plot_BandRatios.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from fooof.utils import trim_spectrum
4545
from fooof.sim.gen import gen_power_spectrum
4646
from fooof.sim.utils import set_random_seed
47-
from fooof.plts.spectra import plot_spectrum_shading, plot_spectra_shading
47+
from fooof.plts.spectra import plot_spectra_shading
4848

4949
###################################################################################################
5050

@@ -124,9 +124,9 @@ def calc_band_ratio(freqs, powers, low_band, high_band):
124124
###################################################################################################
125125

126126
# Plot the power spectrum, shading the frequency bands used for the ratio
127-
plot_spectrum_shading(freqs, powers, [bands.theta, bands.beta],
128-
color='black', shade_colors=shade_color,
129-
log_powers=True, linewidth=3.5)
127+
plot_spectra_shading(freqs, powers, [bands.theta, bands.beta],
128+
color='black', shade_colors=shade_color,
129+
log_powers=True, linewidth=3.5)
130130

131131
###################################################################################################
132132

tutorials/plot_01-ModelDescription.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from fooof import FOOOF
4242
from fooof.sim.gen import gen_power_spectrum
4343
from fooof.sim.utils import set_random_seed
44-
from fooof.plts.spectra import plot_spectrum
44+
from fooof.plts.spectra import plot_spectra
4545
from fooof.plts.annotate import plot_annotated_model
4646

4747
###################################################################################################
@@ -81,8 +81,8 @@
8181
###################################################################################################
8282

8383
# Plot one of the example power spectra
84-
plot_spectrum(freqs1, powers1, log_powers=True,
85-
color='black', label='Original Spectrum')
84+
plot_spectra(freqs1, powers1, log_powers=True,
85+
color='black', label='Original Spectrum')
8686

8787
###################################################################################################
8888
# Conceptual Overview

tutorials/plot_03-FOOOFAlgorithm.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# These are used here to demonstrate the algorithm
4242
# You do not need to import these functions for standard usage of the module
4343
from fooof.sim.gen import gen_aperiodic
44-
from fooof.plts.spectra import plot_spectrum
44+
from fooof.plts.spectra import plot_spectra
4545
from fooof.plts.annotate import plot_annotated_peak_search
4646

4747
# Import a utility to download and load example data
@@ -110,10 +110,10 @@
110110

111111
# Plot the initial aperiodic fit
112112
_, ax = plt.subplots(figsize=(12, 10))
113-
plot_spectrum(fm.freqs, fm.power_spectrum, plt_log,
114-
label='Original Power Spectrum', color='black', ax=ax)
115-
plot_spectrum(fm.freqs, init_ap_fit, plt_log, label='Initial Aperiodic Fit',
116-
color='blue', alpha=0.5, linestyle='dashed', ax=ax)
113+
plot_spectra(fm.freqs, fm.power_spectrum, plt_log,
114+
label='Original Power Spectrum', color='black', ax=ax)
115+
plot_spectra(fm.freqs, init_ap_fit, plt_log, label='Initial Aperiodic Fit',
116+
color='blue', alpha=0.5, linestyle='dashed', ax=ax)
117117

118118
###################################################################################################
119119
# Step 2: Flatten the Spectrum
@@ -131,8 +131,8 @@
131131
init_flat_spec = fm.power_spectrum - init_ap_fit
132132

133133
# Plot the flattened the power spectrum
134-
plot_spectrum(fm.freqs, init_flat_spec, plt_log,
135-
label='Flattened Spectrum', color='black')
134+
plot_spectra(fm.freqs, init_flat_spec, plt_log,
135+
label='Flattened Spectrum', color='black')
136136

137137
###################################################################################################
138138
# Step 3: Detect Peaks
@@ -172,7 +172,7 @@
172172
###################################################################################################
173173

174174
# Plot the peak fit: created by re-fitting all of the candidate peaks together
175-
plot_spectrum(fm.freqs, fm._peak_fit, plt_log, color='green', label='Final Periodic Fit')
175+
plot_spectra(fm.freqs, fm._peak_fit, plt_log, color='green', label='Final Periodic Fit')
176176

177177
###################################################################################################
178178
# Step 5: Create a Peak-Removed Spectrum
@@ -188,8 +188,8 @@
188188
###################################################################################################
189189

190190
# Plot the peak removed power spectrum, created by removing peak fit from original spectrum
191-
plot_spectrum(fm.freqs, fm._spectrum_peak_rm, plt_log,
192-
label='Peak Removed Spectrum', color='black')
191+
plot_spectra(fm.freqs, fm._spectrum_peak_rm, plt_log,
192+
label='Peak Removed Spectrum', color='black')
193193

194194
###################################################################################################
195195
# Step 6: Re-fit the Aperiodic Component
@@ -206,10 +206,10 @@
206206

207207
# Plot the final aperiodic fit, calculated on the peak removed power spectrum
208208
_, ax = plt.subplots(figsize=(12, 10))
209-
plot_spectrum(fm.freqs, fm._spectrum_peak_rm, plt_log,
210-
label='Peak Removed Spectrum', color='black', ax=ax)
211-
plot_spectrum(fm.freqs, fm._ap_fit, plt_log, label='Final Aperiodic Fit',
212-
color='blue', alpha=0.5, linestyle='dashed', ax=ax)
209+
plot_spectra(fm.freqs, fm._spectrum_peak_rm, plt_log,
210+
label='Peak Removed Spectrum', color='black', ax=ax)
211+
plot_spectra(fm.freqs, fm._ap_fit, plt_log, label='Final Aperiodic Fit',
212+
color='blue', alpha=0.5, linestyle='dashed', ax=ax)
213213

214214
###################################################################################################
215215
# Step 7: Combine the Full Model Fit
@@ -226,8 +226,8 @@
226226
###################################################################################################
227227

228228
# Plot full model, created by combining the peak and aperiodic fits
229-
plot_spectrum(fm.freqs, fm.fooofed_spectrum_, plt_log,
230-
label='Full Model', color='red')
229+
plot_spectra(fm.freqs, fm.fooofed_spectrum_, plt_log,
230+
label='Full Model', color='red')
231231

232232
###################################################################################################
233233
#

0 commit comments

Comments
 (0)