From 1d692ad9c7a78ccce2b42a479b7dd3711d444c42 Mon Sep 17 00:00:00 2001 From: TomDonoghue Date: Tue, 28 May 2019 14:22:57 -0700 Subject: [PATCH] Doc updates on plts --- fooof/plts/fg.py | 14 +++++++------- fooof/plts/fm.py | 12 ++++++------ fooof/plts/spectra.py | 7 ++++--- fooof/plts/style.py | 22 ++++++++++++++++++++-- fooof/plts/templates.py | 13 +++++++------ fooof/plts/utils.py | 4 ++-- 6 files changed, 46 insertions(+), 26 deletions(-) diff --git a/fooof/plts/fg.py b/fooof/plts/fg.py index b68781e4..81dfd246 100644 --- a/fooof/plts/fg.py +++ b/fooof/plts/fg.py @@ -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 @@ -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. @@ -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. @@ -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. @@ -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. diff --git a/fooof/plts/fm.py b/fooof/plts/fm.py index 6c6bfa8b..f690cdb3 100644 --- a/fooof/plts/fm.py +++ b/fooof/plts/fm.py @@ -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 @@ -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. @@ -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 @@ -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. """ @@ -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) diff --git a/fooof/plts/spectra.py b/fooof/plts/spectra.py index 445c3e12..8c3bacbb 100644 --- a/fooof/plts/spectra.py +++ b/fooof/plts/spectra.py @@ -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 @@ -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 diff --git a/fooof/plts/style.py b/fooof/plts/style.py index 5440b20f..e7d267d1 100644 --- a/fooof/plts/style.py +++ b/fooof/plts/style.py @@ -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)' diff --git a/fooof/plts/templates.py b/fooof/plts/templates.py index 403ac3d3..731f75f0 100644 --- a/fooof/plts/templates.py +++ b/fooof/plts/templates.py @@ -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 @@ -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. diff --git a/fooof/plts/utils.py b/fooof/plts/utils.py index 03245b8c..b786d048 100644 --- a/fooof/plts/utils.py +++ b/fooof/plts/utils.py @@ -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 @@ -26,7 +26,7 @@ def set_alpha(n_pts): Returns ------- - n_pts : float + alpha : float Value for alpha to use for plotting. """