Skip to content

Commit ba0d1a3

Browse files
committed
add flexibility to save_fm_report()
add all arguments that can be passed to plts.fm.plot_fm(). adresses #256.
1 parent baed4d5 commit ba0d1a3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

fooof/core/reports.py

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

2424
@check_dependency(plt, 'matplotlib')
25-
def save_report_fm(fm, file_name, file_path=None, plt_log=False):
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):
2628
"""Generate and save out a PDF report for a power spectrum model fit.
2729
2830
Parameters
@@ -33,8 +35,17 @@ def save_report_fm(fm, file_name, file_path=None, plt_log=False):
3335
Name to give the saved out file.
3436
file_path : str, optional
3537
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.
3643
plt_log : bool, optional, default: False
3744
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.
3849
"""
3950

4051
# Set up outline figure, using gridspec
@@ -51,7 +62,9 @@ def save_report_fm(fm, file_name, file_path=None, plt_log=False):
5162

5263
# Second - data plot
5364
ax1 = plt.subplot(grid[1])
54-
fm.plot(plt_log=plt_log, ax=ax1)
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)
5568

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

0 commit comments

Comments
 (0)