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 72b06a3

Browse filesBrowse files
committed
Only label vertical lines in acorr
1 parent 31e851a commit 72b06a3
Copy full SHA for 72b06a3

File tree

Expand file treeCollapse file tree

1 file changed

+8
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-8
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,6 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
16891689
16901690
Parameters
16911691
----------
1692-
16931692
x : sequence of scalars of length n
16941693
16951694
y : sequence of scalars of length n
@@ -1743,10 +1742,10 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
17431742
x = detrend(np.asarray(x))
17441743
y = detrend(np.asarray(y))
17451744

1746-
c = np.correlate(x, y, mode=2)
1745+
correls = np.correlate(x, y, mode=2)
17471746

17481747
if normed:
1749-
c /= np.sqrt(np.dot(x, x) * np.dot(y, y))
1748+
correls /= np.sqrt(np.dot(x, x) * np.dot(y, y))
17501749

17511750
if maxlags is None:
17521751
maxlags = Nx - 1
@@ -1756,18 +1755,19 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
17561755
'positive < %d' % Nx)
17571756

17581757
lags = np.arange(-maxlags, maxlags + 1)
1759-
c = c[Nx - 1 - maxlags:Nx + maxlags]
1758+
correls = correls[Nx - 1 - maxlags:Nx + maxlags]
17601759

17611760
if usevlines:
1762-
a = self.vlines(lags, [0], c, **kwargs)
1761+
a = self.vlines(lags, [0], correls, **kwargs)
1762+
# Make label empty so only vertical lines get a legend entry
1763+
kwargs['label'] = ''
17631764
b = self.axhline(**kwargs)
17641765
else:
1765-
17661766
kwargs.setdefault('marker', 'o')
17671767
kwargs.setdefault('linestyle', 'None')
1768-
a, = self.plot(lags, c, **kwargs)
1768+
a, = self.plot(lags, correls, **kwargs)
17691769
b = None
1770-
return lags, c, a, b
1770+
return lags, correls, a, b
17711771

17721772
#### Specialized plotting
17731773

0 commit comments

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