import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pandas import Series,DataFrame
import seaborn as sns
import matplotlib.dates as mdate
import sys
#sep指定分隔符,header首行是列名,读取时error_bad_lines去掉报错的行
df = pd.read_csv(sys.path[0]+'\\ogg.csv',encoding = "utf-8",header = 0,error_bad_lines=False,sep=',')
#pd.date_range生成时间序列freq控制了1天为间隔
print(len(pd.date_range('20190418', '20190618',freq='1D')))
serise=pd.date_range('20190418', '20190618',freq='1D')
ax1=plt.plot(serise,df['time'],color='black',label = "OGG")
print(plt.gca())
plt.gca().xaxis.set_major_formatter(mdate.DateFormatter('%Y-%m-%d'))
plt.xticks(pd.date_range('20190418','20190618',freq='20d'))
df = pd.read_csv(sys.path[0]+'\\bi.csv',encoding = "utf-8",header = 0,error_bad_lines=False,sep=',')
print(len(pd.date_range('20190418', '20190618',freq='1D')))
serise=pd.date_range('20190418', '20190618',freq='1D')
ax1=plt.plot(serise,df['time'],color='red',label = "BI")
print(pl
python 画图以时间为坐标轴
最新推荐文章于 2023-12-21 09:26:28 发布