Skip to content

Avoid quadratic behavior when accumulating stickies. #12546

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 1 commit into from
Oct 17, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 17, 2018

When plotting 10000 lines, this gives a ~10% improvement in performance.
xref #12542.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

When plotting 10000 lines, this gives a ~10% improvement in performance.
@@ -2405,12 +2405,12 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):

if self.use_sticky_edges and (self._xmargin or self._ymargin):
stickies = [artist.sticky_edges for artist in self.get_children()]
x_stickies = sum([sticky.x for sticky in stickies], [])
y_stickies = sum([sticky.y for sticky in stickies], [])
x_stickies = np.array([x for sticky in stickies for x in sticky.x])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

np.isclose is called just below anyways so converting to array here vs just below shouldn't affect performance.

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Seems a fine tweak to me.

@jklymak jklymak merged commit a8dca07 into matplotlib:master Oct 17, 2018
@anntzer anntzer deleted the quadratic-stickies branch October 17, 2018 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants