8000 [MNT] - Update name of points plots by TomDonoghue · Pull Request #391 · fooof-tools/fooof · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions specparam/plts/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from specparam.modutils.dependencies import safe_import, check_dependency
from specparam.utils.select import find_first_ind
from specparam.plts.settings import PLT_FIGSIZES
from specparam.plts.templates import plot_scatter_1, plot_scatter_2, plot_hist
from specparam.plts.templates import plot_points_1, plot_points_2, plot_hist
from specparam.plts.utils import savefig
from specparam.plts.style import style_plot

Expand Down Expand Up @@ -43,17 +43,17 @@ def plot_group_model(group, **plot_kwargs):
fig = plt.figure(figsize=plot_kwargs.pop('figsize', PLT_FIGSIZES['group']))
gs = gridspec.GridSpec(2, 2, wspace=0.35, hspace=0.35, height_ratios=[1, 1.2])

# Apply scatter kwargs to all subplots
scatter_kwargs = plot_kwargs
scatter_kwargs['all_axes'] = True
# Apply points kwargs to all subplots
points_kwargs = plot_kwargs
points_kwargs['all_axes'] = True

# Aperiodic parameters plot
ax0 = plt.subplot(gs[0, 0])
plot_group_aperiodic(group, ax0, **scatter_kwargs, custom_styler=None)
plot_group_aperiodic(group, ax0, **points_kwargs, custom_styler=None)

# Goodness of fit plot
ax1 = plt.subplot(gs[0, 1])
plot_group_metrics(group, ax1, **scatter_kwargs, custom_styler=None)
plot_group_metrics(group, ax1, **points_kwargs, custom_styler=None)

# Center frequencies plot
ax2 = plt.subplot(gs[1, :])
Expand All @@ -64,7 +64,7 @@ def plot_group_model(group, **plot_kwargs):
@style_plot
@check_dependency(plt, 'matplotlib')
def plot_group_aperiodic(group, ax=None, **plot_kwargs):
"""Plot aperiodic fit parameters, in a scatter plot.
"""Plot aperiodic fit parameters.

Parameters
----------
Expand All @@ -77,19 +77,19 @@ def plot_group_aperiodic(group, ax=None, **plot_kwargs):
"""

if group.modes.aperiodic.name == 'knee':
plot_scatter_2(group.results.get_params('aperiodic', 'exponent'), 'Exponent',
group.results.get_params('aperiodic', 'knee'), 'Knee',
'Aperiodic Parameters', ax=ax)
plot_points_2(group.results.get_params('aperiodic', 'exponent'), 'Exponent',
group.results.get_params('aperiodic', 'knee'), 'Knee',
'Aperiodic Parameters', ax=ax)
else:
plot_scatter_1(group.results.get_params('aperiodic', 'exponent'), 'Exponent',
'Aperiodic Parameters', ax=ax)
plot_points_1(group.results.get_params('aperiodic', 'exponent'), 'Exponent',
'Aperiodic Parameters', ax=ax)


@savefig
@style_plot
@check_dependency(plt, 'matplotlib')
def plot_group_metrics(group, ax=None, **plot_kwargs):
"""Plot metrics results, in a scatter plot.
"""Plot metrics results.

Parameters
----------
Expand All @@ -105,9 +105,9 @@ def plot_group_metrics(group, ax=None, **plot_kwargs):
ax.set(xticks=[], yticks=[])

if len(group.results.metrics) == 1:
plot_scatter_1(group.results.get_metrics(group.results.metrics.labels[0]),
group.results.metrics.flabels[0],
'Metrics', ax=ax)
plot_points_1(group.results.get_metrics(group.results.metrics.labels[0]),
group.results.metrics.flabels[0],
'Metrics', ax=ax)

elif len(group.results.metrics) >= 2:
ind1 = 0
Expand All @@ -116,11 +116,11 @@ def plot_group_metrics(group, ax=None, **plot_kwargs):
ind1 = find_first_ind(group.results.metrics.labels, 'error')
if 'gof' in group.results.metrics.categories:
ind2 = find_first_ind(group.results.metrics.labels, 'gof')
plot_scatter_2(group.results.get_metrics(group.results.metrics.labels[ind1]),
group.results.metrics.flabels[ind1],
group.results.get_metrics(group.results.metrics.labels[ind2]),
group.results.metrics.flabels[ind2],
'Metrics', ax=ax)
plot_points_2(group.results.get_metrics(group.results.metrics.labels[ind1]),
group.results.metrics.flabels[ind1],
group.results.get_metrics(group.results.metrics.labels[ind2]),
group.results.metrics.flabels[ind2],
'Metrics', ax=ax)


@savefig
Expand Down
12 changes: 6 additions & 6 deletions specparam/plts/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
###################################################################################################

@check_dependency(plt, 'matplotlib')
def plot_scatter_1(data, label=None, title=None, x_val=0, color=None, ax=None, **plot_kwargs):
"""Plot a scatter plot, with a single y-axis.
def plot_points_1(data, label=None, title=None, x_val=0, color=None, ax=None, **plot_kwargs):
"""Plot data values as points, with a single y-axis.

Parameters
----------
Expand Down Expand Up @@ -68,9 +68,9 @@ def plot_scatter_1(data, label=None, title=None, x_val=0, color=None, ax=None, *


@check_dependency(plt, 'matplotlib')
def plot_scatter_2(data_0, label_0, data_1, label_1,
def plot_points_2(data_0, label_0, data_1, label_1,
title=None, colors=None, ax=None, **plot_kwargs):
"""Plot a scatter plot, with two y-axes.
"""Plot data values as points, with two y-axes.

Parameters
----------
Expand Down Expand Up @@ -101,8 +101,8 @@ def plot_scatter_2(data_0, label_0, data_1, label_1,

colors = iter(colors) if isinstance(colors, ITERABLES) else repeat(colors)

plot_scatter_1(data_0, label_0, color=next(colors), ax=ax, **plot_kwargs)
plot_scatter_1(data_1, label_1, x_val=1, color=next(colors), ax=ax1, **plot_kwargs)
plot_points_1(data_0, label_0, color=next(colors), ax=ax, **plot_kwargs)
plot_points_1(data_1, label_1, x_val=1, color=next(colors), ax=ax1, **plot_kwargs)

if title:
ax.set_title(title, fontsize=TITLE_FONTSIZE)
Expand Down
8 changes: 4 additions & 4 deletions specparam/tests/plts/test_templates.py
Original file line number Diff line number Diff line change< 8EFF /th>
Expand Up @@ -14,19 +14,19 @@
###################################################################################################

@plot_test
def test_plot_scatter_1(skip_if_no_mpl):
def test_plot_points_1(skip_if_no_mpl):

data = np.random.randint(0, 100, 100)

plot_scatter_1(data, 'label', 'title')
plot_points_1(data, 'label', 'title')

@plot_test
def test_plot_scatter_2(skip_if_no_mpl):
def test_plot_points_2(skip_if_no_mpl):

data1 = np.random.randint(0, 100, 100)
data2 = np.random.randint(0, 100, 100)

plot_scatter_2(data1, 'label1', data2, 'label2', 'title')
plot_points_2(data1, 'label1', data2, 'label2', 'title')

@plot_test
def test_plot_hist(skip_if_no_mpl):
Expand Down
Loading
0