'Callback for mouse button release in zoom to rect mode.'

def release_zoom(self, event):

    for zoom_id in self._ids_zoom:
        self.canvas.mpl_disconnect(zoom_id)
    self._ids_zoom = []
    self.remove_rubberband()
    if (not self._xypress):
        return
    last_a = []
    for cur_xypress in self._xypress:
        (x, y) = (event.x, event.y)
        (lastx, lasty, a, ind, view) = cur_xypress
        if (((abs((x - lastx)) < 5) and (self._zoom_mode != u'y')) or ((abs((y - lasty)) < 5) and (self._zoom_mode != u'x'))):
            self._xypress = None
            self.release(event)
            self.draw()
            return
        (twinx, twiny) = (False, False)
        if last_a:
            for la in last_a:
                if a.get_shared_x_axes().joined(a, la):
                    twinx = True
                if a.get_shared_y_axes().joined(a, la):
                    twiny = True
        last_a.append(a)
        if (self._button_pressed == 1):
            direction = u'in'
        elif (self._button_pressed == 3):
            direction = u'out'
        else:
            continue
        a._set_view_from_bbox((lastx, lasty, x, y), direction, self._zoom_mode, twinx, twiny)
    self.draw()
    self._xypress = None
    self._button_pressed = None
    self._zoom_mode = None
    self.push_current()
    self.release(event)
