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


Python SVGdraw.rect方法代码示例

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


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

示例1: addValue

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import rect [as 别名]
    def addValue(self, row, col, size, colour_value):
        """add a dot in row/col.
        """

        # decide the size of the box
        pos = bisect.bisect(self.mThresholdsSize, size)

        if self.mRevertSize:
            size = self.mMaxBoxSize * \
                (1.0 - float(pos) / len(self.mThresholdsSize))
        else:
            size = self.mMaxBoxSize * float(pos) / len(self.mThresholdsSize)

        d = (self.mMaxBoxSize - size) / 2

        x = self.mMapCol2Position[col] + d
        try:
            y = self.mMapRow2Position[row] + d
        except KeyError:
            return

        # determine the colour of the box
        pos = bisect.bisect(self.mThresholdsColour, colour_value)
        colour = self.mColours[pos]

        e = SVGdraw.rect(x, y,
                         size, size,
                         stroke="black",
                         fill="rgb(%i,%i,%i)" % colour)

        self.mElements.append(e)
开发者ID:CGATOxford,项目名称:cgat,代码行数:33,代码来源:go2svg.py

示例2: writeFooter

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import rect [as 别名]
    def writeFooter(self):
        """write footer.

        The footer contains the legend.
        """
        current_x = self.mFooterFrom
        current_y = self.mHeaderHeight + self.mDataHeight + 2 * self.mSeparator

        self.mFooterBoxSize = 30
        self.mNumTicks = 20
        for x in range(len(self.mColourThresholds)):

            e = SVGdraw.rect(current_x,
                             current_y,
                             self.mFooterBoxSize,
                             self.mFooterBoxSize,
                             fill="rgb(%i,%i,%i)" % self.mColours[x],
                             stroke="rgb(%i,%i,%i)" % self.mColours[x])

            self.addElement(e)

            if x % self.mNumTicks == 0:

                e = SVGdraw.line(current_x,
                                 current_y,
                                 current_x,
                                 current_y + self.mFooterBoxSize,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 stroke_width=5)
                self.addElement(e)

                e = SVGdraw.text(current_x,
                                 current_y - self.mFooterBoxSize,
                                 self.mFormatNumberLegend % self.mColourThresholds[
                                     x],
                                 self.mFooterFontSize,
                                 self.mFooterFont,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 text_anchor="start")
                self.addElement(e)

            current_x += self.mFooterBoxSize

        ###########################################################
        if self.mFooter:

            current_y += max(self.mFooterFontSize,
                             self.mMaxBoxSize) + self.mSeparator

            e = SVGdraw.text(self.mPageWidth / 2,
                             current_y + self.mFooterFontSize,
                             self.mFooter,
                             self.mFooterFontSize,
                             self.mFooterFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
开发者ID:lesheng,项目名称:cgat,代码行数:60,代码来源:plot_duplications.py

示例3: writeScale

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import rect [as 别名]
    def writeScale(self):
        """write scales."""

        current_x = self.mScaleX
        current_y = self.mScaleY + self.mScaleHeight

        nboxes = len(self.mColourThresholds)
        # box size for legend in x-direction
        # subtract size of right-most axis label so that it takes the
        # same width as self.mDataWidth.
        box_size_x = math.ceil((self.mDataWidth -
                                (self.mScaleFontSize * len(
                                    self.mFormatNumberLegend %
                                    self.mColourThresholds[-1]))) / nboxes)

        # change font size such that it labels will fit between tick-marks
        self.mScaleFontSize = min(self.mScaleFontSize,
                                  (box_size_x * self.mScaleNumTicks * 1.5) /
                                  len(self.mFormatNumberLegend %
                                      self.mColourThresholds[-1]))

        for x in range(nboxes):

            e = SVGdraw.rect(current_x,
                             current_y,
                             box_size_x,
                             self.mScaleBoxSizeY,
                             fill="rgb(%i,%i,%i)" % self.mColours[x],
                             stroke="rgb(%i,%i,%i)" % self.mColours[x])

            self.addElement(e)

            if x % self.mScaleNumTicks == 0:

                e = SVGdraw.line(current_x,
                                 current_y,
                                 current_x,
                                 current_y + self.mScaleBoxSizeY,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 stroke_width=5)
                self.addElement(e)

                e = SVGdraw.text(current_x,
                                 current_y - self.mScaleBoxSizeY,
                                 self.mFormatNumberLegend % self.mColourThresholds[
                                     x],
                                 self.mScaleFontSize,
                                 self.mScaleFont,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 text_anchor="start")
                self.addElement(e)

            current_x += box_size_x
开发者ID:BioXiao,项目名称:cgat,代码行数:55,代码来源:SVGDuplicationsWheel.py

示例4: getElements

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import rect [as 别名]
    def getElements(self, node_id, x, y):

        e = []
        colour = self.getColour(node_id, x, y)

        if self.mPlotSymbol == "circle":
            e.append(SVGdraw.circle(x + self.mFontSize / 2,
                                    y,
                                    self.mFontSize / 2,
                                    stroke="rgb(%i,%i,%i)" % BLACK,
                                    fill="rgb(%i,%i,%i)" % colour))

        elif self.mPlotSymbol == "square":
            e.append(SVGdraw.rect(x, y - self.mFontSize / 2,
                                  self.mFontSize,
                                  self.mFontSize,
                                  stroke="rgb(%i,%i,%i)" % BLACK,
                                  fill="rgb(%i,%i,%i)" % colour))

        return e
开发者ID:Charlie-George,项目名称:cgat,代码行数:22,代码来源:SVGTree.py

示例5: addDuplication

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import rect [as 别名]

#.........这里部分代码省略.........
                    self.mRadius = self.mRadiusFallBack

                self.mLastMax = max(self.mLastMax, ma)
        else:
            if self.mLastMax > mi:
                self.mRadius += self.mRadiusIncrement
                if with_separator:
                    self.addSeparator()

        self.mPreviousMin = mi
        self.mPreviousMax = ma
        self.mPreviousCis = cis

        self.mRadiusMax = max(self.mRadius, self.mRadiusMax)

        ########################################################
        ########################################################
        ########################################################
        # draw points
        ########################################################
        link_colour = master_colour
        link_rad_width = self.mLinkRadStrokeWidth
        link_arc_width = self.mLinkArcStrokeWidth
        new_points = {}
        for pos1, pos2, gene, quality, chr in points:

            angle = self.getAngle((pos1 + pos2) / 2)

            x, y = self.getPosOnArc(angle, self.mRadius)

            try:
                symbol = quality2symbol[quality]
            except KeyError:
                symbol = "rect"

            if quality in quality2mask:
                colour = self.mLinkColourSymbolMasked
                link_colour = self.mLinkColourMasked
                link_rad_width = self.mLinkStrokeWidthMasked
                link_arc_width = self.mLinkStrokeWidthMasked
            else:
                colour = master_colour

            if gene in self.mPreviousPoints:
                continue

            new_points[gene] = (x, y, angle, quality, chr)

            if symbol == "circle":
                ee = SVGdraw.circle(x, y, self.mLinkSymbolSize,
                                    fill="rgb(%i,%i,%i)" % colour,
                                    stroke="black",
                                    stroke_width=self.mLinkStrokeWidthSymbol)
            elif symbol == "rect":
                ee = SVGdraw.rect(x - self.mLinkSymbolSize / 2, y - self.mLinkSymbolSize / 2,
                                  self.mLinkSymbolSize, self.mLinkSymbolSize,
                                  fill="rgb(%i,%i,%i)" % colour,
                                  stroke="black",
                                  stroke_width=self.mLinkStrokeWidthSymbol)

            if url:
                e = SVGdraw.link(url % gene)
                e.addElement(ee)
            else:
                e = ee
开发者ID:Charlie-George,项目名称:cgat,代码行数:69,代码来源:SVGDuplicationsWheel.py

示例6: plotGene

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import rect [as 别名]
    def plotGene(self, x, y, gene=None, group_id=None):
        """plot a gene at x,y."""

        if gene:
            group_id = gene.mOrthologId

        colour, format = self.mMapGroup2Colour[group_id]

        filled, shape = format.split("-")

        if filled == "filled":
            fill = "rgb(%i,%i,%i)" % colour
            stroke = "rgb(%i,%i,%i)" % BLACK
            stroke_width = 1

        elif filled == "open":
            fill = "rgb(%i,%i,%i)" % WHITE
            stroke = "rgb(%i,%i,%i)" % colour
            stroke_width = self.mBlockSize / 2

        if shape == "circle":
            ee = SVGdraw.circle(x, y, self.mBlockSize, fill=fill, stroke=stroke, stroke_width=stroke_width)
        elif shape == "box":
            ee = SVGdraw.rect(
                x - self.mBlockSize,
                y - self.mBlockSize,
                2 * self.mBlockSize,
                2 * self.mBlockSize,
                fill=fill,
                stroke=stroke,
                stroke_width=stroke_width,
            )
        elif shape == "lefttriangle":
            ee = SVGdraw.polygon(
                (
                    (x - self.mBlockSize, y),
                    (x + self.mBlockSize, y - self.mBlockSize),
                    (x + self.mBlockSize, y + self.mBlockSize),
                ),
                fill=fill,
                stroke=stroke,
                stroke_width=stroke_width,
            )
        elif shape == "righttriangle":
            ee = SVGdraw.polygon(
                (
                    (x - self.mBlockSize, y - self.mBlockSize),
                    (x + self.mBlockSize, y),
                    (x - self.mBlockSize, y + self.mBlockSize),
                ),
                fill=fill,
                stroke=stroke,
                stroke_width=stroke_width,
            )
        elif shape == "uptriangle":
            ee = SVGdraw.polygon(
                (
                    (x, y - self.mBlockSize),
                    (x + self.mBlockSize, y + self.mBlockSize),
                    (x - self.mBlockSize, y + self.mBlockSize),
                ),
                fill="rgb(%i,%i,%i)" % WHITE,
                stroke="rgb(%i,%i,%i)" % colour,
                stroke_width=self.mBlockSize / 2,
            )
        elif shape == "downtriangle":
            ee = SVGdraw.polygon(
                (
                    (x, y + self.mBlockSize),
                    (x + self.mBlockSize, y - self.mBlockSize),
                    (x - self.mBlockSize, y - self.mBlockSize),
                ),
                fill="rgb(%i,%i,%i)" % WHITE,
                stroke="rgb(%i,%i,%i)" % colour,
                stroke_width=self.mBlockSize / 2,
            )

        return ee
开发者ID:CGATOxford,项目名称:Optic,代码行数:80,代码来源:plot_multiple_synteny.py

示例7: writeFooter

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import rect [as 别名]
    def writeFooter(self):
        """write footer.

        The footer contains the legend.
        """
        current_x = self.mFooterFrom
        current_y = self.mHeaderHeight + self.mDataHeight + 2 * self.mSeparator

        ###########################################################
        # Draw legend 1: size of boxes
        e = SVGdraw.text(current_x,
                         current_y + self.mFooterFontSize,
                         self.mThresholdsSizeTitle,
                         self.mFooterFontSize,
                         self.mFooterFont,
                         stroke="rgb(%i,%i,%i)" % BLACK,
                         text_anchor="start")

        current_x += len(self.mThresholdsSizeTitle) * \
            self.mFooterFontSize / 1.5 + self.mSeparator

        self.mElements.append(e)

        l = len(self.mThresholdsSize)
        for x in range(l):
            if self.mRevertSize:
                p = int(self.mMaxBoxSize * (1.0 - float(x) / l))
            else:
                p = int(self.mMaxBoxSize * (float(x) / l))

            e = SVGdraw.rect(current_x,
                             current_y + (self.mMaxBoxSize - p) / 2,
                             p, p,
                             stroke="black",
                             fill="rgb(%i,%i,%i)" % self.startColour)

            self.mElements.append(e)
            current_x += self.mMaxBoxSize + self.mSeparator

            t = "< %g" % (self.mThresholdsSize[x])
            e = SVGdraw.text(current_x,
                             current_y + self.mFooterFontSize,
                             t,
                             self.mFooterFontSize,
                             self.mFooterFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start")

            current_x += len(t) * self.mFooterFontSize / 1.5 + self.mSeparator
            self.mElements.append(e)

        ###########################################################
        # Draw legend 2: colour of boxes
        current_x = self.mFooterFrom
        current_y += max(self.mFooterFontSize, self.mMaxBoxSize) + \
            self.mSeparator

        e = SVGdraw.text(current_x,
                         current_y + self.mFooterFontSize,
                         self.mThresholdsColourTitle,
                         self.mFooterFontSize,
                         self.mFooterFont,
                         stroke="rgb(%i,%i,%i)" % BLACK,
                         text_anchor="start")

        current_x += len(self.mThresholdsColourTitle) * \
            self.mFooterFontSize / 1.5 + self.mSeparator

        self.mElements.append(e)

        l = len(self.mThresholdsColour)

        for x in range(l + 1):

            p = self.mMaxBoxSize

            if x < l:
                t = "< %g" % (self.mThresholdsColour[x])
            else:
                t = "> %g" % (self.mThresholdsColour[x - 1])

            e = SVGdraw.rect(current_x,
                             current_y,
                             p, p,
                             stroke="black",
                             fill="rgb(%i,%i,%i)" % self.mColours[x])

            self.mElements.append(e)
            current_x += self.mMaxBoxSize + self.mSeparator

            e = SVGdraw.text(current_x,
                             current_y + self.mFooterFontSize,
                             t,
                             self.mFooterFontSize,
                             self.mFooterFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start")

            current_x += len(t) * self.mFooterFontSize / 1.5 + self.mSeparator
            self.mElements.append(e)
#.........这里部分代码省略.........
开发者ID:CGATOxford,项目名称:cgat,代码行数:103,代码来源:go2svg.py

示例8: addDuplication

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import rect [as 别名]

#.........这里部分代码省略.........
                # get points of center
                old_x1, old_y1 = self.getPosOnArcForRadius( (self.mPreviousMax + self.mPreviousMin) / 2, r1 )
                new_x1, new_y1 = self.getPosOnArcForRadius( (ma + mi) / 2, r2 )

                # lines for interleaved spans: skip
                if not ((self.mPreviousMin < mi and self.mPreviousMax > ma) or \
                        (self.mPreviousMin > mi and self.mPreviousMax < ma)) :
##                     d = SVGdraw.pathdata( old_x2, old_y2 )
##                     d.line( new_x2, new_y2 )
##                     d.move( new_x1, new_y1 )
##                     d.line( old_x1, old_y1 )
##                     d.move( old_x2, old_y2 )
##                     e = SVGdraw.path( d,
##                                       fill = "none",
##                                       stroke = "rgb(%i,%i,%i)" % BLACK,
##                                       stroke_width = self.mMarkerWidth / 2 )

                    e = SVGdraw.line( old_x1, old_y1,
                                      new_x1, new_y1,
                                      fill = "none",
                                      stroke = "rgb(%i,%i,%i)" % GREY,
                                      stroke_width = self.mMarkerWidth / 2 )
                else:
                    # lines for covering spans, as these overlaps
                    e = None
##                     e = SVGdraw.line( old_x1, old_y1,
##                                       new_x1, new_y1,
##                                       fill = "none",
##                                       stroke = "rgb(%i,%i,%i)" % GREY,
##                                       stroke_width = self.mMarkerWidth / 2 )

            if e:
                self.addElement( e, self.mPlaneJoins )
                    

        self.mPreviousMin = mi
        self.mPreviousMax = ma
        self.mPreviousCis = cis
        
        self.mRadiusMax = max(self.mRadius, self.mRadiusMax)
        
        ## draw points
        link_colour = master_colour
        link_width = 10
        for pos1, pos2, gene, quality in points:
            
            angle = self.getAngle( (pos1 + pos2) / 2 )
            
            x,y = self.getPosOnArc( angle, self.mRadius )

            try:
                symbol = quality2symbol[quality]
            except KeyError:
                symbol = "rect"

            if quality in quality2mask:
                colour = GREY
                link_colour = GREY
                link_width = 1
            else:
                colour = master_colour

            if symbol == "circle":
                ee = SVGdraw.circle( x, y, self.mMarkerWidth,
                                     fill = "rgb(%i,%i,%i)" % colour,
                                     stroke="black",
                                     stroke_width= 1)
            elif symbol == "rect":
                ee =  SVGdraw.rect( x-self.mMarkerWidth/2, y-self.mMarkerWidth/2,
                                    self.mMarkerWidth, self.mMarkerWidth,
                                    fill = "rgb(%i,%i,%i)" % colour,
                                    stroke="black",
                                    stroke_width= 1)

            if url:
                e = SVGdraw.link( url % gene )
                e.addElement( ee )
            else:
                e = ee
            self.addElement( e )                


        angle1 = self.getAngle( mi ) 
        angle2 = self.getAngle( ma )

        x1,y1 = self.getPosOnArc( angle1, self.mRadius )
        x2,y2 = self.getPosOnArc( angle2, self.mRadius )

        d = SVGdraw.pathdata( x1, y1 )
        if cis:
            d.ellarc( self.mRadius, self.mRadius, 0, 0, 1, x2, y2 )            
        else:
            d.ellarc( self.mRadius * 2, self.mRadius * 2, 0, 0, 0, x2, y2 )

        e = SVGdraw.path( d,
                          fill = "none",
                          stroke = "rgb(%i,%i,%i)" % link_colour,
                          stroke_width = link_width )

        self.addElement(e)
开发者ID:siping,项目名称:cgat,代码行数:104,代码来源:plot_duplications.py


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