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
网友评论