前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python-object-one-ne

python-object-one-ne

作者头像
py3study
发布2020-01-14 11:12:42
4340
发布2020-01-14 11:12:42
举报
文章被收录于专栏:python3python3
代码语言:javascript
复制
#!/usr/bin/env python2.6
 # Written by Tony.yang
 # 2012-12-28 
 
 from urllib import urlopen
 from reportlab.graphics.shapes import *
 from reportlab.graphics.charts.lineplots import LinePlot
 from reportlab.graphics.charts.textlabels import Label
 from reportlab.graphics import renderPDF
 
 URL = 'http://www.swpc.noaa.gov/ftpdir/weekly/Predict.txt'
 COMMENT_CHARS = '#:'
 
 # Create a Drawing mode
 drawing = Drawing(400, 200)
 data = []
 
 for line in urlopen(URL).readlines():
         if not line.isspace() and not line[0] in COMMENT_CHARS:
                 data.append([float(n) for n in line.split()])
 
 # define property
 pred = [row[2] for row in data]
 high = [row[3] for row in data]
 low = [row[4] for row in data]
 times = [row[0] + row[1]/12.0 for row in data]
 
 #
 lp = LinePlot()
 lp.x = 50
 lp.y = 50
 lp.height = 125 
 lp.width = 300 
 lp.data = [zip(times, pred), zip(times, high), zip(times, low)]
 lp.lines[0].strokeColor = colors.blue
 lp.lines[1].strokeColor = colors.red
 lp.lines[2].strokeColor = colors.green
 
 drawing.add(lp)
 drawing.add(String(250, 150, 'Sunspots', fontSize=14, fillColor=colors.red))
 
 renderPDF.drawToFile(drawing, 'Tony_report_new.pdf', 'Sunspots')
 
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-07-13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档