Today write a basic tutorial in the second project, mainly using Python to make a PDF diagram, relatively simple.
First we need to install the module PIP install Reportlab can be Used.
The book is to use Urlopen from up and down a txt file, and then open processing to get the data, because I did not get data from this URL path, so directly write a bit of data in the Program.
Urlopen is relatively simple, later written crawler will often use, so here is not speaking, only talk about the Reportlab module Alone.
#Encoding:utf8 fromReportlab.graphics.shapesImport* fromReportlab.graphics.charts.lineplotsImportLinePlot fromReportlab.graphicsImportRenderpdfdata= [((0,0), (+)), ((5,5), (8,8)), ((9,10), (11,12))]drawing= Drawing (400,200) LP=LinePlot ()#set some related properties for the Lineplot classlp.x = 50lp.y= 50Lp.height= 125Lp.width= 300Lp.data=Datalp.lines[0].strokecolor=colors.bluelp.lines[1].strokecolor =colors.redlp.lines[2].strokecolor =colors.greendrawing.add (lp) drawing.add (String (250,150,'Myline', FontSize = 14,fillcolor =COLORS.RED)) Renderpdf.drawtofile (drawing,'lines.pdf','Myline')
The code is very simple, basically look at the name can guess the function, an example of a lineplot class, and then set some properties for this class, including the data, and then add to the drawing, basically there is nothing to say.
This time almost like this, like friends, welcome Attention.
Python Basic tutorial Notes-format a picture (detailed)