1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| from datetime import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
dt = np.dtype([('date', 'S10'), ('hour', 'S5'), ('value', np.float)])
def main():
data = np.loadtxt("evolution.txt", dtype=dt)
dates_str = list()
for d, h in zip(data['date'], data['hour']):
dates_str.append((d + h).decode('utf-8'))
dates = np.array([datetime.strptime (item, "%d-%m-%Y%H:%M") for item in dates_str])
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot_date( dates, data['value'], 'o-', color='g')
ax.fmt_xdata = mdates.DateFormatter('%d/%m/%Y %H:%M')
fig.autofmt_xdate()
plt.show()
if __name__ == '__main__':
main() |