Matplotlib关于以时间为横坐标画图

Matplotlib关于以时间作为横坐标,纵坐标为data的做法。
# coding = utf-8
import dateutil, pylab,random
from pylab import *
from datetime import datetime,timedelta
 
today = datetime.now()
dates = [today + timedelta(days=i) for i in range(10)]
#values = [random.randint(1, 20) for i in range(10)]
values = [3,2,8,4,5,6,7,8,11,2]
pylab.plot_date(pylab.date2num(dates), values, linestyle='-')
text(17, 277, u'瞬时流量示意')
xtext = xlabel(u'时间time (s)')
ytext = ylabel(u'单位 (m3)')
ttext = title(u'xx示意图')
grid(True)
setp(ttext, size='large', color='r')
#setp(text, size='medium', name='courier', weight='bold',color='b')
setp(xtext, size='medium', name='courier', weight='bold', color='g')
setp(ytext, size='medium', name='helvetica', weight='light', color='b')
#savefig('simple_plot.png')
savefig('simple_plot')
show()
 


Matplotlib关于以时间为横坐标画图_第1张图片


转自:http://blog.sina.com.cn/s/blog_4d4afb6d0100aprc.html

你可能感兴趣的:(matplotlib,python)