LoginSignup
5
4

More than 5 years have passed since last update.

時系列プロット / Matplotlib

Last updated at Posted at 2016-02-15
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)

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4