FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Bugfix: enable picking of AsteriskCollection instances by efiring · Pull Request #72 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) No extension  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 3 additions & 0 deletions CHANGELOG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2011-04-03 Fixed broken pick interface to AsteriskCollection objects
used by scatter. - EF

2011-03-29 Wrapped ViewVCCachedServer definition in a factory function.
This class now inherits from urllib2.HTTPSHandler in order
to fetch data from github, but HTTPSHandler is not defined
Expand Down
38 changes: 30 additions & 8 deletions lib/matplotlib/collections.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(self,
self.set_linewidth(linewidths)
self.set_linestyle(linestyles)
self.set_antialiased(antialiaseds)
self.set_pickradius(pickradius)
self.set_urls(urls)


Expand All @@ -105,7 +106,6 @@ def __init__(self,
else:
self._uniform_offsets = offsets

self._pickradius = pickradius
self.update(kwargs)
self._paths = None

Expand Down Expand Up @@ -221,26 +221,48 @@ def draw(self, renderer):
gc.restore()
renderer.close_group(self.__class__.__name__)

def set_pickradius(self, pr):
self._pickradius = pr

def get_pickradius(self):
return self._pickradius

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Noticing that this, Line and Axis all have a pickradius, maybe it belongs in Artist? Doesn't necessarily have to be done for this pull, but it seems like a useful refactoring to make.

def contains(self, mouseevent):
"""
Test whether the mouse event occurred in the collection.

Returns True | False, ``dict(ind=itemlist)``, where every
item in itemlist contains the event.
"""
if callable(self._contains): return self._contains(self,mouseevent)
if not self.get_visible(): return False,{}
if callable(self._contains):
return self._contains(self,mouseevent)

if not self.get_visible():
return False, {}

if self._picker is True: # the Boolean constant, not just nonzero or 1
pickradius = self._pickradius
else:
try:
pickradius = float(self._picker)
except TypeError:
# This should not happen if "contains" is called via
# pick, the normal route; the check is here in case
# it is called through some unanticipated route.
warnings.warn(
"Collection picker %s could not be converted to float"
% self._picker)
pickradius = self._pickradius

transform, transOffset, offsets, paths = self._prepare_points()

ind = mpath.point_in_path_collection(
mouseevent.x, mouseevent.y, self._pickradius,
mouseevent.x, mouseevent.y, pickradius,
transform.frozen(), paths, self.get_transforms(),
offsets, transOffset, len(self._facecolors)>0)
return len(ind)>0,dict(ind=ind)
offsets, transOffset, pickradius <= 0)

return len(ind)>0, dict(ind=ind)

def set_pickradius(self,pickradius): self.pickradius = 5
def get_pickradius(self): return self.pickradius

def set_urls(self, urls):
if urls is None:
Expand Down

Back | FazBrowse Home | New Git URL