Menu

[r540]: / trunk / htdocs / examples / date_demo3.py  Maximize  Restore  History

Download this file

27 lines (21 with data), 769 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
"""
intdate is a class derived from int that is seconds since the epoch
and also provides some helper functions for getting day, month, year,
etc... You can use intdate with any matplotlib plotting function, not
just plot_date
"""
from datetime import datetime
import time
from matplotlib.dates import intdate
from matplotlib.ticker import MinuteLocator, DateFormatter
from matplotlib.matlab import *
# simulate collecting data every minute starting at midnight
t0 = time.mktime(datetime(2004,04,27).timetuple())
t = t0+arange(0, 2*3600, 60) # 2 hours sampled every 2 minute
s = rand(len(t))
ax = subplot(111)
ax.xaxis.set_major_locator( MinuteLocator(20) )
ax.xaxis.set_major_formatter( DateFormatter('%H:%M') )
bar(t, s, width=60)
show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.