Python reportlab库之Axes(含demo)

作者: iCloudEnd | 来源:发表于2019-02-19 22:29 被阅读4次

    Axes是图表中最为常用一个类型,Axes用于显示二维数据,也就是我常用的X-Y图表。

    X属性

    X属性

    Y属性

    Jietu20190219-222824@2x.jpg Jietu20190219-222837@2x.jpg

    具体demo如下:

    from reportlab.graphics import shapes
    from reportlab.graphics.charts.axes import XCategoryAxis,YValueAxis
    from reportlab.lib import colors
    from reportlab.graphics.shapes import *
    drawing = Drawing(400, 200)
    data = [(10, 20, 30, 40), (15, 22, 37, 42)]
    xAxis = XCategoryAxis()
    xAxis.setPosition(75, 75, 300)
    xAxis.configure(data)
    xAxis.categoryNames = ['Beer', 'Wine', 'Meat', 'Cannelloni']
    xAxis.labels.boxAnchor = 'n'
    xAxis.labels[3].dy = -15
    xAxis.labels[3].angle = 30
    xAxis.labels[3].fontName = 'Times-Bold'
    yAxis = YValueAxis()
    yAxis.setPosition(50, 50, 125)
    yAxis.configure(data)
    drawing.add(xAxis)
    drawing.add(yAxis)
    from reportlab.graphics import renderPDF
    renderPDF.drawToFile(drawing, 'label_axes.pdf', 'My First Drawing')
    

    效果图


    axes demo

    相关文章

      网友评论

        本文标题:Python reportlab库之Axes(含demo)

        本文链接:https://www.haomeiwen.com/subject/nkeqyqtx.html