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


Python Line.setOrigin方法代码示例

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


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

示例1: Tick

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import setOrigin [as 别名]

#.........这里部分代码省略.........
        Parent.__init__(self)

        self._tickMark = Line(canvas, **tickMarkProps)
        self._label = Text(canvas, **labelProps)
        self._axis = axis

        self.addChild(self._tickMark)
        self.addChild(self._label)
        
        # Location where the tick should be placed, in data coords
        self._dataLocation = dataLoc

        self._length = 5
        self.setLength(length)

        self._direction = 'in'
        self.setDirection(direction)

    def setLabel(self, text=None, **kwprops):
        """
        Update the label Text object with the passed text and kwprops.

        If text is not a string, then the label's text will not be changed.

        If both text and kwprops['text'] are defined, the text argument takes precedence.
        """

        if isinstance(text, str):
            kwprops['text'] = text
        self._label.setProps(**kwprops)

    def setLength(self, length):
        """
        Update the length of the tick mark. The length must be an int.
        """
        if isinstance(length, int):
            self._length = length

    def setDirection(self, direction):
        """
        Update the direction of the tick mark. The direction must be either 'in'
        or 'out', and refers to whether the tick mark should be inside or outside
        the plot. The label will always be outside.
        """
        if direction in ('in', 'out', 'both'):
            self._direction = direction

    def setTickMarkProps(self, **kwprops):
        """Update the tick mark Line object with the passed kwprops."""
        self._tickMark.setProps(**kwprops)

    def setTickPosition(self):
        """
        Set the position, in plot coordinates, of both the tick mark Line object
        and the label Text object.
        """

        # Determine various points in plot coordinates
        plotLocation = self._axis.mapDataToPlot(self._dataLocation)
        labelPosition = self._axis._plotAnchor
        startPosition = self._axis._plotAnchor
        endPosition = startPosition

        if self._axis.inside() == 'up' and self._direction == 'in':
            endPosition = startPosition + self._length
        elif self._axis.inside() == 'up' and self._direction == 'out':
            endPosition = startPosition - self._length
        elif self._axis.inside() == 'up' and self._direction == 'both':
            endPosition = startPosition - self._length
            startPosition += self._length
        elif self._axis.inside() == 'down' and self._direction == 'in':
            endPosition = startPosition - self._length
        elif self._axis.inside() == 'down' and self._direction == 'out':
            endPosition = startPosition + self._length
        elif self._axis.inside() == 'down' and self._direction == 'both':
            endPosition = startPosition + self._length
            startPosition -= self._length

        self._tickMark.setOrigin(self._axis._ox, self._axis._oy)
        self._label.setOrigin(self._axis._ox, self._axis._oy)

        # Actually set the positions of the tick mark and label
        if self._axis.orientation() == 'horizontal':
            self._tickMark.setPosition(plotLocation, startPosition)
            self._tickMark.setEnd(plotLocation, endPosition)
            self._label.setPosition(plotLocation, labelPosition)
        elif self._axis.orientation() == 'vertical':
            self._tickMark.setPosition(startPosition, plotLocation)
            self._tickMark.setEnd(endPosition, plotLocation)
            self._label.setPosition(labelPosition, plotLocation)

    def remove(self):
        """Remove both the tick mark and the label from the figure."""
        self._tickMark.remove()
        self._label.remove()

    def draw(self):
        """Draw both the tick mark and the label."""
        self._tickMark.draw()
        self._label.draw()
开发者ID:bbreslauer,项目名称:Pygraphene,代码行数:104,代码来源:axis.py

示例2: setOrigin

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import setOrigin [as 别名]
 def setOrigin(self, x=0, y=0):
     """
     Set the origin, using figure coordinates.
     """
     Line.setOrigin(self, x, y)
     self.setLabelOrigin()
开发者ID:bbreslauer,项目名称:Pygraphene,代码行数:8,代码来源:axis.py


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