简体   繁体   English

有没有办法在Reportlab中设置字体大小?

[英]Is there any way setting font size in Reportlab?

I am trying to make simple chart using reportlab with python. 我正在尝试使用带有python的reportlab制作简单的图表。

I made chart with title of x and y, but the font seems like small. 我制作了带有x和y标题的图表,但字体看起来很小。

I wanna change font to be bold and increase font size. 我想将字体更改为粗体并增加字体大小。

here is my code. 这是我的代码。

def DrawPowerChart(self):

    arrX = [0]*6
    arrY = [0]*3
    for i in range(6):
        arrX[i] = i * 60
    for i in range(3):
        arrY[i] = i * 40    

    drawing = Drawing(400,400)

    self.data = [
        ((10,30), (40,3), (70,72), (100,33), (130,14), (160,52), (190,68), (220,37),(250,70),(280,80))
    ]

    lp = LinePlot()
    lp.x = 50
    lp.y = 50
    lp.height = 300
    lp.width = 300
    lp.data = self.data
    lp.joinedLines = 3
    lp.lines[0].strokeWidth = 4
    lp.strokeColor = colors.black
    lp.xValueAxis.valueMin = 0
    lp.xValueAxis.valueMax = 300
    lp.yValueAxis.valueMin = 0
    lp.yValueAxis.valueMax = 80
    lp.xValueAxis.valueSteps = arrX
    lp.yValueAxis.valueSteps = arrY
    drawing.add(String(360,40,"Time(s)")) #this is label x
    drawing.add(String(30,370,"Power(W)")) #this is label y 

I knew if i use canvas i will be solved but I wanna make chart picture including title 我知道如果我使用画布我将被解决但我想制作包括标题的图表图片

See page 95 of the ReportLab User Guide for details. 有关详细信息,请参见“ ReportLab用户指南”的第95页。 Here's an example of how you can change the font size and colour: 以下是如何更改字体大小颜色的示例:

d.add(String(150,100, 'Hello World', fontSize=18, fillColor=colors.red))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM