制图code

# coding=utf-8
import matplotlib.pyplot as plt
import csv
import pandas as pd
from pylab import mpl
from pylab import *
count1 = 729

#while count1 < 935:
#+str(count1)+'
for count1 in range(766,850):
        f = open('pre-processed_data(unit_area)_'+str(count1)+'.csv')
        #d = pd.read_csv('E:\zql\data_processing_v1.0\pre-processed_data(unit_area)_Pieces\pre-processed_data(unit_area)_'+count+'.csv', usecols=[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])
        data = pd.read_csv(f)
        ID = data["ID"]
        DayNum = data["DayNum"]
        time = ['0h','1h','2h','3h','4h','5h','6h','7h','8h','9h','10h','11h','12h','13h','14h','15h','16h','17h','18h','19h','20h','21h','22h','23h']
        count2 = 0
        consume = []
        for count2 in range(0,358):
                consume = data.loc[count2,time]
                #设置所绘制图的大小,长12宽4
                fig = plt.figure(figsize=(10,10))
                #开始绘制了
                plt.xticks(arange(len(time)),time)
                plt.plot(#X轴的数据
                consume.values, #Y轴的数据
                linestyle = '-', #折线的类型
                linewidth = 6, #折线的宽度
                color = 'r', #折线的颜色
                marker = '*',#折线的形状
                markersize = 6,#折线的大小
                #label = 'Electricity consumption per unit area'
                #label = '单位面积耗电量' #加入标签
                )
                #然日期呈45度角倾斜展现,避免了刻度重叠
                #fig.autofmt_xdate(rotation = 45 )
                #plt.xticks(x, time, rotation=45)
                #处理中文显示
                #mpl.rcParams['font.sans-serif'] = ['SimHei']
                #添加标题
                #plt.title('Room'+str(ID)+'Single-day power consumption line chart')
                #添加x轴的名称
                #plt.xlabel('Time')
                #添加y轴的名称
                #plt.ylabel('Single day area power consumption')
                #添加图列
                #plt.legend()
                #展示折线图
                #plt.show()
                Name= 'fig' +r'/'+str(ID[count2]) + '_' + str(DayNum[count2])+'.jpg'
                plt.savefig(Name,dpi=400)
                plt.close(0)
                consume=[]
                count2 = count2 + 1

        #count1 = count1 + 1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值