Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def draw(data, param=[1., 2.], title='LALALA', data_type='Россия', limit=None):
- plt.rcParams["figure.figsize"]=15,10
- mean, std, count = [], [], []
- for day in range(max(len(i) for i in data)):
- arr = []
- for city in data:
- try:
- arr.append(city[day])
- except:
- pass
- mean.append(np.mean(arr))
- std.append(np.std(arr))
- count.append(len(arr))
- mean = np.array(mean)
- std = np.array(std)
- count = np.array(count)
- xasix = range(max(len(i) for i in data))
- fig = plt.figure(figsize=(20, 10))
- gs = gridspec.GridSpec(2, 1, height_ratios=[4, 1])
- ax0 = plt.subplot(gs[0])
- ax0.grid()
- ax0.plot(xasix[:len(data[0])], data[0], 'o-', color="k", label=data_type)
- ax0.fill_between(xasix, mean - 2 * std, mean + 2 * std, alpha=0.1, color="b", label="Доверительный интервал 95%")
- ax0.fill_between(xasix, mean - std, mean + std, alpha=0.2, color="r", label="Доверительный интервал 68%")
- ax0.fill_between(xasix, mean - 0.32 * std, mean + 0.32 * std, alpha=0.4, color="g", label="Доверительный интервал 25%")
- ax0.plot(xasix, mean, 'o-', color="r", label="Математическое ожидание")
- ax0.legend(loc='best', prop={'size': 16})
- matplotlib.rc('xtick', labelsize=18)
- matplotlib.rc('ytick', labelsize=18)
- plt.ylabel("Количесво заболевших", fontsize=18)
- # ax0.axes.get_xaxis().set_visible(False)
- # plt.subplot(212)
- ax1 = plt.subplot(gs[1])
- ax1.grid()
- ax1.plot(xasix, count, 'o-', color="b", label="Математическое ожидание")
- plt.xlabel('День эпидемии', fontsize=18)
- plt.ylabel("Количесво наблюдений", fontsize=18)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement