码迷,mamicode.com
首页 > 其他好文 > 详细

项目 数据可视化6

时间:2018-04-27 22:58:31      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:imp   ram   row   axis   pre   title   auto   current   style   

技术分享图片 1 import csv
 2 
 3 from matplotlib import pyplot as plt
 4 
 5 filename = sitka_weather_07-2014.csv
 6 
 7 with open(filename) as f:
 8     reader = csv.reader(f)
 9     header_row = next(reader)
10     
11 
12     highs =[]
13     for row in reader:
14         high = int(row[1])
15         highs.append(high)
16 
17 
18 fig = plt.figure(dpi=128,figsize=(10,6))
19 plt.plot(highs,c=red)
20 
21 plt.title("Daoly high temperatures,July 2014",fontsize=24)
22 plt.xlabel("",fontsize=16)
23 plt.ylabel("Temperature(F)",fontsize=16)
24 plt.tick_params(axis=both,which=major,labelsize=16)
25 
26 plt.show()

技术分享图片

 import csv
from datetime import datetime

from matplotlib import pyplot as plt

filename = ‘sitka_weather_07-2014.csv‘

with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)
    
    dates,highs=[],[]

    for row in reader:
        current_date = datetime.strptime(row[0], "%Y-%m-%d")
        dates.append(current_date)
        high = int(row[1])
        highs.append(high)


fig = plt.figure(dpi=128,figsize=(10,6))
plt.plot(dates,highs,c=‘red‘)

plt.title("Daoly high temperatures,July 2014",fontsize=24)
plt.xlabel("",fontsize=16)
fig.autofmt_xdate()
plt.ylabel("Temperature(F)",fontsize=16)
plt.tick_params(axis=‘both‘,which=‘major‘,labelsize=16)技术分享图片

plt.show()

技术分享图片

技术分享图片

 

技术分享图片

 

 技术分享图片

 

 

 

技术分享图片

 

项目 数据可视化6

标签:imp   ram   row   axis   pre   title   auto   current   style   

原文地址:https://www.cnblogs.com/zhulvbo/p/8964512.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!