def pick(self, x, y, epsilon=5): """ Return the artist at location x,y with an error tolerance epsilon (in pixels) """ clickBBox = Bound2D(x-epsilon/2, y-epsilon/2, epsilon, epsilon) draw_bbox(self.figure.dpi, clickBBox, self.figure.renderer) def over_text(t): bbox = t.get_window_extent(self.figure.renderer) return clickBBox.overlap(bbox) def over_line(line): # can't use the line bbox because it covers the entire extent # of the line xdata = line.transx.positions(line.get_xdata()) ydata = line.transy.positions(line.get_ydata()) distances = sqrt((x-xdata)**2 + (y-ydata)**2) return min(distances)<epsilon for ax in self.figure.axes: for line in ax.get_lines(): if over_line(line): self.select_line(line) return text = ax.get_xticklabels() text.extend( ax.get_yticklabels() ) for t in text: if over_text(t): self.select_text(t) return
def pick(self, x, y, epsilon=5): """ Return the artist at location x,y with an error tolerance epsilon (in pixels) """ clickBBox = lbwh_to_bbox(x - epsilon / 2, y - epsilon / 2, epsilon, epsilon) draw_bbox(clickBBox, self.renderer) def over_text(t): bbox = t.get_window_extent(self.renderer) return clickBBox.overlaps(bbox) def over_line(line): # can't use the line bbox because it covers the entire extent # of the line trans = line.get_transform() xdata, ydata = trans.numerix_x_y(line.get_xdata(), line.get_ydata()) distances = sqrt((x - xdata) ** 2 + (y - ydata) ** 2) return amin(distances) < epsilon for ax in self.figure.axes: for line in ax.get_lines(): if over_line(line): self.select_line(line) return text = ax.get_xticklabels() text.extend(ax.get_yticklabels()) for t in text: if over_text(t): self.select_text(t) return
def pick(self, x, y, epsilon=5): """ Return the artist at location x,y with an error tolerance epsilon (in pixels) """ clickBBox = Bound2D(x - epsilon / 2, y - epsilon / 2, epsilon, epsilon) draw_bbox(self.figure.dpi, clickBBox, self.figure.renderer) def over_text(t): bbox = t.get_window_extent(self.figure.renderer) return clickBBox.overlap(bbox) def over_line(line): # can't use the line bbox because it covers the entire extent # of the line xdata = line.transx.positions(line.get_xdata()) ydata = line.transy.positions(line.get_ydata()) distances = sqrt((x - xdata)**2 + (y - ydata)**2) return min(distances) < epsilon for ax in self.figure.axes: for line in ax.get_lines(): if over_line(line): self.select_line(line) return text = ax.get_xticklabels() text.extend(ax.get_yticklabels()) for t in text: if over_text(t): self.select_text(t) return
def pick(self, x, y, epsilon=5): """ Return the artist at location x,y with an error tolerance epsilon (in pixels) """ clickBBox = lbwh_to_bbox(x - epsilon / 2, y - epsilon / 2, epsilon, epsilon) draw_bbox(clickBBox, self.renderer) def over_text(t): bbox = t.get_window_extent(self.renderer) return clickBBox.overlaps(bbox) def over_line(line): # can't use the line bbox because it covers the entire extent # of the line trans = line.get_transform() xdata, ydata = trans.numerix_x_y(line.get_xdata(), line.get_ydata()) distances = sqrt((x - xdata)**2 + (y - ydata)**2) return amin(distances) < epsilon for ax in self.figure.axes: for line in ax.get_lines(): if over_line(line): self.select_line(line) return text = ax.get_xticklabels() text.extend(ax.get_yticklabels()) for t in text: if over_text(t): self.select_text(t) return