こんな感じでしょうかね
Python
1import matplotlib.animation as anm
2import matplotlib.pyplot as plt
3import matplotlib.cm as cm
4import numpy as np
5
6fig = plt.figure()
7
8def update(i):
9 if i != 0:
10 plt.cla()
11 z = np.sin(i * 2 * np.pi / 100)
12 plt.scatter(0, 0, c=z, vmin=-1, vmax=1, cmap=cm.bwr)
13
14ani = anm.FuncAnimation(fig, update, frames=100, interval=50)
15plt.show()
【追記】
set_color()
を使う例
Python
1import matplotlib.animation as anm
2import matplotlib.pyplot as plt
3import matplotlib.cm as cm
4import numpy as np
5
6fig = plt.figure()
7ax = fig.add_subplot(1,1,1)
8line, = ax.plot([], [])
9ax.set_ylim(-1, 1)
10
11def update(i, ax, line):
12 x = np.arange(i)
13 y = np.sin(x * 2 * np.pi / 100)
14 line.set_data(x, y)
15 line.set_color(cm.bwr(plt.Normalize(vmin=0, vmax=100)(i)))
16 ax.set_xlim(0, i)
17
18ani = anm.FuncAnimation(fig, update, fargs=(ax, line), frames=100, interval=50)
19plt.show()
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/02 04:48
2018/09/02 06:40
2018/09/02 06:41
2018/09/02 08:55