8000 FIX Removes code that does work from the axes module by NelleV · Pull Request #1569 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX Removes code that does work from the axes module #1569

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
Dec 7, 2012
Merged
Changes from all commits
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
FIX Removes code that does work from the axes module
closes #1465
  • Loading branch information
NelleV committed Dec 7, 2012
commit 465256069ff32b289d1790bcd1e00cb45c24304f
79 changes: 5 additions & 74 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def set_default_color_cycle(clist):
"""
rcParams['axes.color_cycle'] = clist
warnings.warn("Set rcParams['axes.color_cycle'] directly",
DeprecationWarning)
DeprecationWarning)


class _process_plot_var_args(object):
Expand Down Expand Up @@ -271,9 +271,9 @@ def _makeline(self, x, y, kw, kwargs):
# (can't use setdefault because it always evaluates
# its second argument)
seg = mlines.Line2D(x, y,
axes=self.axes,
**kw
)
axes=self.axes,
**kw
)
self.set_lineprops(seg, **kwargs)
return seg

Expand Down Expand Up @@ -3196,76 +3196,7 @@ def pick(self, *args):
'see API_CHANGES in the src distribution')
martist.Artist.pick(self, args[0])

def __pick(self, x, y, trans=None, among=None):
"""
Return the artist under point that is closest to the *x*, *y*.
If *trans* is *None*, *x*, and *y* are in window coords,
(0,0 = lower left). Otherwise, *trans* is a
:class:`~matplotlib.transforms.Transform` that specifies the
coordinate system of *x*, *y*.

The selection of artists from amongst which the pick function
finds an artist can be narrowed using the optional keyword
argument *among*. If provided, this should be either a sequence
of permitted artists or a function taking an artist as its
argument and returning a true value if and only if that artist
can be selected.

Note this algorithm calculates distance to the vertices of the
polygon, so if you want to pick a patch, click on the edge!
"""
# MGDTODO: Needs updating
if trans is not None:
xywin = trans.transform_point((x, y))
else:
xywin = x, y

def dist_points(p1, p2):
'return the distance between two points'
x1, y1 = p1
x2, y2 = p2
return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

def dist_x_y(p1, x, y):
'*x* and *y* are arrays; return the distance to the closest point'
x1, y1 = p1
return min(np.sqrt((x - x1) ** 2 + (y - y1) ** 2))

def dist(a):
if isinstance(a, Text):
bbox = a.get_window_extent()
l, b, w, h = bbox.bounds
verts = (l, b), (l, b + h), (l + w, b + h), (l + w, b)
xt, yt = zip(*verts)
elif isinstance(a, Patch):
path = a.get_path()
tverts = a.get_transform().transform_path(path)
xt, yt = zip(*tverts)
elif isinstance(a, mlines.Line2D):
xdata = a.get_xdata(orig=False)
ydata = a.get_ydata(orig=False)
xt, yt = a.get_transform().numerix_x_y(xdata, ydata)

return dist_x_y(xywin, np.asarray(xt), np.asarray(yt))

artists = self.lines + self.patches + self.texts
if callable(among):
# FIXME test is not defined
artists = filter(test, artists)
elif iterable(among):
amongd = dict([(k, 1) for k in among])
artists = [a for a in artists if a in amongd]
elif among is None:
pass
else:
raise ValueError('among must be callable or iterable')
if not len(artists):
return None
ds = [(dist(a), a) for a in artists]
ds.sort()
return ds[0][1]

#### Labelling
### Labelling

def get_title(self):
"""
Expand Down
0