<div dir="ltr">There is something a bit sutble going on here, see the following code:<div><br></div><div><div>import matplotlib.pyplot as plt</div><div>from six.moves import range</div><div>import sys</div><div><br></div><div>from matplotlib.widgets import RectangleSelector</div><div>from matplotlib.widgets import Button</div><div><br></div><div><br></div><div>def main_window(im):</div><div>    ref_holder = dict()</div><div><br></div><div>    def open_figure(event):</div><div>        ax = event.inaxes</div><div>        if ax is None:</div><div>            # Occurs when a region not in an axis is clicked...</div><div>            return</div><div>        for i in range(len(event.canvas.figure.axes)):</div><div>            if event.canvas.figure.axes[i] is ax:</div><div>                ret = show_new_figure(im)</div><div>                ref_holder['last interactive'] = ret</div><div><br></div><div>    fig, ax = plt.subplots()</div><div><br></div><div>    # some code which locates subplots</div><div>    # show images on subplots</div><div>    show_image(ax, im)</div><div><br></div><div>    fig.canvas.mpl_connect('button_press_event', open_figure)</div><div>    plt.show()</div><div><br></div><div>    return fig, ax</div><div><br></div><div><br></div><div>def show_image(ax, im):</div><div>    ax.cla()</div><div>    ax.imshow(im, cmap='gray', interpolation='nearest')</div><div><br></div><div><br></div><div>def show_new_figure(im):</div><div>    fig, ax = plt.subplots(figsize=(10, 10))</div><div><br></div><div>    class Btn(object):</div><div>        def save(self, event):</div><div>            fig.canvas.manager.toolbar.save_figure()</div><div><br></div><div>        def close(self, event):</div><div>            plt.close(fig)</div><div><br></div><div>        def exit(self, event):</div><div>            sys.exit()</div><div><br></div><div>    callback = Btn()</div><div><br></div><div>    ax.imshow(im, cmap='Reds', interpolation='nearest')</div><div><br></div><div>    axSave = plt.axes([0.5, 0.01, 0.1, 0.075])</div><div>    axClose = plt.axes([0.39, 0.01, 0.1, 0.075])</div><div>    axExit = plt.axes([0.6, 0.01, 0.1, 0.075])</div><div><br></div><div>    btnSave = Button(axSave, 'Save')</div><div>    btnSave.on_clicked(callback.save)</div><div>    btnClose = Button(axClose, 'Close')</div><div>    btnClose.on_clicked(callback.close)</div><div>    btnExit = Button(axExit, 'Exit')</div><div>    btnExit.on_clicked(callback.exit)</div><div><br></div><div>    # draw rectangle</div><div>    def line_select_callback(eclick, erelease):</div><div>        'eclick and erelease are the press and release events'</div><div>        x1, y1 = eclick.xdata, eclick.ydata</div><div>        x2, y2 = erelease.xdata, erelease.ydata</div><div>        print("X, Y points: (%3.2f, %3.2f) --> (%3.2f, %3.2f)" %</div><div>              (x1, y1, x2, y2))</div><div><br></div><div>    rs = RectangleSelector(ax, line_select_callback,</div><div>                           drawtype='box', useblit=True,</div><div>                           button=[1, 3],</div><div>                           minspanx=5, minspany=5,</div><div>                           rectprops=dict(facecolor='blue', edgecolor='blue',</div><div>                                          alpha=1, fill=False),</div><div>                           spancoords='pixels')</div><div>    rs.set_active(True)</div><div><br></div><div>    return rs, btnSave, btnClose, btnExit</div></div><div><br></div><div><br></div><div>The critical bit is that the `show_new_figure` function is returning the `widget` objects and `open_figure` is stashing them in a local dictionary.  What is happening is that without holding on to a reference to the widget objects they get garbage collected.  By design, the callback registries only hold on to a weak-ref (that is a reference that will not prevent garbage collection if it is the last reference left), so if you do not keep a reference to the widgets, the get garbage collections and hence do not exist to get the click events.  This is documented in the widget class docstring (ex <a href="http://matplotlib.org/api/widgets_api.html#matplotlib.widgets.Button">http://matplotlib.org/api/widgets_api.html#matplotlib.widgets.Button</a>)</div><div><br></div><div>Tom</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 7, 2016 at 9:52 PM Enkhbayar Erdenee <<a href="mailto:enkhee.data@gmail.com">enkhee.data@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello<br clear="all"><div><br></div><p style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;line-height:22.4px;margin-top:0px!important">I have an issue on widget events. I have created a figure which contains several subplots. When click on one of the subplots, it shows another figure. This new figure contains button and rectangle selector widgets. Until this it works fine. Problem is nothing happens if I click on the buttons or draw rectangle on this new figure. It works well (i mean button onclick, line_select_callback events raise ), if I just create figure not after click the subplots. I do not know what I am doing wrong. Please help me.</p><p style="margin-top:0px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;line-height:22.4px;margin-bottom:0px!important">By the way, I am using: <br>matplotlib.<strong>version</strong> : '1.4.3'<br>matplotlib.get_backend() : Qt4Agg<br>python: 2.7.10 | Anaconda 2.3.0 (64-bit)</p><p style="margin-top:0px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;line-height:22.4px;margin-bottom:0px!important"><br></p><p style="margin-top:0px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;line-height:22.4px;margin-bottom:0px!important">Here is the some part of code that I having problem:</p><p style="margin-top:0px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;line-height:22.4px;margin-bottom:0px!important"><br></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">import sys</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">import cv2</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">from matplotlib.widgets import RectangleSelector</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">import matplotlib.pyplot as plt</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">from matplotlib.widgets import Button</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">def main_window():</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    def open_figure(event):</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        ax = event.inaxes</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        if ax is None:</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">            # Occurs when a region not in an axis is clicked...</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">            return</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        for i in xrange(len(event.canvas.figure.axes)):</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">            if event.canvas.figure.axes[i] is ax:</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                plt.ion()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                # Show clicked image on new figure</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                show_new_figure(im)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        fig = plt.figure(1)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        </span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        # some code which locates subplots</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        # show images on subplots</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        show_image(im)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        </span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        fig.canvas.mpl_connect('button_press_event', open_figure)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        plt.show()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">def show_image(im):</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    im = im[:, :, (2, 1, 0)]</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    plt.cla()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    plt.imshow(im)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    plt.axis('off')</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    plt.draw()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    # plt.show()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">def show_new_figure(im):</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    class Btn:</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        def save(self, event):            </span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">            plt.close()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        def close(self, event):</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">            plt.close()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        def exit(self, event):</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">            sys.exit()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    callback = Btn()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    im = im[:, :, (2, 1, 0)]</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    fig2, ax = plt.subplots(figsize=(10, 10))</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    plt.cla()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    plt.imshow(im)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    axSave = plt.axes([0.5, 0.01, 0.1, 0.075])</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    axClose = plt.axes([0.39, 0.01, 0.1, 0.075])</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    axExit = plt.axes([0.6, 0.01, 0.1, 0.075])</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    btnSave = Button(axSave, 'Save')</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    btnSave.on_clicked(callback.save)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    btnClose = Button(axClose, 'Close')</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    btnClose.on_clicked(callback.close)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    btnExit = Button(axExit, 'Exit')</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    btnExit.on_clicked(callback.exit)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    # draw rectangle</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    def line_select_callback(eclick, erelease):</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        'eclick and erelease are the press and release events'</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        x1, y1 = eclick.xdata, eclick.ydata</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        x2, y2 = erelease.xdata, erelease.ydata</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">        print ("X, Y points: (%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2))</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    rs = RectangleSelector(ax, line_select_callback,</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                           drawtype='box', useblit=True,</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                           button=[1, 3],  </span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                           minspanx=5, minspany=5,</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                           rectprops=dict(facecolor='blue', edgecolor='blue',</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                                            alpha=1, fill=False),</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">                           spancoords='pixels')</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    rs.set_active(True)</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    plt.axis('off')</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">    plt.show()</span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px!important"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><span style="font-size:14px;line-height:22.4px">Thank you for consideration.</span></font></p></div>
_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div>