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

Only label vertical lines in acorr #9945

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

Merged
merged 2 commits into from
Dec 7, 2017
Merged
Changes from 1 commit
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
16 changes: 8 additions & 8 deletions 16 lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,6 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,

Parameters
----------

x : sequence of scalars of length n

y : sequence of scalars of length n
Expand Down Expand Up @@ -1743,10 +1742,10 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
x = detrend(np.asarray(x))
y = detrend(np.asarray(y))

c = np.correlate(x, y, mode=2)
correls = np.correlate(x, y, mode=2)

if normed:
c /= np.sqrt(np.dot(x, x) * np.dot(y, y))
correls /= np.sqrt(np.dot(x, x) * np.dot(y, y))

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

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

if usevlines:
a = self.vlines(lags, [0], c, **kwargs)
a = self.vlines(lags, [0], correls, **kwargs)
# Make label empty so only vertical lines get a legend entry
kwargs['label'] = ''
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to kwargs.pop('label', '') so that if the user has not passed in a label the axhline does the default thing?

b = self.axhline(**kwargs)
else:

kwargs.setdefault('marker', 'o')
kwargs.setdefault('linestyle', 'None')
a, = self.plot(lags, c, **kwargs)
a, = self.plot(lags, correls, **kwargs)
b = None
return lags, c, a, b
return lags, correls, a, b

#### Specialized plotting

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.