I would like to make a gif using multiple png images that I generate using matplotlib. The following function should create the required histogram plots:
def make_histogram(start, end):
mean_val = statistics.mean(test_dis_item_notensor[start:end])
max_lim = 17
with plt.style.context('ggplot'):
plt.hist(test_dis[start:end], bins=100, rwidth=0.9, color='indianred', range=(0, max_lim), alpha=0.8)
plt.title('Test distributions', fontsize=22)
plt.xlabel('Distance', fontsize=20)
plt.ylabel('Amount', fontsize=20)
plt.text(mean_val*1.1, max_lim*0.9, 'Mean: {:.2f}'.format(mean_val), fontsize=22)
plt.axvline(mean_val, color='k', linestyle='dashed', linewidth=2)
histo = plt.gcf()
return histo
I tried to work with plt.gcf() but the returned object is itself not an rgb figure, what is the best way to proceed? I would like to avoid to save every image to disk and to then reload them.