Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 97d9cd1

Browse filesBrowse files
authored
Merge pull request #16947 from Stefan-Mitic/issue/9100
Fix missing parameter initialization in Axes.specgram()
2 parents 99340e2 + 72597a3 commit 97d9cd1
Copy full SHA for 97d9cd1

File tree

Expand file treeCollapse file tree

2 files changed

+9
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7462,6 +7462,8 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
74627462
Fc = 0 # same default as in mlab._spectral_helper()
74637463
if noverlap is None:
74647464
noverlap = 128 # same default as in mlab.specgram()
7465+
if Fs is None:
7466+
Fs = 2 # same default as in mlab._spectral_helper()
74657467

74667468
if mode == 'complex':
74677469
raise ValueError('Cannot plot a complex specgram')

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4211,6 +4211,13 @@ def test_specgram_angle():
42114211
scale="dB")
42124212

42134213

4214+
def test_specgram_fs_none():
4215+
"""Test axes.specgram when Fs is None, should not throw error."""
4216+
spec, freqs, t, im = plt.specgram(np.ones(300), Fs=None)
4217+
xmin, xmax, freq0, freq1 = im.get_extent()
4218+
assert xmin == 32 and xmax == 96
4219+
4220+
42144221
@image_comparison(
42154222
["psd_freqs.png", "csd_freqs.png", "psd_noise.png", "csd_noise.png"],
42164223
remove_text=True, tol=0.002)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.