import matplotlib.pyplot as plt import pylab import numpy as np from PIL import Image from io import BytesIO
buffer_ = BytesIO() for _ in range(10): a = np.arange(1,10,0.01) y = a ** 2 figure = plt.figure() plt.plot(a,y) figure.savefig(buffer_,format = 'jpg') buffer_.seek(0) dataPIL = Image.open(buffer_) data = np.asarray(dataPIL) x = data.shape[0] y = data.shape[1] t = Image.new('RGB',(x,y)) for i in range(0,x): for j in range(0,y): t.putpixel([i,j],tuple(data[i][j])) print(data.shape) t.show() buffer_.close()