data.txt
# data1,data2
2016-01-23,12
2016-01-24,15
2016-01-25,11
...
2016-03-09,20
time_series.py
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import dateutil
(data1, data2) = np.loadtxt("data.txt",
delimiter=",",
dtype=int)
data2 = np.array([datautil.parser.parse(v) for v in data2])
fig = plt.figure(figsize=(10,10), dpi=100)
ax = fig.add_subplot(111)
ax.xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d\n%H:%M"))
ax.plot(data1, data2, ".")
ax.set_ylim(-0.1, 1.1)
ax.grid(True)
Recommended Posts