Skip to content

Commit

Permalink
Doc updates on plts
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed May 28, 2019
1 parent 252b6f3 commit 1d692ad
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 26 deletions.
14 changes: 7 additions & 7 deletions fooof/plts/fg.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Plots for FOOOFGroup object.
"""Plots for the FOOOFGroup object.
Notes
-----
This file contains plotting functions that take as input a FOOOFGroup() object.
This file contains plotting functions that take as input a FOOOFGroup object.
"""

from fooof.core.io import fname, fpath
Expand All @@ -17,11 +17,11 @@

@check_dependency(plt, 'matplotlib')
def plot_fg(fg, save_fig=False, file_name='FOOOF_group_fit', file_path=None):
"""Plots a figure with subplots covering the group results from a FOOOFGroup object.
"""Plots a figure with subplots covering the results from a FOOOFGroup object.
Parameters
----------
fg : FOOOFGroup() object
fg : FOOOFGroup object
FOOOFGroup object, containing results from fitting a group of power spectra.
save_fig : boolean, optional, default: False
Whether to save out a copy of the plot.
Expand Down Expand Up @@ -59,7 +59,7 @@ def plot_fg_ap(fg, ax=None):
Parameters
----------
fg : FOOOFGroup() object
fg : FOOOFGroup object
Group object from which to plot data.
ax : matplotlib.Axes, optional
Figure axes upon which to plot.
Expand All @@ -80,7 +80,7 @@ def plot_fg_gf(fg, ax=None):
Parameters
----------
fg : FOOOFGroup() object
fg : FOOOFGroup object
Group object from which to plot data.
ax : matplotlib.Axes, optional
Figure axes upon which to plot.
Expand All @@ -96,7 +96,7 @@ def plot_fg_peak_cens(fg, ax=None):
Parameters
----------
fg : FOOOFGroup() object
fg : FOOOFGroup object
Group object from which to plot data.
ax : matplotlib.Axes, optional
Figure axes upon which to plot.
Expand Down
12 changes: 6 additions & 6 deletions fooof/plts/fm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Plots for FOOOF object.
"""Plots for the FOOOF object.
Notes
-----
This file contains plotting functions that take as input a FOOOF() object.
This file contains plotting functions that take as input a FOOOF object.
"""

import numpy as np
Expand All @@ -24,7 +24,7 @@ def plot_fm(fm, plt_log=False, save_fig=False, file_name='FOOOF_fit', file_path=
Parameters
----------
fm : FOOOF() object
fm : FOOOF object
FOOOF object, containing a power spectrum and (optionally) results from fitting.
plt_log : boolean, optional, default: False
Whether or not to plot the frequency axis in log space.
Expand All @@ -43,7 +43,7 @@ def plot_fm(fm, plt_log=False, save_fig=False, file_name='FOOOF_fit', file_path=

ax = check_ax(ax)

# Log Plot Settings - note that power values in FOOOF objects are already logged
# Log settings. Note that power values in FOOOF objects are already logged
log_freqs = plt_log
log_powers = False

Expand All @@ -69,7 +69,7 @@ def plot_peak_iter(fm):
Parameters
----------
fm : FOOOF() object
fm : FOOOF object
FOOOF object, with model fit, data and settings available.
"""

Expand All @@ -79,7 +79,7 @@ def plot_peak_iter(fm):

for ind in range(n_gauss + 1):

# Note: this forces to create a new plotting axes per iteration
# This forces to create a new plotting axes per iteration
ax = check_ax(None)

plot_spectrum(fm.freqs, flatspec, linewidth=2.0, label='Flattened Spectrum', ax=ax)
Expand Down
7 changes: 4 additions & 3 deletions fooof/plts/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def plot_spectrum(freqs, power_spectrum, log_freqs=False, log_powers=False,
power_spectrum : 1d array
Y-axis data, power values for spectrum to plot.
log_freqs : boolean, optional, default: False
Whether or not to take the log of the power axis before plotting.
Whether or not to take the log of the frequency axis before plotting.
log_powers : boolean, optional, default: False
Whether or not to take the log of the power axis before plotting.
ax : matplotlib.Axes, optional
Expand Down Expand Up @@ -72,10 +72,11 @@ def plot_spectra(freqs, power_spectra, log_freqs=False, log_powers=False, labels
power_spectra : 2d array or list of 1d array
Y-axis data, power values for spectra to plot.
log_freqs : boolean, optional, default: False
Whether or not to take the log of the power axis before plotting.
Whether or not to take the log of the frequency axis before plotting.
log_powers : boolean, optional, default: False
Whether or not to take the log of the power axis before plotting.
labels " "
labels : list of str, optional
Legend labels, for each power spectrum.
ax : matplotlib.Axes, optional
Figure axes upon which to plot.
plot_style : callable, optional, default: style_spectrum_plot
Expand Down
22 changes: 20 additions & 2 deletions fooof/plts/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,32 @@
###################################################################################################

def check_n_style(style_func, *args):
""""Check is a style function has been passed, and apply if so."""
""""Check is a style function has been passed, and apply if so.
Parameters
----------
style_func : callable or None
Function to apply styling to a plot axis.
*args
Inputs to the style plot.
"""

if style_func:
style_func(*args)


def style_spectrum_plot(ax, log_freqs, log_powers):
"""Define to styling for a power spectrum plot."""
"""Define to styling for a power spectrum plot.
Parameters
----------
ax : matplotlib.Axes
Figure axes to apply styling to
log_freqs : boolean
Whether the frequency axis is plotted in log space.
log_powers : boolean
Whether the power axis is plotted in log space.
"""

# Get labels, based on log status
xlabel = 'Frequency' if not log_freqs else 'log(Frequency)'
Expand Down
13 changes: 7 additions & 6 deletions fooof/plts/templates.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Plot templates for the FOOOF module.
Notes:
- These are template plot structures used in reports and/or other plots.
- They are not expected to be used / imported separately.
Notes
-----
These are template plot structures for FOOOF plots and/or reports.
They are not expected to be used directly by the user.
"""

import numpy as np
Expand Down Expand Up @@ -67,12 +68,12 @@ def plot_scatter_2(data_0, label_0, data_1, label_1, title=None, ax=None):
data_0 : 1d array
Data to plot on the first axis.
label_0 : str
Label for the data on the first axis, to be set as the y-axis label.
Label for the data on the first axis, to be set as the axis label.
data_1 : 1d array
Data to plot on the second axis.
label_0 : str
Label for the data on the second axis, to be set as the y-axis label.
title : str
Label for the data on the second axis, to be set as the axis label.
title : str, optional
Title for the plot.
ax : matplotlib.Axes, optional
Figure axes upon which to plot.
Expand Down
4 changes: 2 additions & 2 deletions fooof/plts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Notes
-----
These utility functions should be considered private.
They are not expected to be called directly by the user.
They are not expected to be called directly by the user.
"""

from numpy import log10
Expand All @@ -26,7 +26,7 @@ def set_alpha(n_pts):
Returns
-------
n_pts : float
alpha : float
Value for alpha to use for plotting.
"""

Expand Down

0 comments on commit 1d692ad

Please sign in to comment.