I create a pptx file using python pptx package (python 2.7)
I have a image in memory that i create using matplotlib with this code:
import matplotlib.pyplot as plt
plt.clf()
plt.imshow(data, cmap='hot', interpolation='nearest')
plt.xlabel(x_l)
plt.ylabel(y_l)
plt.title(title)
x_values = range(len(times))
plt.xticks(x_values[::len(x_values)/24], range(24))
plt.yticks(range(len(dates)),dates)
plt.axes().set_aspect('auto')
return plt.gcf()
Later i try to add this image to the pptx file using
pic = shapes.add_picture(image, left,top = top, width= width, height = height )
and get the following error: AttributeError: 'Figure' object has no attribute 'read'
The code works if i save the image to a file and then read it to the pptx file with the path, with exactly the same code. adding image file to pptx file
I found only how to add an image file to the pptx, and nothing about adding image from memory.
I need to add it without saving any file to disk.
Thanks!