とりあえずグラフの描写を試してみる。
>>> import matplotlib.pyplot as plt >>> import random >>> fig, ax = plt.subplots() >>> ax.set_title(u'Random') Text(0.5,1,'Random') >>> x_ax = range(1, 256) >>> y_ax = [random.randint(512,1024) for x in x_ax] >>> ax.plot(x_ax, y_ax) [<matplotlib.lines.Line2D object at 0x109151fd0>] >>> plt.show()
python3のコンソールでこのように打つと
こんな感じにグラフができることを確認した。コレをWeb上に表示させるのが次の課題。
また、複数のグラフを重ねる(複数項目を1グラフに入れる)なら
>>> import matplotlib.pyplot as plt >>> import random >>> fig, ax = plt.subplots() >>> ax.set_title(u'Random') Text(0.5,1,'Random') >>> x_ax = range(1, 256) >>> y_ax = [random.randint(512,1024) for x in x_ax] >>> ax.plot(x_ax, y_ax) [<matplotlib.lines.Line2D object at 0x108b890f0>] >>> x_ax = range(1, 256) >>> y_ax = [random.randint(128,256) for x in x_ax] >>> ax.plot(x_ax, y_ax) [<matplotlib.lines.Line2D object at 0x108bdf898>] >>> plt.show()