Вы можете использовать fig.canvas.tostring_rgb
.Вот пример кода, подробности в комментариях.
# create a dummy image to plot
img = np.random.randint(255, size=(20,20,3))
# you need a figure to use canvas methods
# if you didn't create yours you can probably get it with plt.gcf()
fig, ax = plt.subplots()
# plot your stuff
ax.imshow(img)
# force draw
fig.canvas.draw()
# save buffer
w, h = fig.canvas.get_width_height()
buffer = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8).reshape(h, w, 3)
# display your plot
plt.show()
# look at the buffer
fig, ax = plt.subplots()
ax.imshow(buffer)
plt.show()
Первый участок

Экспортированный буфер
