This article mainly introduces Python using Reportlab diagram example, we refer to the use of the bar
Preparation Development environment: Python2.6,reportlab Preparing Chinese font files: SIMSUN.TTC code: Code as follows: #!/usr/bin/env python2.6 # Coding:utf-8 Import traceback reportlab.graphics.shapes import Drawing from Reportlab.graphics.charts . lineplots import Lineplot from reportlab.graphics.charts.textlabels import Label from reportlab.graphics Import Renderpdf from reportlab.graphics.widgets.markers import makemarker from reportlab.pdfbase import Pdfmetrics, Ttfonts & nbsp #注意data的类型, #每一个数据点是一个元组 #一条曲线对应一个存储数据点元组的元组 #一个图形可以包含多条曲线, using a list of data=[((1,100), (2,200), (3,300), (4,400), (5,500 )), ((1,50), (2,80), (3,400), (4,40), (5,70))] drawing = Drawing (M) LP = Lineplot () lp.x = #坐标轴中心坐标 LP. y = lp.height = Lp.width = Lp.data = Data Lp.joinedlines = 1 Lp.lines.symbol = Makemarker (' filledcircle ')   ; Lp.xValueAxis.valueMin = 1 Lp.xValueAxis.valueMax = 5 Lp.xValueAxis.valueStep = 1 lp.yValueAxis.valueMin = 0 Lp.yva Lueaxis.valuemax = lp.yvalueaxis.vAluestep = DRAWING.ADD (LP) title = Label () #若需要显示中文, you need to first register a Chinese font pdfmetrics.registerfont (ttfonts. Ttfont ("haha", "SIMSUN.TTC")) title.fontname = "haha" title.fontsize = Title_text = Unicode (' Hello ', ' GBK ') # Title_text = "abc" Title._text = Title_text title.x = title.y & nbsp = 280 title.textanchor = ' middle ' drawing.add (title) Xlabel = Label () Xlabel._text = ' x ' xlabel.fontsize   ; = xlabel.x = xlabel.y = xlabel.textanchor = ' Middle ' drawing.add (xlabel) Ylabel = Label () Ylabel._text = "Y" ylabel.fontsize = ylabel.x = ylabel.y = 295 ylabel.textanchor = ' Middle ' drawing.add (Ylabel) Try: drawing.save (formats=[' gif '],outdir= ", fnroot=" abc ") except: Traceback.print_exc ()