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


Python Label.textAnchor方法代码示例

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


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

示例1: addChromosomes

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
def addChromosomes(drawing, chrNames, chrSizes, xmap, ymap, w=0.1*DPI, fillColor=colors.skyblue, strokeColor=colors.skyblue):
    for i,chrom in enumerate(chrNames):
        x = xmap(i+1)
        y = ymap(chrSizes[chrom])
        h = ymap(1)-ymap(chrSizes[chrom])
        
        chromosome = Rect(x,y,w,h, strokeColor=strokeColor, fillColor=fillColor)
        drawing.add(chromosome)
        
        topCap = Wedge(x+0.5*w, y+h, 0.5*w, 0, 180, strokeColor=strokeColor, fillColor=fillColor)
        bottomCap = Wedge(x+0.5*w, y, 0.5*w, 180, 0, strokeColor=strokeColor, fillColor=fillColor)
        drawing.add(topCap)
        drawing.add(bottomCap)
        
        label = Label()
        label.setOrigin(xmap(i+1)+w/2, ymap(0))
        label.boxAnchor = 's'
        label.textAnchor = 'middle'
        label.dx = 0
        label.dy = DPI/10
        label.setText(chrom)
        label.fontSize = 36
        label.fontName = 'Helvetica'
        drawing.add(label)
        
        chrLength = Label()
        chrLength.setOrigin(xmap(i+1)+w/2, ymap(chrSizes[chrom]))
        chrLength.boxAnchor = 'n'
        chrLength.textAnchor = 'middle'
        chrLength.dx = 0
        chrLength.dy = -DPI/10
        chrLength.setText('%iMb' % int(chrSizes[chrom]/1e6))
        chrLength.fontSize = 24
        chrLength.fontName = 'Helvetica'
        drawing.add(chrLength)
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:37,代码来源:drawChroms.py

示例2: draw

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
 def draw(self):
     # general widget bits
     w = float(self.length)
     h = float(self.height)
     g = shapes.Group()
     
     body = shapes.Polygon(
         [self.x-0.5*w, self.y-0.5*w,
          self.x-0.5*w, self.y+0.5*w,
          self.x+0.5*w, self.y],
         fillColor=self.fillColor,
         strokeColor=self.strokeColor,
         strokeWidth=self.strokeWidth)
     g.add(body)
     
     if self.label:
         b = g.getBounds()
         s = Label()
         s.setText(self.label)
         s.setOrigin(self.x+0.5*w, self.y-h/2+b[3]-b[1]+4)
         s.boxAnchor = self.boxAnchor
         s.textAnchor = self.textAnchor
         s.fontName = 'Helvetica'
         s.fontSize = self.fontSize
         s.angle = self.labelAngle
         g.add(s)
     
     return g
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:30,代码来源:Glyphs.py

示例3: addScale

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
def addScale(drawing, xmap, y, start, end, tickLen=10, dx=3, dy=6,
  textAnchor='middle', boxAnchor='s', fontSize=12,
  strokeWidth=1, strokeColor=colors.black, scale=1.0, format='%ibp'):
    x1 = xmap(start)
    x2 = xmap(end)
    line = Line(x1+dx,y,x2-dx,y,
        strokeWidth=strokeWidth, strokeColor=strokeColor)
    drawing.add(line)
    
    leftTick = Line(x1+dx,y-0.5*tickLen,x1+dx,y+0.5*tickLen,
        strokeWidth=strokeWidth, strokeColor=strokeColor)
    drawing.add(leftTick)
    
    rightTick = Line(x2-dx,y-0.5*tickLen,x2-dx,y+0.5*tickLen,
        strokeWidth=strokeWidth, strokeColor=strokeColor)
    drawing.add(rightTick)
    
    label = Label()
    label.setOrigin(0.5*(x1+x2), y+dy)
    
    distance = float(end-start)/scale
    label.setText(format % (distance/scale))
    label.fontSize = fontSize
    label.textAnchor = textAnchor
    label.boxAnchor = boxAnchor
    drawing.add(label)
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:28,代码来源:__init__.py

示例4: title_draw

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
 def title_draw(self, x, y, text):
     chart_title = Label()
     chart_title.x = x
     chart_title.y = y
     chart_title.fontName = 'FreeSansBold'
     chart_title.fontSize = 16
     chart_title.textAnchor = 'middle'
     chart_title.setText(text)
     return chart_title
开发者ID:jink8904,项目名称:mysite,代码行数:11,代码来源:pdf.py

示例5: setDescription

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
 def setDescription(self):
     desc = Label()        
     desc.fontName = 'Helvetica'
     desc.fontSize = 12
     desc.x = 230
     desc.y = 10
     desc._text = self._data_dict.get('description', '')
     desc.maxWidth = 280
     desc.height = 20
     desc.textAnchor ='middle'
     self.add(desc, name='Description')
开发者ID:upfrontsystems,项目名称:tarmii.theme,代码行数:13,代码来源:charts.py

示例6: setTitle

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
 def setTitle(self):
     title = Label()        
     title.fontName = 'Helvetica-Bold'
     title.fontSize = 12
     title.x = 300
     title.y = 335
     title._text = self._data_dict.get('title', '')
     title.maxWidth = 180
     title.height = 20
     title.textAnchor ='middle'
     self.add(title, name='Title')
开发者ID:upfrontsystems,项目名称:tarmii.theme,代码行数:13,代码来源:charts.py

示例7: addLabels

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
    def addLabels(self,drawing,title=None,xlabel=None,ylabel=None):
        from reportlab.graphics.charts.textlabels import Label
        if not title is None:
            Title = Label()
            Title.fontName = 'Helvetica-Bold'
            Title.fontSize = 7
            Title.x = drawing.width/2
            Title.y = drawing.height-25
            Title._text = title
            Title.maxWidth = 180
            Title.height = 20
            Title.textAnchor ='middle'
            drawing.add(Title)

        if not xlabel is None:
            XLabel = Label()
            XLabel.fontName = 'Helvetica'
            XLabel.fontSize = 7
            XLabel.x = drawing.width/2
            XLabel.y = 10
            XLabel.textAnchor ='middle'
            XLabel.maxWidth = 100
            XLabel.height = 20
            XLabel._text = xlabel
            drawing.add(XLabel)

        if not ylabel is None:
            YLabel = Label()
            YLabel.fontName = 'Helvetica'
            YLabel.fontSize = 7
            YLabel.x = 12
            YLabel.y = drawing.height/2
            YLabel.angle = 90
            YLabel.textAnchor ='middle'
            YLabel.maxWidth = 100
            YLabel.height = 20
            YLabel._text = ylabel
            drawing.add(YLabel)
开发者ID:jhuguetn,项目名称:WAD_Python,代码行数:40,代码来源:reporter.py

示例8: setAxesLabels

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
    def setAxesLabels(self):
        xlabel = Label()
        xlabel.fontName = 'Helvetica'
        xlabel.fontSize = 12
        xlabel.x = 450
        xlabel.y = 40
        xlabel._text = self._data_dict.get('xlabel', '')
        xlabel.maxWidth = 180
        xlabel.height = 20
        xlabel.textAnchor ='middle'
        self.add(xlabel, name='xlabel')

        ylabel = Label()
        ylabel.fontName = 'Helvetica'
        ylabel.fontSize = 12
        ylabel.x = 20
        ylabel.y = 210
        ylabel.angle = 90
        ylabel._text = self._data_dict.get('ylabel', '')
        ylabel.maxWidth = 180
        ylabel.height = 20
        ylabel.textAnchor ='middle'
        self.add(ylabel, name='ylabel')
开发者ID:upfrontsystems,项目名称:tarmii.theme,代码行数:25,代码来源:charts.py

示例9: addLabel

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
def addLabel(drawing, x, y, text, fontName='Helvetica', fontSize=11, dy=0,
             angle=0, boxAnchor='sw', textAnchor='start'):
    """Add a label to the drawing. 
    This interface here is inconsistent in that it requires pixel coords. FIX
    This just sets convenient defaults for Label."""
    label = Label()
    label.setText(text)
    label.setOrigin(x, y)
    label.fontName = fontName
    label.fontSize = fontSize
    label.boxAnchor = boxAnchor
    label.textAnchor = textAnchor
    label.dy = dy
    label.angle = angle
    drawing.add(label)
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:17,代码来源:__init__.py

示例10: addPointyCompoundFeature

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
def addPointyCompoundFeature(drawing, xmap, y, gene, 
  strokeColor=None, fillColor=colors.blue, intronColor=colors.blue,
  glyph=PointyBlock, height=12, utrHeight=6, rise=8, 
  labeldy=10, fontSize=10, textAnchor='middle', boxAnchor='s'):
    """Adds a pointy compound feature to the drawing. This is typically
    several exons joined by zig-zag lines with an arrow showing strand."""
    if gene.strand=='+':
        x1,x2 = xmap(gene.start), xmap(gene.end)
    else:
        x2,x1 = xmap(gene.start), xmap(gene.end)
    y = y+height/2
    y1 = y
    line = Line(x1,y1,x2,y1,strokeColor=intronColor)
    drawing.add(line)
    
    for exon in gene:
        if exon.strand=='+':
            x1,x2 = xmap(exon.start), xmap(exon.end)
        else:
            x2,x1 = xmap(exon.start), xmap(exon.end)
        
        g = glyph()
        g.x = x1
        g.y = y
        if exon.kind.lower()=='utr':
            g.height = utrHeight
        else:
            g.height = height
        g.length = x2-x1
        g.fillColor = fillColor
        if strokeColor:
            g.strokeColor = strokeColor
        else:
            g.strokeColor = fillColor
        g.fontSize = fontSize
        drawing.add(g)
    
    label = Label()
    label.setText(gene.name)
    x = 0.5*(gene.start+gene.end)
    label.setOrigin(x,y)
    label.dy = labeldy
    label.textAnchor = textAnchor
    label.boxAnchor = boxAnchor
    drawing.add(label)
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:47,代码来源:__init__.py

示例11: addAxis

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
def addAxis(drawing, xmap, y, strokeWidth=1, minorStrokeWidth=0.5, 
  tickDir='down', autoTicks=False, nTicks=20, tickLen=5, fontSize=10, nMinorTicks=80, 
  minorTickLen=2, angle=0, dx=0, dy=-2, textAnchor='middle', boxAnchor=None, 
  scale=1.0, format='%i'):
    """Add a horizontal axis to the drawing.
    
    To do: Round tick positions
    """
    line = Line(xmap.x0, y, xmap.x1, y, strokeWidth=strokeWidth)
    drawing.add(line)
    
    if not boxAnchor:
        if tickDir=='down':
            boxAnchor = 'n'
        else:
            boxAnchor = 's'
    signum = {'up': -1, 'down': 1}[tickDir]
    
    if nTicks>0:
        ticks = tick_generator(xmap.start, xmap.end, n=nTicks, convert=int)
    
    for p in ticks:
        x = xmap(p)
        line = Line(x, y, x, y-signum*tickLen, strokeWidth=strokeWidth)
        drawing.add(line)
        s = Label()
        s.setOrigin(x, y-signum*tickLen)
        s.setText(format % (p/scale))
        s.dx = dx
        s.dy = signum*dy
        s.fontName = 'Helvetica'
        s.fontSize = fontSize
        s.textAnchor = textAnchor
        s.boxAnchor = boxAnchor
        s.angle = angle
        drawing.add(s)
    
    minorticks = tick_generator(xmap.start, xmap.end, n=nMinorTicks, convert=int)
    for p in minorticks:
        x = xmap(p)
        line = Line(x, y, x, y-signum*minorTickLen, strokeWidth=minorStrokeWidth)
        drawing.add(line)
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:44,代码来源:__init__.py

示例12: addAxis

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
def addAxis(drawing, xmap, y, fontSize=8, tickLen=4, minorTickLen=2, 
 nTicks=20, strokeWidth=1, minorStrokeWidth=0.5):
    line = Line(xmap.x0, y, xmap.x1, y, strokeWidth=strokeWidth)
    drawing.add(line)

    ticks = tick_generator(xmap.start, xmap.end, n=nTicks, convert=int)
    for p in ticks:
        x = xmap(p)
        line = Line(x, y, x, y-tickLen, strokeWidth=strokeWidth)
        drawing.add(line)
        s = Label()
        s.setOrigin(x, y-tickLen)
        s.setText(str(p))
        s.fontName = 'Helvetica'
        s.fontSize = fontSize
        s.textAnchor = 'middle'
        s.boxAnchor = 'n'
        drawing.add(s)

    minorticks = tick_generator(xmap.start, xmap.end, n=50, convert=int)
    for p in minorticks:
        x = xmap(p)
        line = Line(x, y, x, y-minorTickLen, strokeWidth=minorStrokeWidth)
        drawing.add(line)
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:26,代码来源:draw_orig.py

示例13: draw

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
    def draw(self):
        g = Group()

        #box
        g.add(Rect(self.x,self.y,len(self.xlabels)*self.gridDivWidth,len(self.ylabels)*self.gridDivWidth,
                   strokeColor=self.gridColor,
                   strokeWidth=self.strokeWidth,
                   fillColor=None))

        #internal gridding
        for f in range (1,len(self.ylabels)):
            #horizontal
            g.add(Line(strokeColor=self.gridColor,
                       strokeWidth=self.strokeWidth,
                       x1 = self.x,
                       y1 = self.y+f*self.gridDivWidth,
                       x2 = self.x+len(self.xlabels)*self.gridDivWidth,
                       y2 = self.y+f*self.gridDivWidth))
        for f in range (1,len(self.xlabels)):
            #vertical
            g.add(Line(strokeColor=self.gridColor,
                       strokeWidth=self.strokeWidth,
                       x1 = self.x+f*self.gridDivWidth,
                       y1 = self.y,
                       x2 = self.x+f*self.gridDivWidth,
                       y2 = self.y+len(self.ylabels)*self.gridDivWidth))

        # draw the 'dot'
        g.add(Circle(strokeColor=self.gridColor,
                     strokeWidth=self.strokeWidth,
                     fillColor=self.dotColor,
                     cx = self.x+(self.dotXPosition*self.gridDivWidth),
                     cy = self.y+(self.dotYPosition*self.gridDivWidth),
                     r = self.dotDiameter/2.0))

        #used for centering y-labels (below)
        ascent=getFont(self.labelFontName).face.ascent
        if ascent==0:
            ascent=0.718 # default (from helvetica)
        ascent=ascent*self.labelFontSize # normalize

        #do y-labels
        if self.ylabels != None:
            for f in range (len(self.ylabels)-1,-1,-1):
                if self.ylabels[f]!= None:
                    g.add(String(strokeColor=self.gridColor,
                             text = self.ylabels[f],
                             fontName = self.labelFontName,
                             fontSize = self.labelFontSize,
                             fillColor=_PCMYK_black,
                             x = self.x-self.labelOffset,
                             y = self.y+(f*self.gridDivWidth+(self.gridDivWidth-ascent)/2.0),
                             textAnchor = 'end'))

        #do x-labels
        if self.xlabels != None:
            for f in range (0,len(self.xlabels)):
                if self.xlabels[f]!= None:
                    l=Label()
                    l.x=self.x+(f*self.gridDivWidth)+(self.gridDivWidth+ascent)/2.0
                    l.y=self.y+(len(self.ylabels)*self.gridDivWidth)+self.labelOffset
                    l.angle=90
                    l.textAnchor='start'
                    l.fontName = self.labelFontName
                    l.fontSize = self.labelFontSize
                    l.fillColor = _PCMYK_black
                    l.setText(self.xlabels[f])
                    l.boxAnchor = 'sw'
                    l.draw()
                    g.add(l)

        return g
开发者ID:AceZOfZSpades,项目名称:RankPanda,代码行数:74,代码来源:dotbox.py

示例14: addCompoundFeature

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import textAnchor [as 别名]
def addCompoundFeature(drawing, xmap, y, gene, 
  strokeColor=None, fillColor=colors.blue, 
  intronColor=colors.blue, intronWidth=0.5,
  glyph=Block, height=12, utrHeight=6,
  labeldy=10, fontSize=10, textAnchor='middle', boxAnchor='s'):
    """Adds a compund feature to the drawing.
    A compound feature is typically several exons joined by zig-zag lines."""
    rise = height + utrHeight
    
    intronStarts = [None]
    intronEnds = []
    heights = []
    for exon in gene:
        x1,x2 = xmap(exon.start), xmap(exon.end)
        
        kind = exon.kind.lower()
        if kind in ['exon', 'utr']:
            intronStarts.append(exon.end)
            intronEnds.append(exon.start)
        
        g = glyph()
        g.x = x1
        g.y = y+height/2
        if exon.kind.lower()=='exon':
            g.height = height
            heights.append(height)
        else:
            g.height = utrHeight
            heights.append(utrHeight)
        
        g.length = x2-x1
        g.fillColor = fillColor
        if strokeColor:
            g.strokeColor = strokeColor
        else:
            g.strokeColor = fillColor
        g.fontSize = fontSize
        drawing.add(g)
    
    for i,(intronStart,intronEnd) in enumerate(zip(intronStarts[1:], intronEnds[1:])):
        x1 = xmap(intronStart)
        x2 = xmap(0.5*(intronStart+intronEnd))
        x3 = xmap(intronEnd)
        # if abs(x3-x1)<3: continue
        # print intronStart,intronEnd,heights[i],heights[i+1]
        
        y1 = y+heights[i]/2+height/2
        y2 = y+rise
        y3 = y+heights[i+1]/2+height/2
        
        line1 = Line(x1,y1,x2,y2,strokeColor=intronColor,strokeWidth=intronWidth)
        line2 = Line(x2,y2,x3,y3,strokeColor=intronColor,strokeWidth=intronWidth)
        drawing.add(line1)
        drawing.add(line2)
    
    # Draw arrows
    if xmap.flipped:
        signum = -1
    else:
        signum = 1
    
    if gene.strand=='+':
        x1 = xmap(gene.end)
        x2 = x1 + signum*15
        x3 = x1 + signum*10
        y1 = y + 0.5*height
        y2 = y + 0.75*height
        y3 = y + 0.25*height
        line1 = Line(x1,y1,x2,y1,strokeColor=intronColor,strokeWidth=intronWidth)
        line2 = Line(x2,y1,x3,y2,strokeColor=intronColor,strokeWidth=intronWidth)
        line3 = Line(x2,y1,x3,y3,strokeColor=intronColor,strokeWidth=intronWidth)
        drawing.add(line1)
        drawing.add(line2)
        drawing.add(line3)
    else:
        x1 = xmap(gene.start)
        x2 = x1 - signum*15
        x3 = x1 - signum*10
        y1 = y + 0.5*height
        y2 = y + 0.75*height
        y3 = y + 0.25*height
        line1 = Line(x1,y1,x2,y1,strokeColor=intronColor,strokeWidth=intronWidth)
        line2 = Line(x2,y1,x3,y2,strokeColor=intronColor,strokeWidth=intronWidth)
        line3 = Line(x2,y1,x3,y3,strokeColor=intronColor,strokeWidth=intronWidth)
        drawing.add(line1)
        drawing.add(line2)
        drawing.add(line3)
    
    # if gene has attribute name...
    label = Label()
    label.setText(gene.name)
    pos = 0.5*(gene.start+gene.end)
    x = xmap(pos)
    label.setOrigin(x,y)
    label.dy = labeldy
    label.textAnchor = textAnchor
    label.boxAnchor = boxAnchor
    drawing.add(label)
开发者ID:SiriusShiu,项目名称:Mungo,代码行数:100,代码来源:__init__.py


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