当前位置: 首页>>代码示例>>Python>>正文


Python Rectangle.set_y方法代码示例

本文整理汇总了Python中matplotlib.patches.Rectangle.set_y方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.set_y方法的具体用法?Python Rectangle.set_y怎么用?Python Rectangle.set_y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.patches.Rectangle的用法示例。


在下文中一共展示了Rectangle.set_y方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Canvas

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]
class Canvas(object):
    def __init__(self, img, name='misc', patch_size=(100, 100),
                 axes=None):
        """

        Parameters
        ----------
        img : 2-D ndarray
            Image to crop from.
        name : str
            Basename of output files for images cropped from this canvas.
        patch_size : tuple of ints
            Size of the patch to crop (rows, cols).
        axes : matplotlib axes object
            Axes on which to draw the patch.

        """
        self.name = name
        self.img = img
        self.x = 0
        self.y = 0
        self.patch_size = patch_size
        h, w = self.patch_size
        self.patch = Rectangle((self.x, self.y), h, w, alpha=0.3)
        self.axes = axes
        axes.add_patch(self.patch)

    def paint(self):
        self.patch.set_x(self.x)
        self.patch.set_y(self.y)

        # This is probably not the right call.  Should call redraw on canvas?
        plt.draw()

        print self.name
开发者ID:Wichard-S,项目名称:supreme,代码行数:37,代码来源:mpl_cut.py

示例2: resizeGraphics

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]
    def resizeGraphics(self, width, height):

        """ It is time to set a magnitude to our currently normalized
            lines, and send them to the figure. Here we assume that
            __normLines & __normPatches are already fully populated. """
        self.__fig.lines   = [] # clear all old lines from figure
        self.__fig.patches = [] # clear all old patches from figure
        self.__xsz = width
        self.__ysz = height

        # scale each text item
        for t in self.__fig.texts:
            t.set_size(self.getTextPointSize(t.gkiTextSzFactor, width, height))

        # scale each line, then apply it to the figure
        for nrln in self.__normLines:
            ll = Line2D([], [])
            ll.update_from(nrln)
            ll.set_data(nrln.get_xdata(True)*self.__xsz,
                        nrln.get_ydata(True)*self.__ysz)
            self.__fig.lines.append(ll)

        # scale each patch, then apply it to the figure
        for nrpa in self.__normPatches:
            rr = Rectangle((0,0),0,0)
            rr.update_from(nrpa)
            rr.set_x(nrpa.get_x()*self.__xsz)
            rr.set_y(nrpa.get_y()*self.__ysz)
            rr.set_width(nrpa.get_width()*self.__xsz)
            rr.set_height(nrpa.get_height()*self.__ysz)
            self.__fig.patches.append(rr)
开发者ID:jhunkeler,项目名称:pyraf,代码行数:33,代码来源:GkiMpl.py

示例3: CustomToolbar

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]

#.........这里部分代码省略.........
    def release_zoom(self, ev):
        if wx.Platform == "__WXMAC__":
            self.to_draw.set_visible(False)
        NavToolbar.release_zoom(self, ev)

    def draw_rubberband(self, event, x0, y0, x1, y1):
        # XOR does not work on MacOS ...
        if wx.Platform != "__WXMAC__":
            NavToolbar.draw_rubberband(self, event, x0, y0, x1, y1)
        else:
            if self.background is not None:
                self.canvas.restore_region(self.background)
            c0, c1 = self.ax.transData.inverted().transform([[x0, y0], [x1, y1]])
            l, b = c0
            r, t = c1
            self.to_draw.set_bounds(l, b, r - l, t - b)
            self.ax.draw_artist(self.to_draw)
            self.canvas.blit(self.ax.bbox)

    def update_background(self):
        """force an update of the background"""
        self.background = self.canvas.copy_from_bbox(self.ax.bbox)

    # Turn on selection
    # TODO: Proper handling of states, actual functionality.
    def _on_custom_select(self, evt):
        #        for id in ['Zoom','Pan']:
        #            self.ToggleTool(self.wx_ids[id], False)
        #        print('Select ROI: %s' % (self.GetToolState(self.wx_ids['ROI'])))
        #        self.ToggleTool(self.wx_ids['ROI'],
        #                self.GetToolState(self.wx_ids['ROI']) )
        self.toggle_selector()

    #        print('Select ROI: %s' % (self.GetToolState(self.wx_ids['ROI'])))

    def onSelect(self, eclick, erelease):
        "eclick and erelease are matplotlib events at press and release"
        #        print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata))
        #        print(' endposition   : (%f, %f)' % (erelease.xdata, erelease.ydata))
        #        print(' used button   : ', eclick.button)
        self.updateROI(
            min(eclick.xdata, erelease.xdata),
            min(eclick.ydata, erelease.ydata),
            abs(eclick.xdata - erelease.xdata),
            abs(eclick.ydata - erelease.ydata),
        )
        if self.canvas.parentFrame.fixedNumberCB.IsChecked():
            # We are working in the fixed-number mode
            # We need to find new roi for this center point
            # The handler will call the update ROI function for us.
            self.canvas.parentFrame.handleROIforN()

    def updateROI(self, x, y, w, h):
        if self.roi is None:
            # print('upd ROI:', x, y, w, h)
            self.roi = Rectangle((x, y), w, h, ls="solid", lw=2, color="r", fill=False, zorder=5)
            self.canvas.figure.axes[0].add_patch(self.roi)
        else:
            self.roi.set_bounds(x, y, w, h)
        self.updateCanvas()

    def toggle_selector(self):
        self.selector.set_active(not self.selector.active)

    def onFixedSize(self, ev):
        self.fixedSize = ev.IsChecked()
        self.updateCanvas()

    def onWidthChange(self, ev):
        if self.roi:
            x = self.roi.get_x()
            w = self.roi.get_width()
            nw = ev.GetValue()
            dw = {"C": (w - nw) / 2, "L": 0, "R": w - nw}[self.canvas.parentFrame.anchorRB.GetStringSelection()[0]]
            self.roi.set_x(x + dw)
            self.roi.set_width(nw)
            self.updateCanvas()

    def onHeightChange(self, ev):
        if self.roi:
            y = self.roi.get_y()
            h = self.roi.get_height()
            nh = ev.GetValue()
            dh = {"C": (h - nh) / 2, "B": 0, "T": h - nh}[self.canvas.parentFrame.anchorRB.GetStringSelection()[-1]]
            self.roi.set_y(y + dh)
            self.roi.set_height(nh)
            self.updateCanvas()

    def updateCanvas(self, redraw=True):
        if self.roi:
            self.canvas.parentFrame.showROI(
                self.roi.get_x(), self.roi.get_y(), self.roi.get_width(), self.roi.get_height()
            )
            self.canvas.parentFrame.setWH(self.roi.get_width(), self.roi.get_height())
            if self.fixedSize:
                self.selector.setSize(self.roi.get_width(), self.roi.get_height())
            else:
                self.selector.setSize()
        if redraw:
            self.draw()
开发者ID:jochym,项目名称:pointsel,代码行数:104,代码来源:pointsel.py

示例4: __init__

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]

#.........这里部分代码省略.........
            xmax, ymax = self.eventrelease.xdata, self.eventrelease.ydata
            # calculate dimensions of box 
            if xmin > xmax: xmin, xmax = xmax, xmin
            if ymin > ymax: ymin, ymax = ymax, ymin
            spanx = xmax - xmin
            spany = ymax - ymin
            xproblems = self.minspanx is not None and spanx < self.minspanx
            yproblems = self.minspany is not None and spany < self.minspany
        # call desired function
        self.onselect()
        self.eventpress = None                # reset the variables to their
        self.eventrelease = None              #   inital values

    def update(self):
        """draw using blit or old draw depending on useblit"""
        if self.useblit:
            if self.background is not None:
                self.canvas.restore_region(self.background)
            self.ax.draw_artist(self.to_draw)
            self.canvas.blit(self.ax.bbox)
        else:
            self.canvas.draw_idle()

    def onmove(self, event):
        """on move event"""
        if self.eventpress is None or self.ignore(event): return
        x, y = event.xdata, event.ydata         # actual position 
                                                # with button still pressed
        minx, maxx = self.eventpress.xdata, x   # click-x and actual mouse-x
        miny, maxy = self.eventpress.ydata, y   # click-y and actual mouse-y
        if minx > maxx: minx, maxx = maxx, minx # get them in the right order
        if miny > maxy: miny, maxy = maxy, miny
        self.to_draw.set_x(minx)                # set lower left of box
        self.to_draw.set_y(miny)
        self.to_draw.set_width(maxx - minx)     # set width and height of box
        self.to_draw.set_height(maxy - miny)
        self.update()

    def keypress(self, event):
        """on key press event"""
        if self.ignore(event): return
        self.eventpress = event
        if event.key == 'q':
            self.eventpress = None
            self.close()

    def plot_gaussians(self, params):
        """plot Gaussian components and profile"""
        plt.subplot(211)
        plt.cla()
        # Re-plot the original profile
        plt.hlines(0, 0.0, 1.0, color='black', lw=1, alpha=0.3, linestyle=':')
        plt.plot(self.phases, self.profile, c='black', lw=3, alpha=0.3)
        plt.xlabel('Pulse Phase')
        plt.ylabel('Pulse Amplitude')
        prefit_buff = 0.1
        postfit_buff = 0.1
        if self.fit_scattering: prefit_buff = 1.0
        ymin,ymax = plt.ylim()
        ymin = params[0] - prefit_buff*(self.profile.max()-self.profile.min())
        ymax = self.profile.max() + prefit_buff * \
                (self.profile.max()-self.profile.min())
        plt.ylim(ymin, ymax)
        DC = params[0]
        tau = params[1]
        # Plot the individual Gaussians
开发者ID:pennucci,项目名称:PulsePortraiture,代码行数:70,代码来源:ppgauss.py

示例5: __init__

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]

#.........这里部分代码省略.........
            self.canvas.draw()
            xmin, ymin = self.eventpress.xdata, self.eventpress.ydata
            xmax, ymax = self.eventrelease.xdata, self.eventrelease.ydata
            # calculate dimensions of box 
            if xmin>xmax: xmin, xmax = xmax, xmin        
            if ymin>ymax: ymin, ymax = ymax, ymin
            spanx = xmax - xmin                  
            spany = ymax - ymin
            xproblems = self.minspanx is not None and spanx<self.minspanx
            yproblems = self.minspany is not None and spany<self.minspany
        # call desired function
        self.onselect()
        self.eventpress = None                # reset the variables to their
        self.eventrelease = None              #   inital values

    def update(self):
        'draw using newfangled blit or oldfangled draw depending on useblit'
        if self.useblit:
            if self.background is not None:
                self.canvas.restore_region(self.background)
            self.ax.draw_artist(self.to_draw)
            self.canvas.blit(self.ax.bbox)
        else:
            self.canvas.draw_idle()

    def onmove(self, event):
        if self.eventpress is None or self.ignore(event): return
        x,y = event.xdata, event.ydata # actual position with button still pressed
        minx, maxx = self.eventpress.xdata, x # click-x and actual mouse-x
        miny, maxy = self.eventpress.ydata, y # click-y and actual mouse-y
        if minx>maxx: minx, maxx = maxx, minx # get them in the right order
        if miny>maxy: miny, maxy = maxy, miny
        self.to_draw.set_x(minx)             # set lower left of box
        self.to_draw.set_y(miny)
        self.to_draw.set_width(maxx-minx)     # set width and height of box
        self.to_draw.set_height(maxy-miny)
        self.update()
    
    def plot_gaussians(self, params):
        plt.subplot(211)
        plt.cla()
        # Re-plot the original profile
        plt.plot(self.phases, self.profile, c='black', lw=3, alpha=0.3)
        plt.xlabel('Pulse Phase')
        plt.ylabel('Pulse Amplitude')
        DC = params[0]
        # Plot the individual gaussians
        for ii in range(self.numgaussians):
            phase, FWHM, amp = params[1+ii*3:4+ii*3]
            plt.plot(self.phases, DC + amp*gaussian_profile(self.proflen, phase, FWHM))

    def onselect(self):
        event1 = self.eventpress
        event2 = self.eventrelease
        # Left mouse button = add a gaussian
        if event1.button == event2.button == 1:
            x1, y1 = event1.xdata, event1.ydata
            x2, y2 = event2.xdata, event2.ydata
            phase = 0.5*(x1+x2)
            FWHM = Num.fabs(x2-x1)
            amp = Num.fabs(1.05*(y2-self.init_params[0])*(x2-x1))
            self.init_params += [phase, FWHM, amp]
            self.numgaussians += 1
            self.plot_gaussians(self.init_params)
            plt.draw()
        # Middle mouse button = fit the gaussians
开发者ID:ariofrio,项目名称:presto,代码行数:70,代码来源:pygaussfit.py

示例6: __init__

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]
class RangeSelector:
    def __init__(self, axes, callbackPre, callbackPost):
        self.axes = axes
        self.callbackPre = callbackPre
        self.callbackPost = callbackPost

        self.eventPressed = None
        self.eventReleased = None

        props = dict(facecolor="red", edgecolor="white", alpha=0.25, fill=True, zorder=100, gid="range")
        self.rect = Rectangle((0, 0), 0, 0, **props)
        self.axes.add_patch(self.rect)

        figure = self.axes.get_figure()
        figure.canvas.mpl_connect("motion_notify_event", self.__on_move)
        figure.canvas.mpl_connect("button_press_event", self.__on_press)
        figure.canvas.mpl_connect("button_release_event", self.__on_release)

    def __on_press(self, event):
        if self.__skip_event(event):
            return

        self.eventPressed = event
        self.callbackPre()
        self.rect.set_visible(True)
        return

    def __on_move(self, event):
        if self.eventPressed is None or self.__skip_event(event):
            return

        xMin = self.eventPressed.xdata
        xMax = event.xdata
        if xMin > xMax:
            xMin, xMax = xMax, xMin
        self.callbackPost(xMin, xMax)

        return

    def __on_release(self, event):
        if self.eventPressed is None or self.__skip_event(event):
            return

        self.eventReleased = event
        xMin, xMax = self.eventPressed.xdata, self.eventReleased.xdata
        if xMin > xMax:
            xMin, xMax = xMax, xMin
        self.callbackPost(xMin, xMax)
        self.eventPressed = None
        self.eventReleased = None
        return

    def __skip_event(self, event):
        if event.button != 2:
            return True

        if self.eventPressed is None:
            return event.inaxes != self.axes

        if event.button == self.eventPressed.button and event.inaxes != self.axes:
            transform = self.axes.transData.inverted()
            (x, _y) = transform.transform_point((event.x, event.y))
            x0, x1 = self.axes.get_xbound()
            x = max(x0, x)
            x = min(x1, x)
            event.xdata = x
            return False

        return event.inaxes != self.axes or event.button != self.eventPressed.button

    def draw(self, xMin, xMax):
        self.rect.set_visible(True)
        yMin, yMax = self.axes.get_ylim()
        height = yMax - yMin
        yMin -= height * 100.0
        yMax += height * 100.0
        self.rect.set_x(xMin)
        self.rect.set_y(yMin)
        self.rect.set_width(xMax - xMin)
        self.rect.set_height(yMax - yMin)

        if self.axes._cachedRenderer is not None:
            self.axes.draw_artist(self.rect)

    def hide(self):
        self.rect.set_visible(False)

    def clear(self):
        self.rect.set_visible(False)
        canvas = self.axes.get_figure().canvas
        canvas.draw()
开发者ID:B-Rich,项目名称:RTLSDR-Scanner,代码行数:93,代码来源:plot_controls.py

示例7: Brusher

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]
class Brusher():
    '''
    A generic brusher.
    
    Expects:
    fig:  a mpl figure with subplots
      NOTE: each individual point, in each subplot, must be assigned its own color.
            e.g. use `scatter(x_coords, y_coords, c=array_of_rgba_colors)`
    data: a tuple of numpy arrays, with one entry for each axis in fig, in order (i.e. left->right then top->bottom)
      each item in the tuple must by a 2d numpy array with:
      array[0] --> 1d array of x coordinates
      array[1] --> 1d array of y coordinates
      and each list must be in the same order.
      i.e. the nth pair of values in the first array of the tuple must correspond
           to the nth pair of values in every other array in the tuple.
    '''
    
    def __init__(self, fig, data):
        '''
        fig:  a pre-rendered figure, with subplot axes
        data: the data represented in fig, formatted as described above
        '''
        self.fig  = fig
        self.data = data
        self.axl  = fig.get_axes()
        
        # internal things to keep track of
        self.button_down = False
        self.brush       = None
        self.brush_axis  = None
        self.start_xy    = (None, None)
        
        # define the colors we want to use (overwrites original figure's colors)
        self.unbrushed_color = [.5, .5, .5, .5]  # this is a transparent gray
        self.brushed_color   = [0., 0., 1., .75]  # this is a transparent blue

        # register events to track
        self.fig.canvas.mpl_connect('button_press_event', self.button_press)
        self.fig.canvas.mpl_connect('motion_notify_event', self.mouse_motion)
        self.fig.canvas.mpl_connect('button_release_event', self.button_release)


    def button_press(self, event):
        ''' handles a mouse click '''
        # if clicked outside of axes, ignore
        if not event.inaxes: return

        # remove old brush object if it's there
        if self.brush:
            self.brush.remove()
            self.unbrush_me()
            plt.draw()
    
        # start a brush here
        self.button_down = True
        self.start_xy    = (event.xdata,event.ydata)
        self.brush       = Rectangle( self.start_xy, 0,0, facecolor='gray', alpha=.15 )
        self.brush_axis  = event.inaxes
        
        # add brush to axis
        event.inaxes.add_patch(self.brush)
        plt.draw()
        
        
    def mouse_motion(self, event):
        ''' handles the mouse moving around '''
        # if we haven't already clicked and started a brush, ignore the motion
        if not (self.button_down and self.brush): return
        # if we've moved the mouse outside the starting axis, ignore
        if self.brush_axis != event.inaxes: return

        # otherwise, track the motion and update the brush
        self.brush.set_width( abs(self.start_xy[0] - event.xdata) )
        self.brush.set_height( abs(self.start_xy[1] - event.ydata) )
        self.brush.set_x( min(self.start_xy[0], event.xdata) )
        self.brush.set_y( min(self.start_xy[1], event.ydata) )
        plt.draw()


    def button_release(self, event):
        ''' handles a mouse button release '''
        self.button_down = False
        
        # if we didn't start with a brush, ignore
        if not self.brush: return
        
        # if we just clicked without drawing, remove the brush
        if (event.xdata, event.ydata) == self.start_xy:
            self.unbrush_me()
            plt.draw()
            return
        
        # if we stopped inside the same axis, update the brush one last time
        if event.inaxes == self.brush_axis:
            self.brush.set_width( abs(self.start_xy[0] - event.xdata) )
            self.brush.set_height( abs(self.start_xy[1] - event.ydata) )
            self.brush.set_x( min(self.start_xy[0], event.xdata) )
            self.brush.set_y( min(self.start_xy[1], event.ydata) )
        
        self.brush_me()
#.........这里部分代码省略.........
开发者ID:matarhaller,项目名称:Seminar,代码行数:103,代码来源:brusher.py

示例8: ComboBox

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]
class ComboBox(LineEdit):
    """
    A ComboxBox, upon clicking button, drops down a list of items to choose.

    Items can be edited also.
    """


    def __init__(
            self,
            width,
            height,
            text_list,
            edit_notify = None,
            selection_notify = None,
            **kwargs
        ):

        if len(text_list) > 0:
            text = text_list[0]
        else:
            text = ''

        super(ComboBox,self).__init__(
            width, height, text, self._on_edit_notify, **kwargs)

        self._text_list = text_list

        self._edit_notify = edit_notify
        self._selection_notify = selection_notify

        if edit_notify and not callable(edit_notify):
            raise RuntimeError('edit_notify must be a callable function')

        if selection_notify and not callable(selection_notify):
            raise RuntimeError('selection_notify must be a callable function')

        #---------------------------------------------------------------------
        # additional items
        #
        # selection axes for showing the possible selections
        # a rectangle to highlight the selection row
        # a button to show the selection drop down

        self._select_axes = None
        self._select_highlight = None # just a rectangle
        self._select_posx = None
        self._select_entries = []

        self._cb_state = ComboState.IDLE

        self._n_lines = 5

        self._mouse_motion_cid = None

        self._ignore_edit_notify = False


    def _render(self, fig, x, y):

        super(ComboBox, self)._render(fig, x, y)

        self._render_dropdown_button(fig)
        self._render_dropdown_axis(fig, x, y)


    def _render_dropdown_axis(self, fig, x, y):

        W, H = fig.get_size_inches()

        h = self._n_lines * self._height

        y -= h

        x /= W
        y /= H

        # create the other gui assets but keep them hidden

        # selection axes, same width, by 10 times in height

        w = self._width / W
        h /= H

        ax = fig.add_axes([x, y, w, h], xticks=[], yticks=[])

        ax.set_xlim([0, self._width])
        ax.set_ylim([0, self._n_lines * self._height])

        ax.set_axis_bgcolor('white')

        ax.set_visible(False)

        ax.set_zorder(1000)

        self._select_axes = ax


    def _render_dropdown_button(self, fig):

#.........这里部分代码省略.........
开发者ID:weegreenblobbie,项目名称:mplapp,代码行数:103,代码来源:combo_box.py

示例9: __init__

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_y [as 别名]
class ItemArtist:

  def __init__(self, position, state):
    self.position = position
    
    indx = state.positions.index(position)

    self.top = -state.tops[indx]
    self.top_line, = pylab.plot([0,width], 2*[self.top], c='b')

    self.bottom = -state.bottoms[indx]
    self.bottom_line, = pylab.plot([0,width], 2*[self.bottom], c='b')

    self.edge = -state.edges[indx]
    self.edge_line, = pylab.plot([0,width], 2*[self.edge], c='g')

    self.label = Text(width/2, (self.top+self.bottom)/2,
        str(position), va='center', ha='center')

    self.axes = pylab.gca()
    self.axes.add_artist(self.label)

    self.src_box = None
    self.exp_box = None
    self._check_boxes(state)


  def _check_boxes(self, state):

    if self.position == state.src:
      if self.src_box == None:
        self.src_box = Rectangle((0, self.bottom), width,
          self.top - self.bottom, fill=True, ec=None, fc='0.7')
        self.axes.add_patch(self.src_box)
      else:
        self.src_box.set_y(self.bottom)
        self.src_box.set_height(self.top - self.bottom)

    elif self.position == state.exp1:
      if state.exp1 < state.src:
        gap_bottom = self.top - state.exp1_gap
      else:
        gap_bottom = self.bottom

      if self.exp_box == None:
        self.exp_box = Rectangle((0,gap_bottom), width,
          state.exp1_gap, fill=True, ec=None, fc='0.7')
        self.axes.add_patch(self.exp_box)
      else:
        self.exp_box.set_y(gap_bottom)
        self.exp_box.set_height(state.exp1_gap)

    elif self.position == state.exp2:
      if state.exp2 < state.src:
        gap_bottom = self.top - state.exp2_gap
      else:
        gap_bottom = self.bottom

      if self.exp_box == None:
        self.exp_box = Rectangle((0,gap_bottom), width, state.exp2_gap,
          fill=True, ec=None, fc='0.7')
        self.axes.add_patch(self.exp_box)
      else:
        self.exp_box.set_y(gap_bottom)
        self.exp_box.set_height(state.exp2_gap)
    else:
      if self.src_box != None:
        self.src_box.remove()
        self.src_box = None
      if self.exp_box != None:
        self.exp_box.remove()
        self.exp_box = None


  def inState(self, state):
    return self.position in state.positions

  def update(self, position, state):
    moved = False

    if position != self.position:
      self.position = position
      self.label.set_text(str(position))

    indx = state.positions.index(self.position)

    old_top = self.top
    self.top = -state.tops[indx]
    if old_top != self.top:
      self.top_line.set_ydata(2*[self.top])
      moved = True

    old_bottom = self.bottom
    self.bottom = -state.bottoms[indx]
    if old_bottom != self.bottom:
      self.bottom_line.set_ydata(2*[self.bottom])
      moved = True

    old_edge = self.edge
    self.edge = -state.edges[indx]
#.........这里部分代码省略.........
开发者ID:03050903,项目名称:drag-sort-listview,代码行数:103,代码来源:dslv.py


注:本文中的matplotlib.patches.Rectangle.set_y方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。