Python matplotlib.pyplot.connect() Examples

The following are 9 code examples of matplotlib.pyplot.connect(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib.pyplot , or try the search function .
Example #1
Source File: mpplot.py    From magpy with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def hzfunc(self,label):
        ax = self.hzdict[label]
        num = int(label.replace("plot ",""))
        #print "Selected axis number:", num
        #global mainnum
        self.mainnum = num
        # drawtype is 'box' or 'line' or 'none'
        toggle_selector.RS = RectangleSelector(ax, self.line_select_callback,
                                           drawtype='box', useblit=True,
                                           button=[1,3], # don't use middle button
                                           minspanx=5, minspany=5,
                                           spancoords='pixels',
                                           rectprops = dict(facecolor='red', edgecolor = 'black', alpha=0.2, fill=True))

        #plt.connect('key_press_event', toggle_selector)
        plt.draw() 
Example #2
Source File: PDS_Compute_MTF.py    From PDS_Compute_MTF with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, filename):
        self.filename = filename
        self.image_data = cv2.imread(filename, 0)
        fig_image, current_ax = plt.subplots()
        plt.imshow(self.image_data, cmap='gray')
        eh = EventHandler(self.filename)
        rectangle_selector = RectangleSelector(current_ax,
                                               eh.line_select_callback,
                                               drawtype='box',
                                               useblit=True,
                                               button=[1, 2, 3],
                                               minspanx=5, minspany=5,
                                               spancoords='pixels',
                                               interactive=True)
        plt.connect('key_press_event', eh.event_exit_manager)
        plt.show() 
Example #3
Source File: mpplot.py    From magpy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def markpoints(self, dataarray,keyarray):
        for idx,elem in enumerate(dataarray):
            key = keyarray[idx]
            #print "Selected curve - markpoints:", idx
            #print dataarray[idx]
            if not idx == 0 and not len(elem) == 0 and key in self.keylist: #FLAGKEYLIST:
                #print ( idx, self.axlist[idx-1] )
                ax = self.axlist[idx-1]
                #ax.clear()
                #ax.text(dataarray[0][1],dataarray[1][1], "(%s, %3.2f)"%("Hello",3.67), )
                ax.scatter(dataarray[0].astype('<f8'),elem.astype('<f8'), c='r', zorder=100) #, marker='d', c='r') #, zorder=100)

        #plt.connect('key_press_event', toggle_selector)
        plt.draw() 
Example #4
Source File: show_labels.py    From bdd100k with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def show(self):
        # Read and draw image
        dpi = 80
        w = 16
        h = 9
        self.fig = plt.figure(figsize=(w, h), dpi=dpi)
        self.ax = self.fig.add_axes([0.0, 0.0, 1.0, 1.0], frameon=False)
        if len(self.image_paths) > 1:
            plt.connect('key_release_event', self.next_image)
        self.show_image()
        plt.show() 
Example #5
Source File: show_labels.py    From bdd100k with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def show(self):
        # Read and draw image
        dpi = 80
        w = 16
        h = 9
        self.fig = plt.figure(figsize=(w, h), dpi=dpi)
        self.ax = self.fig.add_axes([0.0, 0.0, 1.0, 1.0], frameon=False)
        # if len(self.image_paths) > 1:
        plt.connect('key_release_event', self.next_image)
        self.show_image()
        plt.show() 
Example #6
Source File: show_labels.py    From 3d-vehicle-tracking with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def show(self):
        # Read and draw image
        dpi = 80
        w = 16
        h = 9
        self.fig = plt.figure(figsize=(w, h), dpi=dpi)
        self.ax = self.fig.add_axes([0.0, 0.0, 1.0, 1.0], frameon=False)
        if len(self.image_paths) > 1:
            plt.connect('key_release_event', self.next_image)
        self.show_image()
        plt.show() 
Example #7
Source File: show_labels.py    From 3d-vehicle-tracking with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def show(self):
        # Read and draw image
        dpi = 80
        w = self.image_width / dpi  # 16
        h = self.image_height / dpi  # 9
        self.fig = plt.figure(figsize=(w, h), dpi=dpi)
        self.ax = self.fig.add_axes([0.0, 0.0, 1.0, 1.0], frameon=False)
        # if len(self.image_paths) > 1:
        plt.connect('key_release_event', self.next_image)
        self.show_image()
        plt.show() 
Example #8
Source File: convert_png2h5.py    From gprMax with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, im, materials):
        """
        Args:
            im (ndarray): Pixels of the image.
            materials (list): To store selected RGB(A) values of selected pixels.
        """
        self.im = im
        self.materials = materials
        plt.connect('button_press_event', self) 
Example #9
Source File: mpplot.py    From magpy with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def startup(self, fig, data):
        print("--------------------------------------------")
        print(" you started the build-in flagging function")
        print("--------------------------------------------")
        print("    -- use mouse to select rectangular areas")
        print("    -- press f for flagging this region")
        print("    --      press 2,3 to change default flag ID")
        print("    -- press l to get some basic data info")
        print("    -- press o to apply an offset")
        print("    -- press h to get all meta information")
        print("    -- press c to close the window and allow saving")

        # Arrays to exchange data
        self.selarray = []
        # Globals
        self.idxar = [] # holds all selected index values
        #mainnum = 1 # holds the selected figure axis

        self.axlist = fig.axes

        # #############################################################
        ## Adding Radiobttons to switch selector between different plot
        # #############################################################

        plt.subplots_adjust(left=0.2)
        axcolor = 'lightgoldenrodyellow'
        rax = plt.axes([0.02, 0.8, 0.10, 0.15])
        rax.patch.set_facecolor(axcolor)

        # create dict and list
        numlst = ['plot '+str(idx+1) for idx,elem in enumerate(self.axlist)]
        ## python 2.7 and higher
        #  self.hzdict = {'plot '+str(idx+1):elem for idx,elem in enumerate(self.axlist)}
        ## python 2.6 and lower
        self.hzdict = dict(('plot '+str(idx+1),elem) for idx,elem in enumerate(self.axlist))
        radio = RadioButtons(rax, numlst)

        # #############################################################
        ## Getting a rectangular selector
        # #############################################################

        toggle_selector.RS = RectangleSelector(self.axlist[0], self.line_select_callback, drawtype='box', useblit=True,button=[1,3],minspanx=5, minspany=5,spancoords='pixels', rectprops = dict(facecolor='red', edgecolor = 'black', alpha=0.2, fill=True))

        plt.connect('key_press_event', self.toggle_selector)

        return radio, self.hzfunc