想在gridspec的子图中使用matpoltlib动画

时间:2017-11-05 19:42:32

标签: python matplotlib

import matplotlib.gridspec as gridspec
import matplotlib.animation as animation

plt.figure()

gspec = gridspec.GridSpec(2,2)

top_left = plt.subplot(gspec[0,0])
top_right = plt.subplot(gspec[0,1])
lower_left = plt.subplot(gspec[1,0])
lower_right = plt.subplot(gspec[1,1])

x1 = np.random.normal(-2.5, 1, 10000)
x2 = np.random.gamma(2, 1.5, 10000)
x3 = np.random.exponential(2, 10000)+7
x4 = np.random.uniform(14,20, 10000)

top_left.hist(x1, color='b', normed=True, bins=20, alpha=0.5)
top_right.hist(x2, color='r', normed=True, bins=20, alpha=0.5)
lower_left.hist(x3, color='y', normed=True, bins=20, alpha=0.5)
lower_right.hist(x4, color='g', normed=True, bins=20, alpha=0.5)

plt.suptitle('Subplot with GridSpec')

这是我使用gridspec的子图。我想使用matplotlib动画为所有四个子图设置动画。请帮忙。

0 个答案:

没有答案