Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] - Add colorbar to time-frequency plot #341

Merged
merged 5 commits into from
Dec 18, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
MODULE_NAME: neurodsp
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
9 changes: 8 additions & 1 deletion neurodsp/plts/timefrequency.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Plotting functions for neurodsp.timefrequency."""

import numpy as np
import matplotlib.pyplot as plt

from neurodsp.plts.style import style_plot
from neurodsp.plts.utils import check_ax, savefig
Expand All @@ -10,7 +11,8 @@

@savefig
@style_plot
def plot_timefrequency(times, freqs, powers, x_ticks=5, y_ticks=5, ax=None, **kwargs):
def plot_timefrequency(times, freqs, powers, x_ticks=5, y_ticks=5,
colorbar=True, ax=None, **kwargs):
"""Plot a time-frequency representation of data.

Parameters
Expand All @@ -26,6 +28,8 @@ def plot_timefrequency(times, freqs, powers, x_ticks=5, y_ticks=5, ax=None, **kw
Defines the tick labels to add to the plot.
If int, is the number of evenly sampled labels to add to the plot.
If array_like, is a set of labels to add to the plot.
colorbar : bool, optional, default: True
Whether to add a colorbar to the plot.
ax : matplotlib.Axes, optional
Figure axes upon which to plot.
**kwargs
Expand Down Expand Up @@ -70,3 +74,6 @@ def plot_timefrequency(times, freqs, powers, x_ticks=5, y_ticks=5, ax=None, **kw
else:
y_ticks_pos = [np.argmin(np.abs(freqs - val)) for val in y_ticks]
ax.set(yticks=y_ticks_pos, yticklabels=y_ticks)

if colorbar:
plt.colorbar(ax.images[0])
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""NeuroDSP setup script."""
"""Setup script for neurodsp."""

import os
from setuptools import setup, find_packages
Expand Down Expand Up @@ -51,11 +51,12 @@
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
],
platforms = 'any',
project_urls = {
'Documentation' : 'https://neurodsp-tools.github.io/',
'Bug Reports' : 'https://github.com/neurodsp-tools/neurodsp/issues',
'Source' : 'https://github.com/neurodsp-tools/neurodsp'
'Source' : 'https://github.com/neurodsp-tools/neurodsp',
},
)