Python Basic tutorial Notes-format a picture (detailed)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.