それはいいんですが、ここで一言。
Python プロジェクトでライブラリのバージョンを管理するなら仮想環境が要ります。
numpy モジュールを読見込む際、signal.py でみごとこけました。です。
ので「休日を返せ」モードで
(Python は素晴らしい言語かもしれないが)ライブラリ管理がなっていない。
なってないです。つまり、Java でいう Central Repository + Maven がない。
「numpy を使うなら singal.py ファイルを作ってはならない」なる注意書きが必要です。信じがたい。
で、タイミング図を書く方法です。
ここのポイントは線グラフの描写で、毎クロックで縦線をひきます。
折れ線グラフは点を指定して図を描いているのと同じなので、x値を繰り返せばそこで縦線がひかれるわけですね。
xValue で指定しているのがそれです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import random | |
xValue=[] | |
for i in range(0,10): | |
r= random.randint(0,1) | |
xValue.append(i) | |
xValue.append(i) | |
xValue.append(10) | |
yValue = [0] | |
for i in range(0,10): | |
r= random.randint(0,1) | |
yValue.append(r) | |
yValue.append(r) | |
zValue = [0] | |
for i in range(0,10): | |
r= random.randint(0,1) | |
zValue.append(r) | |
zValue.append(r) | |
zValue = np.array(zValue) + 1.5 | |
uValue = [0] | |
for i in range(0,10): | |
r= random.randint(0,1) | |
uValue.append(r) | |
uValue.append(r) | |
uValue = np.array(uValue) + 3 | |
plt.plot(xValue, yValue) | |
plt.plot(xValue, zValue) | |
plt.plot(xValue, uValue) | |
plt.show() | |