Skip to content

Commit 60f3295

Browse files
committed
add plot_kwargs to report methods
**plot_kwargs added to FOOOF.report, FOOOF.save_report, and save_report_fm. FOOOF.plot and plot_fm already had a plot_kwargs argument; however, this argument was not accessed in plot_fm so it was removed.
1 parent 6f185a6 commit 60f3295

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

fooof/core/reports.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
###################################################################################################
2323

2424
@check_dependency(plt, 'matplotlib')
25-
def save_report_fm(fm, file_name, file_path=None, plot_peaks=None, plot_aperiodic=True,
26-
plt_log=True, add_legend=True, data_kwargs=None, model_kwargs=None,
27-
aperiodic_kwargs=None, peak_kwargs=None):
25+
def save_report_fm(fm, file_name, file_path=None, plt_log=True, **plot_kwargs):
2826
"""Generate and save out a PDF report for a power spectrum model fit.
2927
3028
Parameters
@@ -35,17 +33,10 @@ def save_report_fm(fm, file_name, file_path=None, plot_peaks=None, plot_aperiodi
3533
Name to give the saved out file.
3634
file_path : str, optional
3735
Path to directory to save to. If None, saves to current directory.
38-
plot_peaks : None or {'shade', 'dot', 'outline', 'line'}, optional
39-
What kind of approach to take to plot peaks. If None, peaks are not specifically plotted.
40-
Can also be a combination of approaches, separated by '-', for example: 'shade-line'.
41-
plot_aperiodic : boolean, optional, default: True
42-
Whether to plot the aperiodic component of the model fit.
4336
plt_log : bool, optional, default: False
4437
Whether or not to plot the frequency axis in log space.
45-
add_legend : boolean, optional, default: False
46-
Whether to add a legend describing the plot components.
47-
data_kwargs, model_kwargs, aperiodic_kwargs, peak_kwargs : None or dict, optional
48-
Keyword arguments to pass into the plot call for each plot element.
38+
plot_kwargs : keyword arguments
39+
Keyword arguments to pass into the plot method.
4940
"""
5041

5142
# Set up outline figure, using gridspec
@@ -62,9 +53,7 @@ def save_report_fm(fm, file_name, file_path=None, plot_peaks=None, plot_aperiodi
6253

6354
# Second - data plot
6455
ax1 = plt.subplot(grid[1])
65-
fm.plot(plot_peaks=plot_peaks, plot_aperiodic=plot_aperiodic, plt_log=plt_log, add_legend=add_legend,
66-
ax=ax1, data_kwargs=data_kwargs, model_kwargs=model_kwargs, aperiodic_kwargs=aperiodic_kwargs,
67-
peak_kwargs=peak_kwargs)
56+
fm.plot(plt_log=plt_log, ax=ax1, **plot_kwargs)
6857

6958
# Third - FOOOF settings
7059
ax2 = plt.subplot(grid[2])

fooof/objs/fit.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def add_results(self, fooof_result):
372372
self._check_loaded_results(fooof_result._asdict())
373373

374374

375-
def report(self, freqs=None, power_spectrum=None, freq_range=None, plt_log=False):
375+
def report(self, freqs=None, power_spectrum=None, freq_range=None, plt_log=False, **plot_kwargs):
376376
"""Run model fit, and display a report, which includes a plot, and printed results.
377377
378378
Parameters
@@ -386,14 +386,16 @@ def report(self, freqs=None, power_spectrum=None, freq_range=None, plt_log=False
386386
If not provided, fits across the entire given range.
387387
plt_log : bool, optional, default: False
388388
Whether or not to plot the frequency axis in log space.
389+
**plot_kwargs
390+
Keyword arguments to pass into the plot method.
389391
390392
Notes
391393
-----
392394
Data is optional, if data has already been added to the object.
393395
"""
394396

395397
self.fit(freqs, power_spectrum, freq_range)
396-
self.plot(plt_log=plt_log)
398+
self.plot(plt_log=plt_log, **plot_kwargs)
397399
self.print_results(concise=False)
398400

399401

@@ -642,9 +644,9 @@ def plot(self, plot_peaks=None, plot_aperiodic=True, plt_log=False,
642644

643645

644646
@copy_doc_func_to_method(save_report_fm)
645-
def save_report(self, file_name, file_path=None, plt_log=False):
647+
def save_report(self, file_name, file_path=None, plt_log=False, **plot_kwargs):
646648

647-
save_report_fm(self, file_name, file_path, plt_log)
649+
save_report_fm(self, file_name, file_path, plt_log, **plot_kwargs)
648650

649651

650652
@copy_doc_func_to_method(save_fm)

fooof/plts/fm.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
@check_dependency(plt, 'matplotlib')
2828
def plot_fm(fm, plot_peaks=None, plot_aperiodic=True, plt_log=False, add_legend=True,
2929
save_fig=False, file_name=None, file_path=None, ax=None, data_kwargs=None,
30-
model_kwargs=None, aperiodic_kwargs=None, peak_kwargs=None, **plot_kwargs):
30+
model_kwargs=None, aperiodic_kwargs=None, peak_kwargs=None):
3131
"""Plot the power spectrum and model fit results from a FOOOF object.
3232
3333
Parameters
@@ -53,8 +53,6 @@ def plot_fm(fm, plot_peaks=None, plot_aperiodic=True, plt_log=False, add_legend=
5353
Figure axes upon which to plot.
5454
data_kwargs, model_kwargs, aperiodic_kwargs, peak_kwargs : None or dict, optional
5555
Keyword arguments to pass into the plot call for each plot element.
56-
**plot_kwargs
57-
Keyword arguments to pass into the ``style_plot``.
5856
5957
Notes
6058
-----

0 commit comments

Comments
 (0)