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


Python FigureCanvasQTAgg.paintEvent方法代码示例

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


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

示例1: paintEvent

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import paintEvent [as 别名]
    def paintEvent(self, event):
        Canvas.paintEvent(self, event)
        if not self.limit_mode:
            return

       # convert to data units
        height = self.figure.bbox.height
        t = lambda s: np.array(self.axes.transData.transform(s))

        qp = QPainter()
        qp.begin(self)
        qp.setPen(QColor(*self.limit_color))

        # Draw polygon
        if self.limit_mode and self.limit_type == 1:
            for i in range(len(self.limit_data) - 1):
                start = t(self.limit_data[i])
                end = t(self.limit_data[i + 1])
                qp.drawLine(start[0], height - start[1],
                        end[0], height - end[1])
            if self.limit_data:
                start = t(self.limit_data[-1])
                end = t((self._mouse_move_event.xdata,
                    self._mouse_move_event.ydata))
                qp.drawLine(start[0], height - start[1],
                        end[0], height - end[1])

        # Draw an ellipse
        if self.limit_mode and self.limit_type == 2 and self.limit_data:
            # convert to display coordinates
            startp = t(self.limit_data[0])
            mouse = t((self._mouse_move_event.xdata,
                    self._mouse_move_event.ydata))
            center = 0.5 * (startp + mouse)

            if len(self.limit_data) == 1:  # we've set the center, draw line
                eheight = 30
                angvec = mouse - center
                angle = np.arctan2(angvec[1], angvec[0])
                ewidth = np.linalg.norm(angvec)

            elif len(self.limit_data) > 1:  # we've also fixed the angle
                angleline = t(self.limit_data[1])
                center = 0.5 * (startp + angleline)
                angvec = angleline - center
                angle = np.arctan2(angvec[1], angvec[0])
                ewidth = np.linalg.norm(angvec)
                angvec = angvec / ewidth

                mvec = mouse - center
                eheight = np.linalg.norm(mvec - np.dot(mvec, angvec) * angvec)

            if self.limit_data:
                qp.translate(center[0], height - center[1])
                qp.rotate(-angle * 180.0 / np.pi)
                qp.drawEllipse(QPoint(0, 0), ewidth, eheight)
                qp.drawLine(-ewidth, 0, ewidth, 0)
                qp.drawLine(0, -eheight, 0, eheight)

        qp.end()
开发者ID:bwillers,项目名称:pyclust,代码行数:62,代码来源:featurewidget.py

示例2: paintEvent

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import paintEvent [as 别名]
 def paintEvent(self,e):
   FigureCanvas.paintEvent(self,e)
   if self._pressed:
     painter = QPainter(self)
     painter.setPen(QPen(Qt.DotLine))
     (x1,y1) = self.figure.transFigure.inverted().transform([self._pressEvent.x,self._pressEvent.y])
     (x2,y2) = self.figure.transFigure.inverted().transform([self._moveEvent.x,self._moveEvent.y])
     painter.drawRect(x1*self.width(),(1-y1)*self.height(),(x2-x1)*self.width(),-(y2-y1)*self.height())
开发者ID:manipp4,项目名称:pyview,代码行数:10,代码来源:canvas.py

示例3: paintEvent

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import paintEvent [as 别名]
 def paintEvent(self, event):
     FigureCanvas.paintEvent(self,event)
     painter = QtGui.QPainter()
     painter.begin(self)
     painter.setRenderHint(QtGui.QPainter.Antialiasing)
     painter.fillRect(self.rect(), QtGui.QBrush(QtGui.QColor(255, 255, 255, 0)))
     if self.counter<60:
         painter.setPen(QtGui.QPen(Qt.NoPen))
         for i in range(6):
             if (old_div(self.counter, 5)) % 6 == i:
                 painter.setBrush(QtGui.QBrush(QtGui.QColor(127 + (self.counter % 5)*32, 127, 127)))
             else:
                 painter.setBrush(QtGui.QBrush(QtGui.QColor(127, 127, 127)))
             painter.drawEllipse(
                 old_div(self.width(),2) + 30 * math.cos(2 * math.pi * i / 6.0) - 10,
                 old_div(self.height(),2) + 30 * math.sin(2 * math.pi * i / 6.0) - 10,
                 20, 20)
     painter.end()
开发者ID:davtoh,项目名称:RRtools,代码行数:20,代码来源:main.py


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