-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #343 from neurodsp-tools/mlplts
[ENH] - Plotting updates
- Loading branch information
Showing
11 changed files
with
305 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Plotting functions for neurodsp.aperiodic.""" | ||
|
||
from neurodsp.plts.style import style_plot | ||
from neurodsp.plts.utils import check_ax, savefig, prepare_multi_plot | ||
|
||
#################################################################################################### | ||
#################################################################################################### | ||
|
||
@savefig | ||
@style_plot | ||
def plot_autocorr(timepoints, autocorrs, labels=None, colors=None, ax=None, **kwargs): | ||
"""Plot autocorrelation results. | ||
Parameters | ||
---------- | ||
timepoints : 1d array | ||
Time points, in samples, at which autocorrelations are computed. | ||
autocorrs : array | ||
Autocorrelation values, across time lags. | ||
labels : str or list of str, optional | ||
Labels for each time series. | ||
colors : str or list of str | ||
Colors to use to plot lines. | ||
ax : matplotlib.Axes, optional | ||
Figure axes upon which to plot. | ||
**kwargs | ||
Keyword arguments for customizing the plot. | ||
""" | ||
|
||
ax = check_ax(ax, figsize=kwargs.pop('figsize', (6, 5))) | ||
|
||
for time, ac, label, color in zip(*prepare_multi_plot(timepoints, autocorrs, labels, colors)): | ||
ax.plot(time, ac, label=label, color=color) | ||
|
||
ax.set(xlabel='Lag (Samples)', ylabel='Autocorrelation') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Tests for neurodsp.plts.aperiodic.""" | ||
|
||
from neurodsp.aperiodic.autocorr import compute_autocorr | ||
|
||
from neurodsp.tests.settings import TEST_PLOTS_PATH, FS | ||
from neurodsp.tests.tutils import plot_test | ||
|
||
from neurodsp.plts.aperiodic import * | ||
|
||
################################################################################################### | ||
################################################################################################### | ||
|
||
def tests_plot_autocorr(tsig, tsig_comb): | ||
|
||
times1, acs1 = compute_autocorr(tsig, max_lag=150) | ||
times2, acs2 = compute_autocorr(tsig_comb, max_lag=150) | ||
|
||
plot_autocorr(times1, acs1, | ||
save_fig=True, file_path=TEST_PLOTS_PATH, | ||
file_name='test_plot_autocorr-1.png') | ||
|
||
plot_autocorr([times1, times2], [acs1, acs2], | ||
labels=['first', 'second'], colors=['k', 'r'], | ||
save_fig=True, file_path=TEST_PLOTS_PATH, | ||
file_name='test_plot_autocorr-2.png') |
Oops, something went wrong.