def __init__(self, lines, drawtype='box', minspanx=None, minspany=None, useblit=False, lineprops=None, rectprops=None, spancoords='data', button=None, maxdist=10, marker_props=None, interactive=False, state_modifier_keys=None): self.verbose = True self.lines = flatten(lines) ax = self.lines[0].axes RectangleSelector.__init__( self, ax, self.select_lines, drawtype, minspanx, minspany, useblit, lineprops, rectprops, spancoords, button, maxdist, marker_props, interactive, state_modifier_keys) hprops = dict(linewidth=10, alpha=0.5, linestyle='-') # marker='s' self.selection = [ np.zeros(l.get_xdata().shape, bool) for l in self.lines ] #Create Line2D for highlighting selected sections self.highlighted = [] for line in self.lines: hline, = ax.plot([], [], color=line.get_color(), **hprops) self.highlighted.append( hline ) self.artists.append( hline ) #enable blitting for the highlighted segments
def get_part(mapping, event): part = getattr(mapping[event.artist], event.part) if event.part in ('stems','caps'): artists = getattr(part, event.partxy) else: artists = part yield from flatten([artists])
def __init__(self, lines): self.lines = flatten(lines) self.ax = ax = self.lines[0].axes self.figure = fig = ax.figure ConnectionMixin.__init__(self, fig) #save the background after the first draw saving = True #print('RAAAR') #print(self.connections) #print(self._connections) #create the position markers self.markers, = ax.plot([], [], **self.marker_props) self.markers.set_zorder(20)
def multirange(*shape): N, dl = flatten(shape) return np.tile(range(dl), (N,1))